If you have a large playbook it may become useful to be able to run a specific part of the configuration without running the whole playbook. Both plays and tasks support a “tags:” attribute for this reason. You can ONLY filter tasks based on tags from the command line with –tags or –skip-tags. Adding “tags:” in any part of a play (including roles) adds those tags to the contained tasks.
Example:
tasks:
- yum: name={{ item }} state=installed
with_items:
- httpd
- memcached
tags:
- packages
TASK BY TRAINER:
Create a YAML file named “task.yml” for displaying message “I AM STUDYING” in one debug module and “I AM PLAYING” in another. Apply tag play and study for the respective module. Now specify the tag play to select the tasks having play in the tags section.