get started with Ansible Network Automation (FREE cisco router lab)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I love ansible it's by far one of my favorite IT automation tools we can use it to manage it configure hundreds of devices from Windows servers to Linux servers and even routers and switches yeah routers and switches and that's what we're talking about today ansible Network automation what's going on guys welcome back to network Chuck ah it's so good in my last video we talked about ansible an IT automation tool that requires no programming knowledge at all anyone can pretty much walk into this and start using it without too much trouble and we talked about hey what is it what is it for how can we use it we went through an example in a lab you can check that out up here but we mainly focused on administering Linux servers but what about networking I mentioned Cisco routers and switches we can do this with ansible in fact it's one of the more popular tools for networking engineers just because you don't need to know Python you don't need to know any of that and that's what we're doing in this video I'm going to walk you through how to quickly set up ansible to control routers and switches and like most of my videos you'll have an opportunity to get your hands dirty your feet wet we're gonna actually do stuff on Cisco routers you don't need a lab in your own home there's stuff available for free thanks to Cisco dev net oh and by the way did you hear the new CCNP course is released on CBT Nuggets so if you're looking at getting your ccmp your cisco certified networking professional certification Enterprise training for the encore exam is now live check it out link below it is by far the best training you can find for ccmp hands down now I'm not just saying this because I had a hand in it cuz I am on there but we had a whole bunch of the trainer's Jeremy Chara keith Barker Geoff Kish Jacob Moran Knox hutchinson it's an all-star cast so what are you waiting for start working on that ccmp today you get a seven day free trial if you're not already a subscriber and getting back to ansible I also talk a lot more about other network automation tools in that course we cover puppet chef saltstack which you require to know about for the CCNP exam now so go check that out ok ansible cisco routers switches let's go first let's set up ansible right now I'm in ascent OS bark has nothing installed on it just yet I'll walk you through it from the ground up first let's do some updates I'll do yum update - why to make sure my repositories are all updated whoo mine took a bit but here we go next we'll make sure we have the EPL release installed because that's how we can get ansible will do yum install ETL - release - why and here we go again now we wait it's great though get some more coffee it's already done and now we can finally install ansible will do yum install ansible - why and now we're ready to rock well not just yet we need to change one thing in the ansible configuration file so we'll get to that location right now CD etc ansible CD means change directory we're gonna go to this directory now let's list our contents real quick and there's our ants more configuration file let's edit that sucker so I'll do VI as my text editor that's the editor I'm using and Sybil dot CFG I will scroll down probably about halfway through the document hard to tell though you're looking for something called host key checking angles false we want to disable this so we can play nicely with our cisco devices without having to upload SSH keys all that headache this is just a lab don't worry about it so I'm gonna hit I to edit remove that hashtag or pound symbol that I'll hit escape : WQ to jump out now to manage our Cisco routers and switches we need to add them to our inventory file or our host file for more information about what that is and how that works look back at the previous video or the course below for CBT Nuggets now this is the fun part we're gonna take advantage of free access to dev Nets cisco routers and switches they make it freely available in their sandboxes let me show you how to connect to those right now the website is developer cisco.com if you don't already have an account with dev net and go ahead and set up a free account if you're getting into Network automation this is almost required actually I'm gonna say it is required do it now now the links to the routers will be using our below a lot the first one real quick it's an always-on sandbox Cisco IOS XE and here's information we care about right about here hostname the port and the login information and then I'll pull up these second router while we're at it link below for that this is another version of that same router we'll scroll down to our information we care about BAM right here now why are we using two routers well you don't have to you can use one router but I want to demonstrate how we can manage configurations enter commands on multiple devices from one spot our control node in ansible now a quick note while these routers are available right now and what you're seeing here is live as of the time of this recording this could change I don't manage this website there might be a different version of this router it might be undergoing maintenance so just keep that in mind so let's get back to our ansible server here and I will jump into my hosts file VI host now we're gonna add some hosts right now I'm gonna go down to the bottom here where I can edit some things hit I to start editing and we'll add our routers I'm going to group my routers in a group called routers using opening and closing brackets and just underneath that I will enter my host information let's go grab those router number one is right here I'll copy that address paste that there and then let's grab the second one here is his host information and we'll put it just below now here will be the main difference between accessing Linux devices and network devices like cisco routers switches the difference being the variables we use to connect so let's start defining our variables for this entire group opening bracket I'll say your routers is the group I want to mess with I'll put a colon and put VARs and anything below this will be our variables for that group let's do login credentials first ansible underscore user and I'll see equals what was that username again it was developer developer and then just underneath that ansible underscore password equals and I'll just snag that right here and paste another variable will absolutely need is the connection type because we're not connecting to Linux boxes we're connecting to routers so it'll be ansible underscore connection equals and we'll put in Network underscore CLI we're dealing with the CLI command line interface of a network device the next variable will be ansible underscore network and score OS equals we have to help ansible understand what operating system we're connecting to it because it could be an Arista device it could be iOS XR so we have to let ansible know hey this is what we're dealing with this particular iOS will just be iOS and then one more variable because Cisco definite is using the SSH port of eight one eight one instead of the default 22 we need to make sure that ansible knows about that so we'll say ansible underscore port equals eight one eight one now that guy's is pretty much it for the host file we've got our routers listed and then we have the variables of how we can connect to these devices how ansible can interact with them I'm going to hit escape : WQ to write and quit and we're good I'm gonna clear my screen so we have something fresh here and let's see if this worked so we'll start with the ansible command we'll specify that we want to a mess with our routers that's the group we're gonna be interacting with I'll specify - m4 module and I'll use the ping module just to make sure things are up and running BAM okay we got a pong back so we know we can at least reach them via the ping module now let's run some ad hoc Cisco IOS commands so I'm gonna clear this out once more I'll start with a good old favorite show IP interface brief one of my favorite commands as well as Jeremy Charro's the command will be ant Sybil I'll specify the routers group put - m4 module in the module we're using is iOS underscore command now well do - a and then we'll specify which command we're using so then I'll do double quote commands equals Segal quote and then between these single quotes I'll be putting my command so it'll be show IP interface brief and you can abbreviate like you normally award on the command line the single quote to close that out double quote to close out the entire thing and let's see if this works if this does work we'll get the show IP interface brief output from both routers right here with just one command yes would you look at that how cool is that how powerful is that let me scroll up and make sure I got both host yes sir we did oh that's amazing powerful right imagine if you had a hundred devices just like that you got other information or if their IP interface information entering commands ad-hoc on ansible is cool it's fun but it's not the most powerful way we can use ansible let's try a playbook out now what's a playbook well if you want to find out check out my last video up there or check out the course I created on CBT Nuggets to find out more not just a test I have a playbook all ready to go here it is here is my llamo file which is my playbook and I've got one play in here this is my play named general config you can see that my host I'm applying it to my routers group so both the routers that we put into the hosts file in the ants pool posts inventory and we're doing two things the first task is we're adding a banner and in this playbook we're using the iOS banner module now what's a module well you can look back at my previous video where I talk about that but they're basically small programs to help us to apply configuration to our devices we're using the iOS banner module - what do you think we're doing we're we're modifying the banner on this device specifically we're modifying the login banner and we're changing it to Nicolas Cage is the Tiger King and we're making sure that the state of that banner is present and then we have another task in this play named ad loopback and we're adding a loopback interface we're using the iOS interface module and we're going to make sure that loopback 21 is present now I love Cisco Devon because we're actually going to make these changes to the router they allow us to do that so let's do it so to set this up I'm first gonna grab the contents of this file all that beautiful yeah Mille copy it get back to our terminal here our server and I'll create a new file I'll do V I will call this dev net dot yml aryama file I'll hit I just start editing this and I will paste this code in there I'll hit escape : WQ to write and quit it's ready to go let's test it out so to run a playbook and ansible the command will be ansible - playbook and then we just specify the file dev net dot yml let's do this let's go [Music] it worked check it out okay if we go back to the play-by-play here tasks add banner BAM changed BAM changed on both devices tasks add loopback BAM changed BAM changed play recap both are ok we changed two things two tasks two tasks were changed awesome what happens if you run it again let's run the play once more okay what happened nothing nothing happened and that's supposed to happen because what ansible did is it went to both these devices made sure that the banner was where it should be the state was present it was present no need to make that change I dumped it identity I can never say that stinking word it will forever trip me up same thing for loopback no change needed that sure beats copy and paste and config into a router because when you copy and paste it's gonna try and apply that config every time they won't check and see if it's there or not which could for some commands and some configurations really screw things up this is a lot cleaner a lot better now I feel like we need to log into one of these devices and make sure our changes actually happened so let's go check that out I'll log into the first one here on port 81 81 developer ah look there it is right they already the login banner Nicolas Cage's tiger King right now anyone who logs into this whoever-you-are will see this password let's do a show IP interface brief there's Lubeck 21 awesome now let's be good dev net citizens and remove the configuration that we added because we don't want this to confuse people or offend people or whatever so we will go and edit the file once more VI demo dot yml our playbook and we'll change the state from present forgot to hit I to edit will change the state from present to absent on both of these tasks escape : WQ now let's run that play once more [Music] and we're done and we can see that looking back at the play-by-play here ad banner changed I loop back now we're not adding or removing and we didn't change the name of these tasks but it did indeed remove we got our information let's go verify on that router will do show IP interface brief again lube back 21 is gone will do show run begin banner yeah and all we see is the message of the day which is welcome to the CSR 1000 be no login banner banner present perfect we cleaned up our mess now I do want you guys to go out there and mess with this putting your own fun banners maybe leave a message for the next person who logs in and does this again so cool what Devon it does network automation with ansible is super fun and it's something you can kind of do right now in your network without too much effort if you're able to follow this lad that we just did that's awesome the modules I showed you and the things I showed you we're very basic but they're hard ton of stuff you if you go to an Sable's website you get a full list of all the modules you have available there's a ton of examples out there and you can really truly start to automate your network and you don't have to go through the trouble of learning programming now you should learn Python you definitely need to you know how I feel about that but the point is you don't have to just start learning network automation now as you begin to take those steps and you want to go further into this yeah you should definitely learn the other tools and programming and everything else so check out CBT Nuggets com I've got links below for the courses I've created so again ccmp on core training was just released and it's awesome so go check that out then we got training for dev net CCNA programming everything we got you squared away guys that's about it I'm real quick if you don't mind I would love to just see what banner message you left and the comments if you did go through and do the lab that'd be kind of fun and let me know what you thought of this if you liked the video go ahead and like it you want to subscribe and hang out with me more hit that subscribe button that's all I got gonna finish up my coffee and catch you guys later [Music]
Info
Channel: NetworkChuck
Views: 111,880
Rating: 4.9592299 out of 5
Keywords: network automation, network programmability, ansible cisco, ansible tutorial, ansible for network engineers, ansible network automation tutorial, cisco automation, cisco network automation, network automation with ansible, ansible playbook tutorial, network automation cisco, network automation using ansible, ccnp, ccnp encor, ccnp enterprise, network automation for beginners, network automation ansible, cbt nuggets, cbt nuggets encor, cbt nuggets ccnp, ansible cisco ios
Id: OWKPxAgh9DU
Channel Id: undefined
Length: 15min 2sec (902 seconds)
Published: Fri May 08 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.