From 2c433cb707b462e955fdd59854f5ac117bc94ed2 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Wed, 29 May 2013 09:42:13 -0400 Subject: [PATCH] Add an example of Jinja2 casting. --- docsite/latest/rst/playbooks.rst | 2 +- docsite/latest/rst/playbooks2.rst | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docsite/latest/rst/playbooks.rst b/docsite/latest/rst/playbooks.rst index 451950ad30e..80c49569f8f 100644 --- a/docsite/latest/rst/playbooks.rst +++ b/docsite/latest/rst/playbooks.rst @@ -176,7 +176,7 @@ And in /srv/templates/motd.j2:: You are logged into {{ facter_hostname }} -But we're getting ahead of ourselves, as that just showed a task in a playbook. Let's talk about tasks. +But we're getting ahead of ourselves, as that just showed a task in a playbook ahead of schedule. Let's talk about tasks. Tasks list ++++++++++ diff --git a/docsite/latest/rst/playbooks2.rst b/docsite/latest/rst/playbooks2.rst index fbb73abedee..5309e43eef9 100644 --- a/docsite/latest/rst/playbooks2.rst +++ b/docsite/latest/rst/playbooks2.rst @@ -281,6 +281,12 @@ As a reminder, to see what derived variables are available, you can do:: ansible hostname.example.com -m setup +Tip: Sometimes you'll get back a variable that's a string and you'll want to do a comparison on it. You can do this like so: + + tasks: + - shell: echo "only on Red Hat 6, derivatives, and later" + when: ansible_os_family == "RedHat" and ansible_lsb.major_version|int >= 6 + Variables defined in the playbooks or inventory can also be used. If a required variable has not been set, you can skip or fail using Jinja2's