August 2015
Intermediate to advanced
168 pages
3h 32m
English
Ansible uses Jinja2 as a template engine. Hence, it would be useful for us to understand Jinja2 control structures in addition to the ones supported by Ansible tasks. Jinja2's syntax encloses the control structures inside the {% %} blocks. For conditional control, Jinja2 uses the familiar if statements, which have the following syntax:
{% if condition %}
do_some_thing
{% elif condition2 %}
do_another_thing
{% else %}
do_something_else
{% endif %}The template that we created earlier to generate the my.cnf file assumes that all the variables referred in it are defined somewhere. There is a chance that this is not always the case, which could result in errors while running ...
Read now
Unlock full access