The --skip-tags
Ansible also provides a way to skip some tags in a playbook. If you have a long playbook with multiple tags, like 10, and you want to execute them all but one, then it would not be a good idea to pass nine tags to Ansible. The situation would be more difficult if you forgot to pass a tag and the ansible-playbook
command fails. To overcome such situations, Ansible provides a way to skip a couple of tags, instead of passing multiple tags. It's functioning is pretty straightforward, and can be triggered in the following way:
ansible-playbook playbooks/tags_example.yaml --skip-tags file_present
The output will be something like:
PLAY [localhost] *************************************************
TASK [setup] *****************************************************
ok: [localhost]
TASK [Ensure the file /tmp/ok does not exists] *******************
ok: [localhost]
PLAY RECAP *********************************...