# mysql\_db module, variables and hyphenated DB names

**URL:** <https://forum.ansible.com/t/mysql-db-module-variables-and-hyphenated-db-names/25256>\
**Category:** Ansible Project\
**Created:** [August 15, 2017, 2:03pm UTC](https://forum.ansible.com/t/mysql-db-module-variables-and-hyphenated-db-names/25256 "2017-08-15T14:03:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark.haney](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mark.haney](https://forum.ansible.com/u/mark.haney)\
**Post date:** [August 15, 2017, 2:03pm UTC](https://forum.ansible.com/t/mysql-db-module-variables-and-hyphenated-db-names/25256/1 "2017-08-15T14:03:39Z")

</div>

So, I’m trying to built a task list for backing up our primary DB server. The issue is that ONE database has a hyphenated name (no, I’m not the one that did something that stupid). Here’s the task that bombs:

- name: backup mysql  
vars:  
exclude\_db:

- “information\_schema”

- “performance\_schema”

- “mysql”

- “test”

- “sat\_master”

- “`google-provisioning`”  
shell: 'mysql -NBA -e “show databases;” ’  
register: dblist

- name: backup databases  
mysql\_db:  
state: dump  
name: “{{ item }}”  
target: “/backups/{{ ansible\_month }}/{{ ansible\_day }}/{{ item }}\_bu.bz2”  
login\_user: root  
#login\_password: “{{ vault\_root\_passwd }}”  
with\_items: “{{ dblist.stdout\_lines | difference(exclude\_db) }}”

And here’s the error message:

Unable to look up a name or access an attribute in template string ({{ dblist.stdout\_lines | difference(exclude\_db) }}).  
Make sure your variable name does not contain invalid characters like ‘-’: argument of type ‘StrictUndefined’ is not iterable

I can build shell commands for this if I have to, but is there a way to make ansible behave with this one DB? BTW, I’ve added it to the vars it’s ‘google-provisioning’. I’ve tried the backticks as per normal mysql methods, but that doesn’t seem to help. I’ve also tried escape it via \ but nothing has worked. I’d really like to strangle the cretin that did this, but is there any way to make this work without hand crafting individual backup tasks?
