Adding a section to the FAQ about array notation. (#30782)

* Adding a section to the FAQ about array notation.

* Fixing spelling of jinja and Celsius.

* Adding an example that uses dots.
pull/28107/merge
Matt Bruzek 7 years ago committed by Brian Coca
parent 86d8a4ff50
commit aaaf88908d

@ -305,6 +305,20 @@ You shouldn't put plaintext passwords in your playbook or host_vars; instead, us
.. _commercial_support:
Ansible supports dot notation and array notation for variables. Which notation should I use?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The dot notation comes from Jinja and works fine for variables without special
characters. If your variable contains dots (.), colons (:), or dashes (-) it is
safer to use the array notation for variables.
.. code-block:: jinja
item[0]['checksum:md5']
item['section']['2.1']
item['region']['Mid-Atlantic']
It is {{ temperature['Celsius']['-3'] }} outside.
Can I get training on Ansible?
++++++++++++++++++++++++++++++
@ -407,6 +421,3 @@ Please see the section below for a link to IRC and the Google Group, where you c
Have a question? Stop by the google group!
`irc.freenode.net <http://irc.freenode.net>`_
#ansible IRC chat channel

Loading…
Cancel
Save