Network Automation with Ansible – Part 3 – Generating Device Configuration with Jinja2 Templates
In this example I generated configuration for two switches, where I configured few VLANs and their interfaces and some DHCP Pools.
Jinja2 Template
I am using Jinja2 templating module to generate the configuration. I am using a tree structure of directory and files to pass the configuration commands and variable required to generate the configuration. I create a role named switch which I called in my playbook.
The directories are structured as

Playbook

Task/main.yml

Templates/switch. j2

Vars/main.yml

Sample Configuration Generated by Playbook, Template and Variables
I generated configuration for two switches, as I passed the variables for two switches.
Switch 1

Switch 2

Recent Comments