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 explore Ansible's capability in more depth to define what constitutes a change or failure for tasks within a play.