Add an example of Jinja2 casting.

pull/2982/merge
Michael DeHaan 11 years ago
parent 575967cee4
commit 2c433cb707

@ -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
++++++++++

@ -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

Loading…
Cancel
Save