Development and testing
In order to deliver an Ansible project it’s necessary to test the code and configuration. The tags provide the administrators with a tool to test single tasks’ files and single tasks. For example, to test single tasks at single remote host test_01, create a playbook
shell> cat lp.yml
- hosts: test_01
become: true
roles:
- vbotka.linux_postinstall
Customize configuration in host_vars/test_01/lp-*.yml
and check the syntax
shell> ansible-playbook lp.yml --syntax-check
Then dry-run the selected task and see what will be changed. Replace <tag> with valid tag or with a comma-separated list of tags
shell> ansible-playbook lp.yml -t <tag> --check --diff
When all seems to be ready run the command. Run the command twice and make sure the playbook and the configuration is idempotent
shell> ansible-playbook lp.yml -t <tag>
See also
Periodically run playbooks from cron by ansible-runner ansible-cron-audit.bash
ansible-runner wrapper arwrapper.bash