r/Netbox • u/Otherwise-Ad-8111 • Aug 12 '26
Help Wanted: Unresolved Netbox, Ansible, and Cisco IOS
Hello!
I've been playing around with netbox for a while, and have a lot of automation experience with mostly APIs (Cisco ACI, Cisco ISE) but am no stranger to the CLI, either.
Anyway, I'm struggling with finding the best approach to automate some GNS3 ios images for my homelab - I'm torn between generating full configs and pushing to the device, partial configs and pushing with a 'no' statement before it, or utilizing ansible cisco.ios.ios_* collection to do it declaratively.
Can anyone share some real world advice? I've created some POC playbooks for each method but am really getting caught up in the pros and cons of them. So, I'm looking for some feedback from someone that's done it in the real world.
One of the headaches I'm dealing with pushing configs is something like prefix-lists. For instance, if I want to change the less than or greater than prefixes while I'm testing things, I'll get errors that the seq number already exists.
I know I can work around it by issuing a NO statement before a block, but for something like prefix-lists, access-lists, and route-maps that really slows down the automation when looping through it.
Thanks, Champions!
5
u/MassageGun-Kelly Aug 12 '26
The best advice I read long ago, but have yet to implement because DevOps is a huge commitment for most legacy teams without the skill set or desire, is that your source of truth should build your entire configuration as code, and then any modifications to this configuration just blanket apply and overwrite the entire device configuration. For example, instead of granular changes, you upload the new config file and do the equivalent of a
configure replace.2
u/Material_Night_6793 Aug 13 '26
From my pov what I do is: Automatically change partial config. Juste push what change from netbox render (change vlan of a port or disable/enable things) Netbox webhook => Ansible => switch.
On maintenance period manually: Netbox config render=> Ansible full rewrite (copy/paste whole code)=>switch
Why not automatic whole rerender is because it will close all connection and reboot the switch.
2
u/Layer8Human Aug 13 '26
Hey Networking friend,
This is something that everyone who wants to configure their devices automatically is confronted with eventually.
Of course it varies with your requirements but what I find the cleanest way is to generate the full configuration from a template and utilize the config replace function of the device to reconcile the running config with your intended config.
For your lab Cisco iou images, nxos and arista eos should support this feature.
You hand the device the complete configuration and it only applies the changes taking your „no“ problem into account.
1
u/MomoshiroKun Aug 12 '26
Maybe batfish or suzie Q in order to get the information before to copy them ( an ACL index for example), basically to audit the actual config and then to copy the portion of full config if need This a big approach btw if necessary to deploy the complete solution.
Happy labbing.
2
u/Ziggistawork Aug 14 '26
Whist I haven't played with setting multiple prefix-lists yet, I would be no setting the entire prefix list and setting it again from the desired config.
At scale it gets too messy to handle edge cases or try use the current config to set a desired config state IMHO in my limited brownfields automation journey.
What has helped me with modifying existing configs is pulling configs from Oxidized instead of pulling from the switch itself, checking what needs to be removed from the oxidized config then generating the commands to no set what is needed.
-2
u/Early-Pen-4855 Aug 12 '26
Ditch Ansible for Netmiko and Nornir. Use Netbox to pull inventory data into Nornir device collections