Summary
Jinja2 is a powerful language that is extensively used by Ansible. Not only is it used to generate file content, but it is also used to make portions of a playbook dynamic. Mastering Jinja2 is vital for 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. Additionally, we learned how to make effective use of control structures, how to manipulate data, and even how to perform comparisons and tests on variables to both control the flow of Ansible playbooks (by 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 explore Ansible's capability in more depth to define what constitutes a change or failure for tasks within a play.