March 2019
Intermediate to advanced
412 pages
9h 49m
English
A less common but confusing gotcha comes from a quirk of the Jinja2 syntax. Complex variables within Ansible playbooks and templates can be referenced in two ways. The first style is to reference the base element by the name, followed by a bracket, and the subelement within quotes inside the brackets. This is the standard subscript syntax. For example, to access the herp subelement of the derp variable, we will use the following:
{{ derp['herp'] }}
The second style is a convenience method that Jinja2 provides, which is to use a period to separate the elements. This is called dot notation, and is as follows:
{{ derp.herp }}
There is a subtle difference in how these styles work, and it has to do with ...
Read now
Unlock full access