--- # tags allow us to run all of a playbook or part of it. # # assume: ansible-playbook tags.yml --tags foo # # try this with: # --tags foo # --tags bar # --tags extra # # the value of a 'tags:' element can be a string or list # of tag names. Variables are not usable in tag names. - name: example play one hosts: all remote_user: root # any tags applied to the play are shorthand to applying # the tag to all tasks in it. Here, each task is given # the tag extra tags: - extra tasks: # this task will run if you don't specify any tags, # if you specify 'foo' or if you specify 'extra' - name: hi tags: ['foo'] shell: echo "first task ran" - name: example play two hosts: all remote_user: root tasks: - name: hi tags: - bar shell: echo "second task ran" - include: tasks/base.yml tags: - base