Hi,
I've previously created a module for Ansible which reads information from a device and lets you use them as facts in other modules. When I wrote that module I didn't think that I would use Ansible to also change configuration through SNMP. Partly because SNMP is well SNMP, but mainly because of the fact that what you can actually change through SNMP is limited.
However after reading the discussions here and on Twitter about the need to support "legacy" devices using modern tools I figured that I'd take a stab at it anyway.
After looking at different things that you can change using SNMP I settled on creating and removing VLANs and that became the first module, cisco_snmp_vlan.py.
My goal was to create a module which was idempotent that could create, rename and remove VLANs from a switch. I used an 8-port 2960 switch but my guess is that anything running Cisco IOS would work.
If you want to check it out you can find it at Github:
(The readme file has en example of what it could look like when you run a playbook)
Currently the module isn't very user friendly as there's no installer, also I'm using a wrapper module I created for pysnmp called
nelsnmp which also doesn't have an installer. But if you want to try it and don't know what to do just let me know and I'll try to help you. My plan is to have nelsnmp available through pip.
At this state the module only supports SNMPv2, but I have the code for SNMPv3 in my other module. I just haven't implemented SNMPv3 in nelsnmp yet. Also in the current version nelsnmp doesn't have any error checking so it won't stop if the snmp community string is incorrect.
This module only changes the running config and my next module will probably be one which saves the config. I've written a Python script for that but haven't converted it to an Ansible module yet. What I was thinking was that when you create a playbook you could register the results from modules such as cisco_snmp_vlan and if a change status is registered Ansible runs the module which saves the config. That way the playbook would remain idempotent.
Anyway I hope someone finds this useful, if you have any comments or suggestions please let me know.
Best regards
Patrick
Ps. And now the hard part, figuring out which open source license I should attach to the project..