Growing Beyond Ansible host_vars and group_vars

One of the attendees of my Building Network Automation Solutions online course quickly realized a limitation of Ansible (by far the most popular network automation tool): it stores all the information in random text files. Here’s what he wrote:

I’ve been playing around with Ansible a lot, and I figure that keeping random YAML files lying around to store information about routers and switches is not very uh, scalable. What’s everyone’s favorite way to store all the things?

He’s definitely right (and we spent a whole session in the network automation course discussing that).

However, you can get pretty far by using host- and group variable files. For example, Mark Prior (an automation expert with numerous deployments under his belt) still uses them in his projects as he explained in his Network Infrastructure as Code presentation.

Once you think you should do better, start by consolidating things into a proper data model which is kept in a single file (instead of having random thingies lying around in host_vars and group_vars files). You’ll find more details in the Data Models part of our automation course (where you’ll also find a section on data stores).

The only way to grow beyond data models in text files is by using a database (in which case you’ll have to develop your own UI), or an IPAM/CMDB system that matches your needs. Obviously, you’ll pay for that scalability with increased complexity. You have to export data from one of those systems before running Ansible playbooks, or write dynamic inventory scripts or your own inventory plugin. Anyway, that’s the only way to grow if you insist on using Ansible. Maybe you should check out Nornir?

Assuming you did your homework and figured out what data model you need to describe your services or network infrastructure, you could start looking around for the best tool to store that data model in. Netbox is probably one of the best ones because it was designed by a cool networking engineer with massive experience… and he even described his solution in our automation course.

Latest blog posts in Single Source of Truth (SSoT) in Network Automation series

Add comment