I've got a problem with Ansible 2.2 in Ubuntu.
My playbook contains the following:
---
- hosts: all
become: yes
roles:
- mysql
I've used the MySQL role from here https://galaxy.ansible.com/geerlingguy/ but renamed all to MySQL
locally. In the defaults folder of the playbook is a file which contains the parameter:
mysql_datadir: /var/lib/mysql
With that, Ansible is working fine. But now I want a specific configuration per host as explained here: http://docs.ansible.com/ansible/playbooks_best_practices.html
So I created the file inventories/host_vars/test.yml
, removed the one in the defaults folder of the task and updated the playbook to the following:
---
- hosts: all
become: yes
roles:
- mysql
tasks:
- name: include vars
include_vars: inventories/host_vars/test.yml
Now Ansible won't accept that; it says that the variable is not set:
fatal: []: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'mysql_datadir' is undefined\n\nThe error appears to have been in '/home/michael/Ansible/Playbooks/roles/mysql/tasks/setup-Debian.yml': line 24, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Delete innodb log files created by apt package after initial install.\n ^ here\n"}
Passing the argument via command line works without problems. How can I fix that?