How do tags work?
IntermediateConceptPlaybooks, Plays, Tasks and Handlers
Answer
Tags label tasks, blocks, roles, plays or imports so you can run or skip a subset.
- ansible.builtin.package: { name: nginx }
tags: [packages, web]
- ansible.builtin.template: { src: a.j2, dest: /etc/a }
tags: config
ansible-playbook site.yml --tags config
ansible-playbook site.yml --skip-tags packages
ansible-playbook site.yml --list-tags
Tags on a block or role apply to everything inside it. Tags on include_tasks apply only to the include itself unless you use apply:, whereas import_tasks passes tags down.