If you have a large playbook, it becomes useful to be able to run only a specific part of it rather than running everything in the playbook. Ansible supports a tag attribute for this reason.
When you apply tags on things, then you can control whether they are executed by adding command-line options.
When you execute a playbook, you can filter tasks based on the tags in two ways, such as:
- tasks:
- - yum:
- name: "{{ item }}"
- state: present
- loop:
- - httpd
- - memcached
- tags:
- - packages
-
- - template:
- src: templates/src.j2
- dest: /etc/foo.conf
- tags:
- - configuration