Removing Configuration in NetBox with Ansible

Removing Configuration for Individual Components

In the previous post, I demonstrated an example of a custom field. Inside the task, there was a state parameter. This parameter tells NetBox whether to create or delete it.
Leaving the state hard set inside the task means all custom tags (as in that example) will either be present, or absent in NetBox.

A neater way to do this is to add a state item to the list so that each element of the list can be added or removed. I will demonstrate this with a tenant.

Playbook

Organisation Vars

The vars file contains the tenant_list which is similar to the previous example of custom fields, but includes a state. This will be for each tenant.

Organisation Tasks

Inside this task the state parameter is present, and will use whatever is inside the tenant_list

Leave a Comment

Your email address will not be published. Required fields are marked *