Skip to Main Content
Mastering Ansible
book

Mastering Ansible

by Jesse Keating
November 2015
Intermediate to advanced content levelIntermediate to advanced
236 pages
4h 42m
English
Packt Publishing
Content preview from Mastering Ansible

Chapter 3. Unlocking the Power of Jinja2 Templates

Templating is the lifeblood of Ansible. From configuration file content to variable substitution in tasks, to conditional statements and beyond, templating comes into play with nearly every Ansible facet. The templating engine of Ansible is Jinja2, a modern and designer-friendly templating language for Python. This chapter will cover a few advanced features of Jinja2 templating.

  • Control structures
  • Data manipulation
  • Comparisons

Control structures

In Jinja2, a control structure refers to things in a template that control the flow of the engine parsing the template. These structures include, but are not limited to, conditionals, loops, and macros. Within Jinja2 (assuming the defaults are in use), a control ...

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.
Start your free trial

You might also like

Automating with Ansible

Automating with Ansible

Sander van Vugt

Publisher Resources

ISBN: 9781784395483Supplemental Content