Creating network configuration templates

As we are now familiar with the basics of Ansible, let us look at an example in which we generate configs ready to be deployed for some routers. To start with, we need to understand roles in Ansible. Roles are used to create a file structure for Ansible playbooks. Based upon roles, we can group similar data. Sharing the roles with others would mean we share the entire defined file structure for a common set of content. A typical role file structure would contain the main folder and the content folder, and under the content folder, we would have templates, vars, and tasks folders.

In our case, the hierarchy is as follows:

  • Main directory
    • -Roles
      • -Routers
        • -Templates
        • -Vars
        • -Tasks

Under each of ...

Get Practical Network Automation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.