Add an example of Jinja2 casting.

This commit is contained in:
Michael DeHaan 2013-05-29 09:42:13 -04:00
parent 575967cee4
commit 2c433cb707
2 changed files with 7 additions and 1 deletions

View file

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

View file

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