Posted on March 19, 2018, 5:15 pm by about-dev.com
The documentation from the Ansible website it's awsome, but when you don't have enough time to read it and you just want an quick answer this is not the best place to go because there is no search feature available.
That's why here I'll write about some of the stuffs I needed and had a long search for the solution.
To check the syntax of a playbook, use ansible-playbook with the --syntax-check flag. This will run the playbook file through the parser to ensure its included files, roles, etc. have no syntax problems.
>>ansible-playbook my_playbook.yml --syntax-check
>>ansible-playbook my_playbook.yml --list-hosts
(from the official Ansible website)
Child groups override parent groups and hosts always override their groups.
1. Group variables
# file: /etc/ansible/group_vars/boston
2. Host variables
# file: /etc/ansible/host_vars/xyz.boston.example.com
3. Role variables
# file: roles/x/defaults/main.yml
# if not overridden in inventory or as a parameter, this is the value that will be used
# file: roles/x/vars/main.yml
# this will absolutely be used in this role
Well, you can't :). I've discovered this the hard way.
If you define a variable in an inventory group_vars file, that variable will only be available to the tasks section from a playbook.
To use a variable in an include_role / import_role section from a playbook you have to use the vars_files in that playbook.