From 54b98effdfe45d8b492b5c507fb5f52457ef8467 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 20 Mar 2012 19:55:24 -0400 Subject: [PATCH] Add demonstration of only_if capability --- examples/playbooks/playbook4.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/playbooks/playbook4.yml diff --git a/examples/playbooks/playbook4.yml b/examples/playbooks/playbook4.yml new file mode 100644 index 00000000000..7fb6673cb0d --- /dev/null +++ b/examples/playbooks/playbook4.yml @@ -0,0 +1,25 @@ +--- +# this is a demo of conditional executions using 'only_if', which can skip +# certain tasks on machines/platforms/etc where they do not apply. + +- hosts: all + user: root + + vars: + favcolor: "red" + ssn: 8675309 + +# facter and ohai variables can be used in only_if statements too +# ex: "$facter_operatingsystem == 'CentOS'", which bubble up automatically +# from the managed machines + + tasks: + + - name: "do this if my favcolor is blue" + action: shell /bin/false + only_if: "'$favcolor' == 'blue'" + + - name: "do this if my favcolor is red" + action: shell /bin/false + only_if: "'$favcolor' == 'red'" +