- jinja2 is python based templating language.
- we use it mostly when we want to keep some configuration files or any file dynamic.
- When configuration changes are mostly dynamic you don't know the value before running the playbook then we use this template.
- We just keep the variable of Ansible-playbook in this jinja template which can get replaced while running the playbook.
- We can use loops and conditional statement to transform the data according to our requirement..
- It comes with .j2 extension.
- It is very easy to use.
Tags:
{# #} When you want to comment something to describe the tasks.
{% %} In control statement such as if-else, for loops we use this Tag.
{{ }} This tag will replace the variable name with the actual value.
[pankaj@host]$ ansible-playbook ansible-playbook-example.yaml
References:
https://ansible-tips-and-tricks.readthedocs.io/en/latest/ansible/commands/
0 Comments