ansible – Introduction to playbooks – Tags

Play contains several tasks, which can be tagged:

- name: Install applications
  hosts: all
  become: true
  tasks:
    - name: Install vim
      apt: name=vim state=present
      tags:
        - vim
    - name: Install screen 
      apt: name=screen state=present
      tags:
        - screen

Task with tag ‘vim’ will run when ‘vim’ is specified in tags. You can specify as many tags as you want. It is useful to use tags like ‘install’ or ‘config’. Then you can run playbook with specifying tags or skip-tags. For

ansible-playbook my_playbook.yml --tags "tag1,tag2"
ansible-playbook my_playbook.yml --tags "tag2"
ansible-playbook my_playbook.yml --skip-tags "tag1"

By default Ansible run all tags

if you want to reproduce, please indicate the source:
ansible – Introduction to playbooks – Tags - CodeDay