Is there a way to check playbook syntax and variables?
I'm trying to dry-run(--check) but for some reasons it works really slow. It looks like it tries to perform an action instead of just check the syntax
I want to omit en errors like this:
..."msg": "AnsibleUndefinedVariable: ERROR! 'application_name' is undefined"}
You may want to verify your playbooks to catch syntax errors and other problems before you run them. The ansible-playbook command offers several options for verification, including --check , --diff , --list-hosts , --list-tasks , and --syntax-check .
To force a task to run in check mode, even when the playbook is called without --check , set check_mode: yes . To force a task to run in normal mode and make changes to the system, even when the playbook is called with --check , set check_mode: no .
The easiest way to do a dry run in Ansible is to use the check mode . This mode works like the --syntax-check command, but on a playbook level.
This is expected behaviour according to the documentation:
When ansible-playbook is executed with --check it will not make any changes on remote systems. Instead, any module instrumented to support ‘check mode’ (which contains most of the primary core modules, but it is not required that all modules do this) will report what changes they would have made rather than making them. Other modules that do not support check mode will also take no action, but just will not report what changes they might have made.
http://docs.ansible.com/ansible/playbooks_checkmode.html
If you would like to check the YAML syntax you can use syntax-check.
ansible-playbook rds_prod.yml --syntax-check playbook: rds_prod.yml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With