Wednesday, March 20, 2019

Network Reconfiguration Scripting Challenge

My organization will be refreshing wifi with a different vendor, and the switchport configs will be slightly different. My challenge is to automate the reconfiguration of all wifi switchports across about 100 Cisco switch stacks. There is no consistency whatsoever as to what port ranges are used for wifi, so a simple 'int ran gi1/0/1-12' isn't going to get the job done. However, the wifi switchports all have exactly the same description ("Xirrus" — the rip and replace makes sense now, right?) and our existing WAPs use LLDP, so I have two easy ways to identify which ports I need to reconfigure.

I use simple Ansible playbooks and I have some very, VERY rudimentary skills in Python. What's the best way to create a process that identifies the appropriate switchports and applies a given config to each?

I'm currently thinking that this is a Python problem, and that I need to write a script which does the following:

  1. Run "show int desc | inc Xirrus" or "show lldp neigh | inc B,W,R"
  2. Somehow pull all the Gi#/#/# strings from the command output and put them into a list
  3. Execute a for-loop to apply the given config to each item in the list

And then obviously put that all inside a big for-loop to execute on each switch. The middle step there is the stumbling block right now.

Or is there some magical, easier solution?



No comments:

Post a Comment