969c3feb13
Also be smart and don't run a play at all if no tasks in the play match any of the tags specified. This includes not running the setup actions!
29 lines
575 B
YAML
29 lines
575 B
YAML
---
|
|
# 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
|
|
#
|
|
# note the include syntax to tag all tasks included below
|
|
# it is a short hand over adding "tag:" to each task entry
|
|
|
|
- name: example play one
|
|
hosts: all
|
|
user: root
|
|
tasks:
|
|
- name: hi
|
|
tags: foo
|
|
action: shell echo "first task ran"
|
|
|
|
- name: example play two
|
|
hosts: all
|
|
user: root
|
|
tasks:
|
|
- name: hi
|
|
tags: bar
|
|
action: shell echo "second task ran"
|
|
- include: tasks/base.yml tags=base
|
|
|