Options

How to Expect script to configure many Cisco routers at once

IsmaeljrpIsmaeljrp Member Posts: 480 ■■■□□□□□□□
Hello all,

Wanted to know if anyone knows of a good resource to learn all the ins and outs to using expect for making Cisco IOS configuration changes.

Scenario is I have an EEM configuration I'd like to enter on 50 routers or so. I have SSH access to each of them. How can I learn from the ground up to perfom this sort of task that I'd like to do.

I've seen a couple of links, but I really don't have any sort of scripting knowledge and I need a resource that will guide me through the process, or a way for me to ask any question.

How did any of you first start learning scripting?

Thanks,
Ismael

Comments

  • Options
    ccie14023ccie14023 Member Posts: 183
    Expect scripting is simple. If you know the CLI, you just send the config. I recommend using PExpect, which is Expect for Python. You could then create a simple script that reads the device list from a text file and iterates through it sending the same expect commands. If you want to learn the basics of Python there are a number of courses and books. I like "Automate the Boring Stuff with Python" by Sweigart. While not networking-specific, it's a great intro to Python.

    You might also look into Ansible. Ansible has some great CLI-templating capabilities that are far easier to work with than Expect scripts. While IOS devices will only support the CLI/SSH interface, it's still easier to use, in my opinion, than Expect. If you have access to Cisco dCloud, I wrote a lab on Ansible for NX-OS devices a while back, but it has a section on CLI templating at the end that applies just as well to IOS. (Just search for Ansible.)

    NETCONF is becoming a preferred method of configuring network devices. Again, you can use it with Python. You can use it with later versions of IOS-XE (16.3 and later), IOS-XR, and some NX-OS devices.

    A couple of resources: check out Cisco DevNet (http://developer.cisco.com) as well as my blog (in the signature.) I have just started a series on programmability but there is only one article. Stay tuned for more.
Sign In or Register to comment.