Ansible Cisco IOS_Config Module: Part 1 Configuring Cisco Routers with simple commands

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello welcome to this video on the iOS config module with an answer ball now the iOS config module is one of my probably most used modules within ansible it allows you to apply configurations line by line via a config file or even via ginger to template though we're going to cover all those options with a very simple test deployment to a single router so let's get started so I'm in my ansible and I am running currently you sorry ansible 2.5 and I've got a very simple playbook opened up and as you can see all I've got so far other three dashes though I'm going to start by building this playbook out very simply bit by bit and you can follow along though first of all we start with the three dashes for the Yama file and then I need to say which hosts I'm going to apply this playbook to and for this instance it's going to be my CSR Reuters and if you look in my host file this is ansible that's I just call it Reuters good back there so I've got one in my Reuters file and this is Ruta one on 192 168 1 o 6.50 let's just jump into that box just to make sure I can get to it mine - not one six eight Domino's 6.50 so this is a csr Rooter see the address I was connecting to here 1 & 2 1 6 8 1 o 6.50 so I proved I can connect to it from ansible directly the good start just a good verification and we're going to start to build out the playbook so I'm going to connect to Reuters here I will just need to put gather facts else wouldn't want to gather any facts for these devices and just for now I'm going to use connection local okay so the tasks that I want to configure are starting off very simply so just to show you how the iOS config module works we're going to change the hostname of root of one I'm going to use the iOS config module and the way to do this is to say the first way is to just do lines and in here you then just apply the Cisco configuration file you want to do so I'm going to say hostname are changed that's it so this very simple playbook will connect to all the devices in my Reuters group in the host file which is currently one router it's then going to run the play book called change host name using the iOS config module and it's going to run the command host name our dash changed and that's it so we jump back to ansible and run that playbook but its ansible that playbook I asked config yeah Moe that's what I've called it and I'm gonna use my username you okay so we've got a problem here I could not match the supplied host pattern ignoring the rooters so if you look here just to double check I've got that right so that's Reuters and in here Reuters and in my host file its caps though that's just shows you that everything in here is case-sensitive so we need to save that with the caps so let's just jump back to ansible and run that again so you can see it's first task change hostname and that's completed and the orange indicates something has changed and the green down here indicates that everything is good so if we SSH back into the routine a should see the name the hostname of that device has changed and as you can see the name there is odd has changed so it has changed though this very simple playbook here let's run that one command so I'm just going to put it back do you root of one run the PlayBook again you this is just going to change the hostname back to our one again that changes now just to show you the item potency of ansible in that means that it will only make a change when there is a change to be made so if that command is already there the Rooter host name is already Rooter 1 this run again shouldn't need to make any changes it's green so that ran no changes were made you can see changed equals zero and that's completed and we just ssh back into that root just to verify it's no r1 okay so that is about as simple you can get we've got a very simple playbook we're using the iOS config and we're running this single line hostname r1 now these are all global commands so hostname r1 SNMP communities NTP servers etc so I can do ntp that's 92168 1.1 to make sure that this command is actually the right command to run so just to verify that we jump into the router itself I've got this insecure CI to you here but this is the router that I was in so we can just make sure that NTP server see that that wasn't the command so in TP space so okay there we go so the the correct syntax to define an NTP server on the Cisco root of his NTP space server and then the IP address we can figure that manually on the router and you can see that now exists there as an entry so let's remove that get ansible to deploy that so so run include SNM ntp so if that doesn't exist at the moment so we can now make this command that's what it should be we'll leave the hostname in that's for giggles and that's there so we run this playbook again and this is now going to configure the the ntp server and again a change was made if we jump back onto the roots are here everyone including ntp in the command you can see was put in so ansible is configuring these global settings so that's very simple to understand you put a dash in the command and that's brilliant now another way to do things are commands thou actually underneath different levels so like an interface configuration command so let's have a look on the router and look at the configuration on gigabit ethernet 1 now i'm gonna get ansible to put a description on this interface and the way that works within ansible is that you put the command that you want to go at the bottom so I want the command to be description you config' by ansible now this has this syntax called parents interface Gigabit Ethernet one so what it's doing is saying I want to apply this configuration underneath this parent though we've put that in gonna run the PlayBook again you and that's completed with a change so if we jump back to the root or again faced gi1 we've now got description config by ansible or any configuration that you need to apply with ansible that is underneath a different has to be underneath this parents though we can do another example so if I said under OSPF Reuter ID on line two dot one sixty eight dot one dot one and this has to be Arents Rooter OSPF for 100 I will just make sure show IP I've got currently rout of SPF 100 and if we check what that command looks like at the moment so I've got Rooter OSPF 100 and I haven't defined a Rooter ID though I've done the same again this is the command I want to apply and it needs to go underneath this Rooter OSPF for 100 they will just run this again but once you know what you need to do it's very easy to use the iOS config module to do it that changes and check the config on the router again SPF 100 you can see now we have a Rooter ID configured now this is great for simple commands single commands if you wanted to ensure a certain command existed on all your devices but a hundred devices in your host file you put one command here and you're guaranteed that single command will be defined on every device now I'm gonna stop the video here in the next video we're going to be going through using ansible and the iOS config module and using a template or a source configuration so I look forward to seeing you in the next video thank you for watching and see you soon
Info
Channel: Roger Perkin
Views: 27,092
Rating: 4.8483415 out of 5
Keywords: Network Automation, Ansible for Network Engineers, Ansible Tutorial, Roger Perkin, IOS-Config Module, Cisco, Ansible Cisco, network programmability, ios_config, ios_config ansible
Id: 7RBs7JFj4xI
Channel Id: undefined
Length: 13min 17sec (797 seconds)
Published: Mon Apr 23 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.