summaryrefslogtreecommitdiffstats
path: root/docsite/rst/playbooks_variables.rst
diff options
context:
space:
mode:
authorMichael DeHaan <michael.dehaan@gmail.com>2014-02-15 20:01:07 +0100
committerMichael DeHaan <michael.dehaan@gmail.com>2014-02-15 20:01:07 +0100
commit47316074fe53ec25ee14177ee53fb62c3901912d (patch)
tree1504ff61a178c3bb04a38c3974dd9957b7b8e936 /docsite/rst/playbooks_variables.rst
parentFixing usage string in ansible-galaxy install for role files (diff)
downloadansible-47316074fe53ec25ee14177ee53fb62c3901912d.tar.xz
ansible-47316074fe53ec25ee14177ee53fb62c3901912d.zip
Document "|default" Jinja2 filter example.
Diffstat (limited to 'docsite/rst/playbooks_variables.rst')
-rw-r--r--docsite/rst/playbooks_variables.rst13
1 files changed, 13 insertions, 0 deletions
diff --git a/docsite/rst/playbooks_variables.rst b/docsite/rst/playbooks_variables.rst
index e8593a33a4..bca0d0f1b1 100644
--- a/docsite/rst/playbooks_variables.rst
+++ b/docsite/rst/playbooks_variables.rst
@@ -166,6 +166,19 @@ This allows an explicit check with this feature off::
The variable value will be used as is, but the template evaluation will raise an error if it is undefined.
+
+.. _defaulting_undefined_variables:
+
+Defaulting Undefined Variables
+------------------------------
+
+Jinja2 provides a useful 'defaults' filter, that is often a better approach to failing if a variable is not defined.
+
+ {{ some_variable | default(5) }}
+
+In the above example, if the variable 'some_variable' is not defined, the value used will be 5, rather than an error
+being raised.
+
.. _set_theory_filters:
Set Theory Filters