Summary
Jinja2 is a powerful language that is used extensively by Ansible. Not only is it used to generate file content, it is also used to make portions of a playbook dynamic. Mastering Jinja2 is vital to creating and maintaining elegant and efficient playbooks and roles.
In this chapter, we learned how to build simple templates with Jinja2 and render them from an Ansible playbook. We learned how to make effective use of control structures, to manipulate data, and even perform comparisons and tests on variables to both control the flow of Ansible playbooks (keeping the code lightweight and efficient) and create and manipulate data without the need for duplicate definitions, or excessive numbers of variables.
In the next chapter, we will ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access