If you have a big playbook and you just want to run one of those tasks, tags is your best choice. How to use it?
first, the most common form of use:Take the official example: Tasks:-yum:name={{Item}} state=installed with_items:-httpd-memcached Tags:- PACKAGES-TEMPLATE:SRC=TEMPLATES/SRC.J2 dest=/etc/foo.conf Tags:-configuration At this point if you want to run only one of these tasks, this Run when you specify tags can ansible-playbook example.yml--tags "configuration,packages" #run more Tagsansible-playbook example.yml-- Tags packages # only run a tags instead, you can also skip a taskansible-playbook example.yml--skip-tags Configurat Ion
two, tags and role combined useTags This property can also be applied to role, for example: roles:-{role:webserver, port:5000, Tags: [' Web ', ' foo ']}
third, tags and include the use of combined-Include:foo.yml Tags=web,foo This way, all the tasks defined in FOOL.YML are executed
Iv. Special tags built into the systemAlways, tagged, untagged and all are four systems built-in tags, have their own special meaning forever: After specifying this tag, task tasks will never be executed without considering whether to use the--skip-tags tag tagged: when-- tags are specified as it, then whenever a task with tags tag is executed,--skip-tags effect is reversed untagged: When--tags is specified for it, all tasks without tag tags will be executed,--the Skip-tags effect opposite all: This tag does not need to be specified, which is the ansible-playbook default execution. All tasks are executed
From for notes (Wiz)
3.2 Playbook Tags