# Ansible 2.1.0 - How to avoid dashes error with rendering templates (like my.cnf)

**URL:** <https://forum.ansible.com/t/ansible-2-1-0-how-to-avoid-dashes-error-with-rendering-templates-like-my-cnf/22362>\
**Category:** Ansible Project\
**Tags:** galaxy-ng\
**Created:** [August 23, 2016, 3:52pm UTC](https://forum.ansible.com/t/ansible-2-1-0-how-to-avoid-dashes-error-with-rendering-templates-like-my-cnf/22362 "2016-08-23T15:52:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cepxio](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cepxio/32/1458_2.png) [@Cepxio](https://forum.ansible.com/u/Cepxio)\
**Post date:** [August 23, 2016, 3:52pm UTC](https://forum.ansible.com/t/ansible-2-1-0-how-to-avoid-dashes-error-with-rendering-templates-like-my-cnf/22362/1 "2016-08-23T15:52:30Z")

</div>

Hi all!

I am new in Ansible and this Group, so thanks in advance for the patience and help.

I’m writing a Playbook Roles for install and setup MySQL RDBMS on Linux (CentOS), and I get an error with the template module when ansible parses the my.cnf.j2.  
Here the msg err

TASK [mysql : Copy my.cnf global MySQL configuration.] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /opt/settings/ansible/roles/mysql/tasks/configure.yml:2  
fatal: [v1080udesa]: FAILED! =\> {“changed”: false, “failed”: true, “invocation”: {“module\_args”: {“dest”: “/etc/my.cnf”, “group”: “root”, “mode”: “0644”, “owner”: “root”, “src”: “my.cnf.j2”}, “module\_name”: “template”}, “msg”: “AnsibleUndefinedVariable: Unable to look up a name or access an attribute in template string (# The MySQL database server configuration file.\n **[cut output for sanity]** key\_buffer\t\t\t= 64M\n\n).\nMake sure your variable name does not contain invalid characters like ‘-’: unsupported operand type(s) for -: ‘StrictUndefined’ and ‘StrictUndefined’”}  
to retry, use: --limit @install\_mysql.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

I’m refurbishing one Role from Ansible-Galaxy, so I think that this works already for others DBAs. (but i don’t know if this version work)  
I searched several roles on Galaxy and all users have the same template command and similar template file.  
In addition, I leave the link: [https://galaxy.ansible.com/geerlingguy/mysql/](https://galaxy.ansible.com/geerlingguy/mysql/)  
Could someone help me to find if it is an error with the playbook or a version bug?

Regards!

---

<div class="post-metadata">

**Author:** ![Cepxio](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cepxio/32/1458_2.png) [@Cepxio](https://forum.ansible.com/u/Cepxio)\
**Post date:** [August 24, 2016, 2:56pm UTC](https://forum.ansible.com/t/ansible-2-1-0-how-to-avoid-dashes-error-with-rendering-templates-like-my-cnf/22362/2 "2016-08-24T14:56:08Z")

</div>

Hi again, I found the problem.  
I did not realize from change the name of the values in template and I only changed it in the defaults file.

**myisam-recover-options = {{ mysql\_myisam-recover-options }}**

So, I correct it and it works.

Thanks!

---

<div class="post-metadata">

**Author:** ![Sukhdeep\_Singh\_Aulak](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@Sukhdeep\_Singh\_Aulak](https://forum.ansible.com/u/Sukhdeep_Singh_Aulak)\
**Post date:** [May 29, 2017, 4:51am UTC](https://forum.ansible.com/t/ansible-2-1-0-how-to-avoid-dashes-error-with-rendering-templates-like-my-cnf/22362/3 "2017-05-29T04:51:02Z")

</div>

> > I was also having the same error,

> > I was substituting the variable like this {{var\_property1-role}} ,

> > ansible doesn’t permit - in variable names so by changing

> > {{var\_property1-role}} to {{var\_property1\_role}} it worked fine.

Your post was of great help.

Thanks,  
Sukhdeep

---

<div class="post-metadata">

**Author:** ![Mischa\_ter\_Smitten](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@Mischa\_ter\_Smitten](https://forum.ansible.com/u/Mischa_ter_Smitten)\
**Post date:** [May 29, 2017, 12:05pm UTC](https://forum.ansible.com/t/ansible-2-1-0-how-to-avoid-dashes-error-with-rendering-templates-like-my-cnf/22362/4 "2017-05-29T12:05:22Z")

</div>

This is how we solved it:

[https://github.com/Oefenweb/ansible-percona-server](https://github.com/Oefenweb/ansible-percona-server)
