From the course: Ansible Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Using templates

Using templates

- [Instructor] Templates tend to be a major aspect of configuration management and automation tools like Ansible. So, it's no big surprise that Ansible is ready for templates and their usage, thanks to built in support for Jinja2. Jinja2 is a popular templating language for Python developers. So, let's take a look at a simple example here, a simple, but very fun example. So, in my home directory here, notice I have created a template named Jinja2.J2. So, it must have that .J2 extension, but you can name the template whatever you like. So, let's take a look at that. If we go in and look at the Jinja2 template, we are going to see that it is very simple. It says, a message from your node and then the variable of inventory underscore host name that it can take from the facts on the target system. And then it says today's message and it gives a web server message. This is a variable that we are going to actually define…

Contents