Recently I have been working more with network automation and using Arista Validated Designs (AVD), Ansible and Netbox. A somewhat common request that I encounter is being able to pull the Ansible inventory from Netbox. There is an Ansible plugin for this called “nb_inventory” to do this exact function. However, through my testing I have found a more preferable approach. I opt for executing an Ansible playbook with a GraphQL query, which then processes the output through a Jinja template to create the inventory file. This technique offers a significant advantage: in the event of a Netbox server outage or accessibility issues, the inventory remains usable for running Ansible playbooks until access to Netbox is restored. In the upcoming example, I’ll introduce additional logic tailored for environments using AVD. However, the approach can be easily adapted for scenarios involving only Ansible and Netbox. This article presumes the presence of functional Netbox and AVD environments which is out of scope for this post.