you need to learn ansible right now but hold up why what is it why is it so important I have some good reasons here's why when you hear the word ansible I want you to think Automation IT automation so that means systems cloud networking automating all the things ansible is one of the most popular tools out there for this function automation of IT stuff it's owned by a red hat super simple to use and guess what you don't need to know any programming it helps but you don't need to know my goal in this video
is to show you why adding ansible to your skill set will be crazy valuable so we'll cover hey what the junk is ansible how can I even use this what's it look like well then get our hands dirty and actually use ansible to do some things like automate some Linux stuff automate some networking stuff Cisco routers and switches and you will have an opportunity to play with this alright got your coffee let's do it [Music] was first tackled why why do you need ansible and we'll look at it from the perspective of like a Linux
system admin so I might have one server that I need to manage managing this server is super easy I'm happy it's great what I have to make a change for example maybe changing the DNS server that this Linux box uses it's easy like $0.04 OS all I do is update the etc resolve conf file update one file I'm golden but then what if I have a lot more servers to manage which is most likely the case if you're a Linux admin who's gonna pay you to manage one Linux server I don't know if you had
that gig you have a sweet gig but a lot of servers I'm not happy anymore because they don't have to log into each individual box and change this file it takes time and that's just one thing what I have what if I have to do so many other tasks to manage these boxes that's where ansible comes in whoo it's so cool check this out with ansible I'll put a server up that has ansible running on it and I'll make this my master my control station this is my command center where I make all the magic
happen where I make control and that saves scenario if I needed to change the DNS servers on all my servers I would just make the change here on my control station etc resolve I'll make it my change to that file and then my control station goes out and boot and makes the changes to all my servers so the big difference before I'm logging into every server individually making the change making the change huh redundant monotonous with ansible I make the change on my control station I say control station commander I will have to change all
my servers do it now oooh and it doesn't know ansible is not the only tool that does this but it is the easiest it is crazy easy to set up and I'll show you that here in a moment I'll walk you through it it'll take about five minutes for real ok what if you're not a Linux admin what if you're in network engineer guess what this works for you too if you have a bunch of routers to manage which we often do and so what can do the same thing for you so instead of updating
the configuration on each individual router logging and logging in and maybe updating the NTP peer or updating the banner tedious ho-hum monotonous ansible you do it in one place and you can update all your devices this makes me extra extra happy Joker smile happy re fun facts about ansible it's a pretty big deal because they are owned by Red Hat Red Hat is pretty much the enterprise standard for Linux everywhere you might be familiar with their free version cent OS so if your goal is to become a Linux system admin or really at this point
any admin for any area of IT learning automation tools like ansible it's key that's you have to right now ansible is also Python based which makes it extra cool and then this is probably the the greatest feature I love about ansible it is agentless what does that mean well typically when you're doing automation your automation tool will require you to install some sort of agent or client on the machine now in a lot of cases this is not possible especially for network engineers because we have Cisco routers running Cisco IOS and you can't install crap
on those so then we can't manage it with that system but with ansible it's agentless it simply connects over SSH and runs commands it's awesome we'll go into a few of the nuts and bolts of how that works here in a moment both ansible it's not just Linux it's not just Cisco IOS it's a sure AWS Windows machines you can manage your entire infrastructure did I mention it was free yes it is free and you can install it on pretty much any Linux distro even Mac OS now why is it free well it's it's open
source much like Sense OS is now of course there's a paid version just like cent OS has red hat as the paid Enterprise version ansible has what's called ansible Tower which is like this awesome thing and that gives you a few more bells and whistles but ansible it's by itself is amazing and as far as how it interacts with the machines and in routers and switches and controls it's definitely a push model it's very pushy you have pull and push models this one pushes configuration to devices pushes commands whereas other models might have it to
where the device will pull configurations from the control station or node ok enough fun facts time to get our hands dirty actually play with ansible and see why it's so awesome this is also your chance to just get started with it because that's sometimes the biggest hurdle to learning something NIT it's just getting started so I'm gonna walk you through it right now so whether using a virtual machine Mac OS cloud we're gonna walk through the setup and start playing with ansible right now now because I love the cloud I'll be setting up my lab
in Linode my cloud service provider and the sponsor of this video so if you want to set up your lab right now and follow along with me I've got a link below twenty dollar credit it'll pretty much get you through whatever you need to do right now so pretty much free and we'll have some fun so go to Linode comm forward slash network chuck so i'll navigate on over to lynda.com get my stuff logged in set up a free account if you don't already have one for this lab we'll set up three servers in the
cloud or on your own virtual machines and your in your home or wherever you are one will be the control station or the master the guy controlling everything and the two others will be the guys being controlled let's do this so if with the control node I got a special thing for you to save some time here in Linode on the dashboard if you look at the option right here is called stack scripts click on that I have one called network chuck ansible that will be publicly available to any of you to find that you'll
go to community scripts right here and you'll search network chuck now what is a stack script well it allows me to deploy a virtual machine with a script that I'll have it pre-configured the way I want it to so if I jump into this stack script and edit it you'll see I have a few commands that launch when it deploys so if you're deploying this on your own server or on your own laptop or wherever these are the commands that you would enter to make it work you would first use yum to update then you
would install the EPL release to be able to install ansible and then you'll install ansible so that's all I'm doing and that's pretty much all you have to do to get ansible installed all these commands right here so if you're following along here in Linode we'll just click on the dots here and say deploy new Linode we're basing this lab off sent to OS 7 and I'll choose my region here in Dallas I'll select the smallest node I can on the standard plan here and put in my password and click create and now we wait
actually you know while we're waiting for that one to set up let's go set up our other two right now for our other two virtual machines will click on create at the top here and click on the node choose our image it'll be sent to s7 region Dallas pick your region that's closest to you you'll have the best performance choose my size put in my password and click create and now I'll rinse and repeat do that once more for another virtual machine ok our three servers are created I'm going to jump into my aunt's will
server right here the one we created with our stack script now go over here and copy public IP address so I can connect to it and I'll use my favorite SSH clients solar putty and we'll get connected I'll log in as root which is the default user and then put on my password I set up at the time of creation as long as I put it in right there VCAL and the first thing I want to do is get to my ansible directory so I'll do CD or change directory and go to /etc forward slash
and Sybil bam if I do LS I can see what's inside there got three files the two we care about right now are ansible config and the host file ansible config is obviously where we have our ansible configuration settings the host file contains the list of things we're going to control so our two Linux servers are going to control and make it do what we want to those guys will be in this file but not yet we haven't added them yet and that host file is one of the key components in how ansible works it's
often referred to as the inventory file and much like any inventory it'll list all the things that you control all your Linux machines your routers if you're a network engineer your switches it lists the things that you're going to control so let's jump in there we use command VI that's one of the editors you can use Nano or whatever you want you're comfortable with but you can follow along with me right now I'm using the VI I know I normally use Nano I'm switching to them just a little bit so we'll do VI host to
edit this file if you're not logged in this route you may want to add sudo to the beginning of that command so you have super awesome administrative access but I'm route I don't need that right now all the stuff at the beginning is helpful tells you how it works we don't need that yet right now we'll go to the bottom of the file we'll hit hi and now we're editing so I Amin's insert we're gonna be editing in this file first we're going to add our Linux servers to the inventory so we'll create a group
called Linux servers the way we define a group is by doing brackets I'll just call it Linux closing bracket and just below are the hosts so I'll go back to Linode and grab the IP addresses of my other guys here this guy I'll grab is IP address and paste that right there and then my other one and paste that right there now that right there is pretty much all you have to do to have a host in the inventory to where ansible will try to reach out and control them when you do things but we
do want to define some things like hey what username and password are we going to use when we try to connect to these servers so let's go and do that now so just below that we can do another bracket and put Linux : so Linux is the group or referencing those serve up there and then we'll put bars and closing bracket and just flow that are the attributes or the options we're changing forward those servers when we connected them and for our Linux boxes it's just two options we're gonna change the first one will be
ansible underscore user equals the username now I'm going to be using the root account and this is just for labbing purposes I know I'm gonna get raked over the coals for people like that why are you using group you should never use root you shouldn't you should use a specified account just for ansible but hey we're just getting our feet wet we're we're trying this out so don't freak out about this as you move forward you'll do best practices don't worry and then we'll do the option and Sybil underscore password and this will be the
password you used to log in the one you created when you first created these Lynne Oates my password was here we go password one two three and that was it not too bad right now let's save the document now but if you were using a VI like I am you'll hit the escape button escape and then : WQ you'll notice I have the WQ at the bottom here basically means write and quit done so you just set up the inventory file for antipope and we're almost there reckon we're almost done we're just gonna do one
more thing we're gonna jump into the ansible configuration file so I'll do di and Sybil dot CFG and we're gonna change one option we're gonna scroll down until we find the option that's let me show you right here host key checking equals of false normally with ansible and production you'll have host key checking with SSH keys and everything it's very secure for us we're just labbing so we're going to disable this function so we avoid all the headaches of trying to set that up so we'll enable this option by going into edit mode by hitting
I and then we'll remove that hashtag there or pound sign have you want to refer to it and that essentially enables that configuration so host key checking equals false we're not gonna be host key checking and then we'll hit escape : WQ to save and we're pretty much ready to go I'm gonna clear my screen here so have a clean slate and now we're gonna do our first ansible command and it's simple we're just gonna paint our devices and see if they are here and okay so the command we are using is ansible and then
we'll specify what host we're gonna be dealing with you can specify one host by specifying the IP address or whatever I'm going to specify just Linux the group we created and it'll look at those two hosts we put in there then we'll do dash M which stands for module we'll cover what that means here in a moment but the module we'll be using is called ping and that's all we need I'm gonna hit enter and boom it worked we use the edible if you just did that you use ansible and you found out that hey
you actually gathered some facts ansible can gather facts about your machines about the things it controls and you can use those facts to do cool stuff and it also told us that hey the ping was successful you pinged it it punked on both things servers cool let's try something else let's try entering a regular Linux commands like we would on a on one machine but we can do it on two machines at one time so we'll do ansible well specify what host Rim using again so I'll say Linux that'll do - a this is kind
of like ad hoc commands just on-the-fly commands you want to use and I'll put those in quotes and I'll say it let's sum let's see what OS release these servers are on so I can cat those files and do etc /os release and let's see what happens BAM look at that and went to both servers enter those commands and it gave us the contents of the OS release file which in this case tells us it's sent OS Linux Evan we got information from two servers with one command super cool I love it let's do one
more thing what do you say we just reboot the machines ansible specify our host Linux - a will say reboot and of course the connection was reset because we rebooted them now let's make sure our machines are coming back up so we'll do ansible Linux - and ping see if they're up again yes ok they're up now what we're doing right now is just more of just ad hoc commands command line commands we can just do real quick but there's a more powerful way to use ansible and that's through the use of something called a
playbook a playbook is accomplishing the same thing that we just did on the command line we're making changes to multiple servers or devices to make our lives easier this is just a bit more organized now this is a term borrow from sports a playbook will contain place and these plays we each have their own tasks what the junk does that mean we'll talk about it right now now a playbook is actually a file we'll create it's a yamo file what is Gamal now we're not gonna go into too much detail about what Gamal is but
it's a data serialization language and don't let that scare you it's just a way we're gonna look at our data in a file the way we format it and use it so the computers can love it it actually stands for yam will ain't markup language and ansible loves it is what it uses so much so that does help me remember that it does use it I call it yan table anyways this will be a yam will file and these tasks are just things gonna do to our our Linux machines so for example what we just
did like rebooting our machine that might be one task that we perform on our Linux machines let's take a look at one right now actually now this right here is a yam will file notice we have three dashes up here that kind of didn't that's a mo file and the file type is dot yml or the extension is and then notice all this awesome spacing and the way it's organized it's very human readable that's the way it was designed it's designed for humans and computers we can coexist finally so this whole file right here is
a playbook and this right here rest set name and I love Nano that's the play and then underneath that play we have our tasks so in this play I have one task one thing I want to do I want to make sure that the text editor Nano is installed on all my servers that's what I named it and sure Nano is there and then I enlist the help of a module this right here is a module and actually I designed this with Ubu too because I use a PT this should be the yum module because
we'll be installing Nano on sent OS boxes and these modules are basically little small programs to help us define the state we want our service to be in so for example I want to use the yum module to make sure that Nano is on these machines and the state I want to be in as I wanted to have the latest version of Nano so when I run this playbook it's going to do that what do you say we do that right now so I'll copy the contents of my yam will file here I'll jump back
into my ansible control station and I'll create a new file I'll do feei I'll name it I love Nano yml this is my playbook I'll hit I to start editing this and I'll paste this in there now there's one thing I need to edit and notice this I said the host I want to mess with assistant OS that's not any host or anything we have in our system right now the host I want to mess with is the group of called Linux the one we defined in the hosts file so with that changed I'll hit
escape : WQ to save this bad boy and boom so now we're gonna run this now this this is what I love about ansible check this out ah just watch I don't want to spoil it for you to run a playbook and answer but will do the command or use the command ansible - playbook and we'll specify the file I love Nano dot yml that's it let's hit enter and go there's the play I love Nano there's the task gathering facts oh it's done okay so many cool things just happen the first thing you did
is it has a task called gathering facts you can disable this if you want but by default it's going to do this and just gather information about the system then I have the task I defined make sure Nano is there using the yum package manager is going to make sure yama is installed and the state should be the latest version available and then here's the play recap our play-by-play I love this so much it tells me the status of each node tells me things are good and it tells me that it changed on the host
meaning it installed Nano now can I show you something real cool real quick right now let's run that play again or that playbook again ready go watch what happens this is interesting this is what makes ansible really really cool look what happened when we ran this we have an okay status but then notice what was changed nothing zero changes ansible will not make a change at the state that we wanted in is already there that's called idempotency ID impotent it's it's a wart it's fancy word describe what we just saw it won't make a change
unless it has to make a change and that's killer in this world in this world of automation all the day was made sure that the our desired state my desired state that Nano would be on these machines and it verified that and made sure it was there if it wasn't it wouldn't make that change we saw that happen what do you say we reverse it what do you say we make a no not be there anymore I'll clear my screen we'll jump into that same file again I love nano dot yml using VI and i'll
hit i to start editing this and i'll change the state from latest to absent hey escape : WQ to get out of there now let's run that play again ansible playbook I love nano why am L we should have renamed our task and shirt antennas there no ensure you knows not there and it changed changed one it made sure nano wasn't there anymore okay that was the basics of ansible we went through something very very basic now I want you to go crazy and do some cool stuff but how do you go crazy well look
at the documentation and start playing around let me show you on an Sable's website they have all their modules documented so you can go in there and see what's available and you can go just absolutely crazy and have fun with it and of course you can look up examples online they have a ton of examples available for you oh and by the way all these will have links below including the example script I used now again I want you to go crazy I want you to do some cool things both in your own lab and
and maybe in your real production stuff I don't know don't get me in trouble but I want to see that comment below what you might end up doing or what you're already doing maybe you're already in ansible beast let us know how you're using it now this video did not cover every little thing about ansible that would take away too long the entire course is dedicated to learning ansible which by the way you should check out at CBT Nuggets calm links below for that the goal of this video was just to get you started to
get your feet wet to get over that first initial hurdle to try out an table to understand how it works and to realize that it's not so scary just to get started huge shout out to Ola node the sponsor of this video for giving us a really great easy way to try it out without even having even any hardware and anything at all and our own networks all you need is a real really a phone or iPad or computer BAM you can connect to it and work with it now what about Cisco devices what about
network devices you didn't show us that I will it's not in this video that's coming soon and if you're going for your CC & P encore we'll have that type of training on CBT Nuggets when it's available very very soon so link below for that it's coming don't worry well guys that's about it I hope you are able to move forward with ansible and add that to your skill set because automation and IC is here to stay both the networking and system admin stuff and cloud stuff it's the future and as you learn the basics
you'll eventually get to the point where automation will be your best friend because those repetitive tasks or managing large networks and large infrastructures becomes impossible without some sort or form of automation whoo that's about it for me I've been talking too much I'll catch you guys later [Music] [Applause] [Music] [Music]