What are Ansible tags?
How are Ansible tags used?
Ansible tags are keywords used to mark and control the execution of specific tasks, roles, or plays within a playbook. They allow you to selectively run or skip certain parts of a playbook, which is useful for debugging, testing, or selectively applying changes...!
Thanks
Ansible tags are like labels you assign to individual actions (tasks) within your playbooks. These labels act as runtime selectors, enabling you to instruct Ansible to execute or skip specific tasks when you run the playbook. Although the usual workflow involves running an entire playbook from beginning to end, the ability to target and execute particular tasks on demand offers significant flexibility and efficiency.
--- - hosts: localhost gather_facts: False tasks: - name: Hello tag example debug: msg: "Hello!" tags: - hello - name: No tag example debug: msg: "How are you?" - name: Goodbye tag example debug: msg: "Goodbye!" tags: - goodbye
ansible-playbook example.yml --tags "<tag-name>" (the task with this tag will be executed only )
ansible-playbook example.yml --skip-tags "<tag-name>" ( the task with this tag will be skipped while rest of the play will be executed ).
apart from this, ansible has always and never tag which helps you to execute a task from the playbook always and never respectively as the name suggests.
https://docs.ansible.com/ansible/2.9/user_guide/playbooks_tags.html
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.