FreeKB - Ansible Jinja2 templating
Ansible - Jinja2 templating

Ansible can use the Jinja templating system for variables. If you are not familiar with Jinja, check out Getting Started with Jinja.

In Jinja2, an expression has this structure. This could be a variable, an array, et cetera.

{{ ... }}

 

For example, let's say a variable named "foo" contains a value of "bar".

vars:
  foo: bar

 

This is how you would use the "foo" variable to return "bar".

{{ foo }}

 

Here is an example of using a Jinja2 variable in the debug module.

- name: "output the 'foo' variable"
  debug:
    msg: "The foo variable contains a value of {{ foo }}"

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 9cc08 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |