What you'll learn
- Explain the RHCSA prerequisite for RHCE eligibility and the exam objectives this course covers
- Install Red Hat Enterprise Linux on a virtual machine and register it to receive software updates
- Configure a dedicated Ansible user and passwordless SSH key authentication from the control node to managed nodes
- Describe the roles of the Ansible control node, inventory, variables, and YAML playbooks in automating managed devices
- Compare host variables and group variables for applying unique or shared values across inventory devices
- Configure the ansible.cfg file and build an INI or YAML inventory with host groups to verify connectivity
Free 48-minute video lesson with a full transcript and knowledge checks. No account needed to watch.
Introduction
Let's discuss what we need to know about the RHCE certification exam!
VMWare and Red Hat Enterprise Linux
In this video we discuss how to download and configure the VMWare virtualisation software that we will use to build our lab environment. Once that is done, we'll sign up for a free account with Red Hat and download a valid copy of Red Hat Enterprise Linux.
Knowledge Check
You must pay for a Red Hat annual license in order to use RHEL.
Setting Up the Lab Environment
In this video we walk through the creation of 3 different virtual machines - all running Red Hat Enterprise Linux. One machine, the "control node", will be configured to use Ansible. This machine, in turn, will be used to automate and manage the other 2 virtual machines in the network. Let's walk through the setup process!
Knowledge Check
Which of the following commands were used to register the RHEL machine (choose all that apply)?
Select all that apply.
SSH Configuration
Ansible is an "agentless" automation solution. This means that the devices being managed by Ansible do not have to install any special software locally. However, in order to be managed by Ansible these devices will require SSH connectivity. In order to facilitate a smooth automated workflow we want to configure our devices to authenticate without the need to enter in passwords every time a connection is established. As such, in this video we walk through how to generate a public-private cryptographic key-pair to enable SSH key-based authentication.
Knowledge Check
Which command was used to transfer the SSH public key over to the managed nodes?
Ansible Basics
In this video we discuss some of the basic concepts behind Ansible. How does Ansible operate? What are the main components of the Ansible architecture? Let's dig in and find out!
Knowledge Check
Match the following components of the Ansible architecture
This interactive assessment is available in the full learning experience.
Configuring Ansible
In this video we walk through some very basic configurations to get Ansible up and running. We discuss the values specified in the Ansible configuration file. Next we create an Ansible inventory using the INI format to specify the two RHEL devices we plan to manage.
Knowledge Check
Which of the following configuration files will Ansible treat with the highest priority?
Validation
In this section, we aim to validate that we understand all the vital information discussed within this skill. Give it and go and test your knowledge!
Knowledge Check
Before sitting the RHCE exam, all candidates are required to hold a valid and current RHCSA certification.
Knowledge Check
The RHCE exam focuses on performing RHCSA-level tasks in an automated fashion using Ansible.
Knowledge Check
Which of the following describes how Ansible operates (choose all that apply)?
Select all that apply.
Knowledge Check
The Ansible inventory can be specified using which of the following formats (choose all that apply)?
Select all that apply.
Knowledge Check
Ansible playbooks are written using which file format?
Knowledge Check
Which command was used to modify the file used to define superuser access?
Knowledge Check
When modifying the "sudoers" file, which of the following configurations was used to allow the "ansible" user to elevate privileges without having to enter a password?
Knowledge Check
Is this your first time using Ansible?
This interactive assessment is available in the full learning experience.
View Transcript
Introduction
0:00Hey friends and welcome to the Red Hat Certified Engineer course here on CBT N uggets. So what I want to do to begin is to first discuss the general exam objectives pretty much what should we actually be tackling within this particular course and discuss the format of the course as well as who this course actually should be for. So with that said let's dive in and look at some of the details. Now the very first thing to state about the RHC examination is that if you want to be eligible and achieve this particular certification you must first have a valid and current RHCSA certification.
0:38So if you've not quite yet got your Red Hat Certified System Admin certification then fear not we do actually have the RHCSA examination course here on CBT Nuggets also. So once you've got that box ticked and you are a valid RHCSA Certified Engineer you are therefore eligible to set this particular course. Now important to understand the RHCE certification is a performance based exam. There are no written questions, only written tasks that you have to perform on a virtual machine.
1:11So the question is what type of tasks should you be expected to know. Now really traditionally in older iterations of this particular exam you could expect to see very advanced Linux admin topics. However in the new modern version of the examination the actual tasks which you are asked to perform are really not that advanced. It is very much the type of content that you would expect to see in the RHCSA certification. The difference here in the RHCE exam is that we are performing all of these types of tasks that we would do in this particular exam.
1:44But now we are being asked to do those tasks via automation using Red Hat Ans ible Engine. So whilst the RHCSA examination might ask you to configure new users on the system the RHCE exam will ask you to do the same type of thing this time using Ansible. Now if we go into the actual objectives here we get a little bit more detail about what should actually be studying. Here are the actual tasks that we are expected to understand. Notice these are very very similar to what we see in RHCSA. Configuring local storage, managing users, basic security, configuring file systems, that type of thing.
2:20But doing it with this understanding of automation. So we are going to be looking at all of these components of Ansible. Things like the inventory, how we can use modules, what variables are, how to use loops and conditional statements, that type of thing. We are going to learn how we can use rows within Ansible and leverage something known as Ansible Galaxy. And how we can set up what is known as the Ansible control node which is basically the device on the system that is running Ansible that is performing the Ansible automation . And we are going to learn how we can perform those tasks on these managed nodes. So very important we will get to see how we can actually use SSH keys for passwordless authentication, how we can elevate a privileges on these managed devices that type of thing. We will talk about something known as Ansible Navigator, we will talk about creating plays and playbooks.
3:04As well as a whole bunch of other details including how we can also templatise configuration files and protect secret data using a utility known as Ansible Vault. So we are going to have a lot of fun within this course. However the very first thing that we are going to have to do is to begin building out our lab environment and that begins by getting a copy of Red Hat Enterprise Linux.
VMWare and Red Hat Enterprise Linux
0:00So friends, one of the very first things that we have to do is we have to get a hold of Red Hat Enterprise Linux. This is the Linux distribution that we're going to be using in order to install Ansible. So with that said, let's just dive in. Now the first thing to say with respect to Red Hat Enterprise Linux is that you can actually run this and say for example a cloud environment, or if you so wish you could run this as a bare metal installation, pretty much meaning that you could just install it on your regular hardware, your laptop, your PC, whatever it may be, and run it just as a regular OS but that is not the way that I'm going to recommend that you begin your lab process.
0:38Instead, I'm going to suggest that you make use of virtual machines. Now perhaps you happen to have some type of software on your computer already, maybe you're using something like say VirtualBox. And if you are, feel free to use that virtualization solution. In my case though, my personal favorite and the software that I'm going to recommend you use is VMware. So in this particular video, we're going to go through the installation of getting VMware available to us. And then we're going to see how we can actually get a working copy of Red Hat Enterprise Linux in order to perform our labbing.
1:11So let's do with the first part of the problem and talk about VMware. Now the first thing to say is if you happen to be using a Windows machine as your host computer, what you should actually search for is VMware Workstation Player. And if we click on this link right here, notice this is the platform for running virtual machines on a Windows or Linux PC. So once again, even if your host machine happens to be a Linux machine and you want to run virtualization software on that machine, then just like with Windows, you would download VMware Workstation Player.
1:41Now notice it says you can buy a commercial license. We don't have to worry about that right here if we just scroll on down. We can actually try the player for free if we so wish. This is for non-commercial purposes for your own labbing, that type of thing. So if you're on Windows, click this link. If you happen to have a Linux machine as your host machine, you be click this one instead. Now in my case, I happen to be using a Mac. So we have to download VMware Fusion. So in this case here, we click this link. Notice it says here that VMware Fusion 13 allows support for Intel or Apple Silicon, meaning that if you happen to have an older MacBook with an Intel processor, you can use this solution.
2:19Or if you happen to have one of these M1 or M2 MacBooks, the new ones, you can all also use VMware Fusion 13. So in this case here, what I'm going to do, given that I have an M1 MacBook, I 'm going to click Register for a Personal Use License. Now it takes us to this page here, VMware Fusion Personal Use License. If you already have a VMware account, you can just select "I have an account." If you haven't got that account set up, you first want to create that account very, very important. So all you would do is click this link here.
2:49And what you're going to have to do is to provide some information about yourself, such as your email address. Now just be aware, you can't just put in some dummy email, make sure it is a real email, because you're going to have to click a verification link within that email in order to activate that account. So really make sure you can access that email when it pops in. Then if you scroll on down, you can give your name, your address, job title, that type of thing. Fill out the capture and agree to the terms. And once you have done that, you will get an email in your inbox and you can click the link to verify your account. Going back to this particular page, you can now select "I have an account."
3:22So let's click this link here. And all you would do would be to enter that email registered with this account and pop in your subsequent password. So I will just log into mine right now. Perfect. Now I've logged in if I just scroll on down. Now it takes me to my license information. Now over here, this is where the license key happens to be now, because I don't want to share my license with absolutely everyone that's watching this video. I have just obscured this. But once you have registered, you will have your own license key. So all you want to do is to copy that particular key. Once you have done that, we can now go and click "Manually Download."
3:55And then simply save the download. And when the download completes, just double click. Run through all the prompts in the installation wizard and when you are asked, simply supply and copy in your own personal license key. And once you've done that, you will be presented with an interface quite like this. There on the left hand side, I've got a whole bunch of virtual machines that I have created prior to this course. If you have a brand new installation, you will not expect to see these down the left hand side, don't worry about it. We're going to create our own Red Hat Enterprise Linux from scratch using this VMware software.
4:27So now we have access to our VMware virtualization solution. What we now want to do is to get our hands on a Red Hat Enterprise Linux image in order to create that real machine. So with that said, let's do it. So in order to get this ISO image, we need to create a Red Hat account. The first place I'm going to go to is to developers.retat. So let's click this link right here. Now in the top right, if I just click log in, what I can do is pass in my Red Hat account details right here. However, if you do not already have that Red Hat account, you would just go down to the bottom here and register for a Red Hat account.
5:01So let's just click this link here and you will have to provide some basic login information such as your login ID. So choose a username, give it a password, fill in the personal information, your first name, last name, email that type of thing. Then accept the terms and choose create my accounts. Now once you actually have a valid Red Hat account, what I'm going to do is search for Red Hat Enterprise Linux downloads. So if you click this link right here. Now this part is important if you happen to have a regular Windows machine or an older MacBook, basically if you happen to have an Intel processor, you can just select download rail at no cost right here.
5:39In my case though, because I'm using an M1 MacBook, similarly if you happen to be using an M2 MacBook, the newer one, anything Apple Silicon, you're going to have to get a very specific version of rail and that is the ARM version, the ARM architecture. As such, we are going to select more ways to try. So depending on what you have at home, choose whatever one is appropriate. In my case here, I'm going to click this link. So if I just scroll on down right here, the one I want to get is Red Hat Enterprise Linux ISO for servers and workstations.
6:10So notice in my case here, I can choose the ARM 64 button, in fact you can also choose the regular Intel version if you so want from this page here too. Now when I click this particular link, if you aren't already logged in, it's going to prompt me to login. This is why it is very important that we have that Red Hat account created. So click the page, once you've logged in, you'll be presented with a download. In my case here, I will just choose save and now I'm going to be downloading Red Hat Enterprise Linux with the ARM architecture. So now whilst that download, we will soon have access to Red Hat Enterprise Linux as well as our virtualization solution in VMware, what we now want to do is to begin setting up our lab environments.
Setting Up the Lab Environment
0:00So friends, now that we have access to Red Hat Enterprise Linux, as well as our virtualization software, what we want to do is to create three different virtual machines. Now in the case here, we're going to have one particular virtual machine which is going to act as our Ansible Control node. Pretty much this is going to be the machine that is responsible for managing all other machines. Don't worry about the terminology too much, we'll talk about an in an upcoming video. So this is going to be the machine that is responsible for doing all the automation.
0:30And quite simply Ansible is just software that we're going to install on a Red Hat Enterprise Linux machine. So once again, the first VM is going to be a Rail based and quite honestly, the next two machines, machines two and three are also going to be Rail based. Now just a point of note with respect to using Ansible, the machines that Ans ible manage do not all have to be Red Hat Enterprise Linux. They could for example be Ubuntu, they could be Rocky Linux, whatever it may be . The reason why we're using two more additions of Rail has quite simply on the examination, you can expect to be managing and dealing with Rail systems.
1:06So it just makes sense to have an entire lab environment all working with Rail. So like I say, we'll have three different Rail machines, the fourth Rail machine we will install Ansible. In this case here, I'm going to recommend that you install a graphical user interface based Rail machine. This makes things easier to operate. Now with respect to the machines that are going to be managed by Ansible, if you happen to be struggling for resources, then you could get away with just using a minimal install. This pretty much means that you're just going to get a basic command line interface, no nice graphics, no web browser, that type of thing.
1:39But honestly, it's going to be more than enough to practice working with Ans ible. Now in my case, the two other additional machines right here, I am also going to install them with a graphical user interface. The reason why I'm doing that is because I have plenty of resources on my personal computer and for the purposes of recording, visually for you at home watching, it just makes it nice that if you happen to be looking at a graphical user interface. But like I say, if you're struggling for resources by all means you can do that minimal install for those two. So let's first walk through the creation of our first machine here, which is going to have Ansible installed on it.
2:13So I will pull up my VMware. Depending if you happen to have a Windows based installation, the interface might look a little bit different, but ultimately the configurations are going to be the same. The first thing we want to do is to create a new virtual machine. So I will go to file here and then choose new. In the case here, I'm going to install from a disk or image. This is going to be the real image that we just downloaded in the previous video. Let's click continue. So in my case here, I will just choose the real image and then select continue. So right now we have some default settings as it transpires by default, I'm using 2Gig of RAM and 20Gig of hardware space that is going to be plenty fine for me.
2:51So if you so wish you can just choose finish. But if for example, if you happen to have more resource to despair, no harm in choosing customized settings, let's just give the device a name, which is called this rail control click save and then you can go into process as a memory. If you so wish you can crank the memory up to whatever you need. Allocate more processes that type of thing if you so wish but the default should suffice. So with that now done, I will just click play and then I'm just going to arrow up to actually install red hat enterprise Linux and just hit enter. Now just give it some time to boot up and load.
3:22Now the very first time we're going to have to do is to choose your own language. In my case here, I'm going to be selecting English and English United Kingdom, choose whatever is appropriate for you and then choose continue. Now the first thing I'm going to do is to choose the installation destination. Let's click this link here and then I'm going to select this 20 gig hard drive that I have cut out for this particular virtual machine. Once I have that highlighted, I'm going to click again to make sure I see a tick. There we go. And in the case here, I'm not going to worry about data encryption or storage configuration.
3:53I will leave that automatic and leave the others unchecked. Let me now just select done. So with that now done, it says automatic partition and selected. That's a good sign. The next one I'm going to go to is network and host name. So all I want to do is to make sure this ethernet connection is toggled on right now. It's on. If it was off, it would be gray. In this case here, I want to make sure it is blue. Once that is done, I will now select done. Then I'm going to go to software selection. In the case here, this is going to be my Ansible control mode. I'm going to recommend you select server with GUI to get that graphical user interface.
4:27With respect to the other installations, when you're making machine two and three, if you so wish, feel free to choose minimal install. I would select the graphical installation. So let's choose done. The next thing I'm going to do is to go down to root passwords. Let me just give a very bad password or password one, which is absolutely not secure. But nevertheless, just for lab and environments, let's just keep it simple. So again, I will say password one and then I will select done. Okay. So now we see the root password is set and then I will go down to user creation . Let's click this here and let's just give this a name.
4:59I'll just call this nugget user and I will also make this user and administrative. So we can use the pseudo commands and again, just to keep things all simple, I will just choose the password or password one. Like I say, never ever do this in a real live environment. That's just because it's a lab and any virtual machine. In the case here, though, I will click done. It gives me the warning. Let's click done again to accept it. And now what I want to do is I want to choose begin installation. So just give this some time to begin installing all the necessary information. And most it does that. I will just temporarily pause the video.
5:29Perfect. Everything has now installed. What I will now select is reboot system and give it a moment to just reboots. Okay. So now we are presented with a login page. Let's click on our nugget user and I'll type in password one. Now the first thing it's going to say is do we want to take the tour in this case here. I'm just going to select no thanks. Now notice up the very top here, it says please register your system to receive software updates. If you want to download external packages, easiest way to simply get this done is to well register the system. So let's do that.
6:00So the first thing I will do here is just click X and I'm going to go to my terminal. Now you can probably tell that the text is very, very small. What I want to do is to customize things. So I'll go to this option here and then go down to preferences. I will then go to unnamed and then I'll click custom fonts. And then all I'm going to do is to bump up the font size. Then I will just choose colors. I will uncheck this box and then I can select my own color theme. So in this case here, I will just make the background black and I'll make the text. Let's say a red color since it is red at now.
6:32This is certainly not necessary, but just to make things a little bit easier to follow. I'm just going to rename the actual computer itself. So I will just say siddle hostname cTL set hyphen hostname and I will just call the device red box. Now I'll type in my admin password, which is going to be password one. Now right now the name has not changed. But if I happen to close the terminal, go back up to activities, open up a brand new one. Notice the name has now changed now with respect to registration. We're only going to concern ourselves with registering the device that is going to be running Ansible, which in my case here is this particular machine.
7:09So what I'm going to do is say sudo subscription manager and then the word register. Now I'll have to type in my admin password, which is password one. And now what I'm going to have to do is to provide my red hat enterprise Linux details. Remember we created our accounts. So all I will do is type in my email associated with my red hat account, which in my case here is IPV zero. If I enter, what I'm now going to have to do is to provide the password that is associated with my red hat account. So this is not the password one that I created on this machine. It's the actual password that we created when we signed up with red hat.
7:42So I'll type it in and to enter give it a moment to register. And now it says the system has been registered. What I now want to do is to say sudo subscription manager, attach and to enter and we can see the registration has been successful. Perfect. So if I just say sudo dnf repo list, we now have access to these particular repositories. And now what I want to do is I want to install Ansible core. So let me just clear the screen and I will now say it's sudo dnf install and let me just access out to clear the screen. And I will just say Ansible hyphen core.
8:13If I hit enter, give it a moment to pull in the information, I will just say why and to enter and there we go. So with that now done, what I should be able to do is to say Ansible dash dash version. And we actually see the Ansible version information right here. Now you'll notice for the purposes of recording, just to make things a little bit easier on the eye, I changed the color of the prompt. But that is certainly not anything you have to worry about yourself. What I'm now going to do is simply shut down the machine right now. So if I say shut down dash H now and to enter, we have now created our control machine.
8:46Let's now quickly spin up a device that is going to be managed by Ansible. So let's go to fail and new once again, follow the same procedure, install image and just walk through the same type of process. Choose a disk. If you want to use a minimal install, you can reduce these resources greatly. But for me, I'm just going to leave them at the defaults. And I will just call this rail blue box. The name itself doesn't actually matter, but just choose anything you so wish. So I'll pull this up, choose install and I'm just going to follow the same type of options and continue.
9:16So like I said with software selection, feel free to choose minimal install if you so wish. Same again when it comes to the root passwords. I'm just going to keep things really simple, choosing password one and I will select done and done again for the user creation. I'm again going to select nugget user and again, keeping it simple, just use password one again, making this user the administrator. Once that's done, begin installation. So once again, reboot the system. So on this particular box, we do not have to worry about registering the system nor do we have to worry about actually installing Ansible.
9:49And all I did on this particular device was change the host name to blue box to make it easier to follow. Now what I'm going to do is stop the video and in the meantime, I will create one more managed device in the exact same way that I created the blue box. The only difference being is that it's going to have a different host name known as yellow box. From now, I will stop the video, continue the task and I will see you in the very next video where we talk about SSH authentication.
SSH Configuration
0:00So friends, in this particular video, what we're going to do is set up SSH keys so that we can authenticate into our managed devices, that is going to be the blue box and yellow box from the Ansible control node without having to enter any passwords. And now it 's not just that. What we want to do is on each of our machines, that is the Ansible control node , as well as the managed devices, we want to create a user called Ansible. And this is going to be a dedicated user account for Ansible to operate. Now it's not absolutely essential that you create a Ansible user, but realistically for managing things such as security, having this dedicated account really does keep things a lot cleaner. So the very first thing is we will create that Ansible account, we'll say it's sudo user ads dash M, and I will just say Ans ible. And then I will say it's sudo pass wd and then specify the account I want to create the password for, which is Ansible. If I hit enter, now what I'm going to do is specify the password that I want to use for the Ansible account. Now just to keep things really, really simple, I will alter as call the password Ansible. Okay, once again, not exactly best practices, we can see we're getting a warning that this is a bad password, but nevertheless, let's just stick with the word Ansible again. Okay, so we now have created this Ansible user, let's do the
1:19same thing on the other two machines. So I'm here on the blue box, let me just say sudo user ad dash m Ansible, type in the password of password one for super user privileges. And now I will create the password for the Ansible user so sudo pass wd Ansible. Again, the password is simply going to be the word Ansible. And let's just confirm that and to enter. Now let's go to the yellow box. Once again, let's just create the Ansible user and we'll give the Ansible user password of Ansible and once again just confirm that password. Now what I also want to do is to give the Ans ible user account access to the sudo command without having to type a password. Once again, we will handle this a little bit different in a real environment, but for simplicity and for the purposes of the examination, we are absolutely fine to do so. So let's just say sudo vice sudo.
2:07And if we scroll all the way down just below this part here that says route all equals all, all I'm going to do here is say Ansible, which is the name of the user accounts, and then say all equals a name within parentheses all. And then I would just say no pass wd colon and then the word all. So if I just write and quit, let's do the same thing on blue box and yellow box. So once again, sudo vice sudo and just type in the exact same information again. Perfect. So colon writing quits. And lastly, on the yellow box machine, we just sudo vice sudo and again, just type in the exact same content.
2:43Once again, saving with a wq. So if on my main machine, I just type ipadder, we can see the ip address happens to be 192168160.133. And we want to be able to reach the blue box and yellow box. So let's see what their IP addresses are. So once again, we just do ipadder on the blue box, we can see this is 192168160.134. And over on the yellow box, we are on 160.135. What I actually want to do now is to create some SSH keys for login. Now what I'm going to do is I'm going to create these keys as the answerable user sources, sudo su hyphen answerable and I enter, we can now see the username has changed to answerable right here. And what I'm going to do is say SSH hyp hen key gen and enter. That's going to tell me the file where it's going to save automatically.
3:33That is fine. So I'll just hit enter. It's going to ask me for a passphrase. Now in the real world, once again, we absolutely want to be adding a passphrase but for simplicity for the examination. Absolutely find you to leave this blank. So let's just hit enter and enter again. And now we have automatically generated our SSH key pair, the public key as well as the private key. Now what we want to be able to do is to share the public key with the blue box and the yellow box. This is going to allow us to authenticate in as the answerable user to those devices without having to type in the password answerable, which is going to be much, much better for us when working an in automated fashion. So all I will say is SSH hyphen copy ID. And then I will say answerable at 192.168.168.134, which is the first machine the blue box machine. If I enter, I will say yes.
4:26And I will type in the password of answerable the very first time I'm doing this authentication. Perfect. We have now added the key to that particular machine for the blue box. And similarly, if I arrow up and do 135, I answer, I now say yes to add the fingerprint. I type in answerable again. I now log into the yellow box and transfer my public key over to that particular device. So now moving forward whilst I'm on the red box itself, the answerable control node, if I now just want to authenticate into that particular device, say for example , the blue box, I can just say SSH, answerable, and then type in the IP address of 192.168.134.
5:05And to enter, notice we authenticate straight away without having to type in the passphrase. I'm now on the blue box. See that right there? And again, if I exit out, arrow up, type 135, I enter, automatically, we just slide directly into the yellow box without having to type the password. That is exactly what we want. So now we have the basic setup of our lab environments. We have our three virtual machines. We have now created a dedicated answerable user for all three devices and have now configured passwordless SSH key authentication. With that now done , we are ready to begin talking about answerable.
Ansible Basics
0:00So friends, let's talk a little bit about what Ansible actually is. Well quite simply, at its most basic level, Ansible is an automation tool that has been developed by Red Hat. So think about the tasks that you would do as a Linux administrator. Perhaps you're managing 1000 servers and you want to go in and maybe modify the DNS settings, as opposed to having to log in to each device one by one by one. To manually make those configuration changes yourself, utilising a tool such as Ansible, you can have that change be automated all at once and have the system updated in the blink of an eye.
0:36Now the way Ansible operates, it uses something known as a push model. Let me just describe what that looks like. So imagine over here we had a Red Hat based system. This could just be a virtual machine and on that system you happen to install Ansible Looker. Here is going to be the machine that is going to manage all of the devices in the network. To say for example you had a whole ton of different servers that you're managing. One could be an Ubuntu machine, one could have it be Red Hat enterprise Linux as well, one could be Fedora, one could be Kali Linux, it doesn't actually matter.
1:06The point is if you happen to be a system administrator responsible for managing all these devices, having Ansible installed on one particular control mode will allow you to connect all of these devices at the same time and push out those updates. Now the reason why we refer to Ansible as using a push model to make its configuration changes is if you happen to have let's maybe say two machines over here that you're managing, the cool thing is that these devices here that happen to be managed by Ansible, this device here, these machines do not have to install any particular software you don't have to install Ansible here or here.
1:42You simply install Ansible on the device that is going to be performing the automation in that Ansible enabled device simply pushes out those changes to these different nodes. So all happens from here and is pushed outward towards the network, that is what we're referring to. Now as we move through this particular course there's going to be a strong emphasis on something known as YAML, pretty much this is a file format that is designed to be very human readable but it allows us to actually utilise programmatic logic, just like you can do so with say for example Python code except this time the code that we're writing quote unquote really doesn't look like code, it is very very easy on the eyes, really really easy for system administrators to look at and understand.
2:24Now with respect to Ansible the actual architecture can be broken down into four core components. The first component is the configuration file, typically this is going to be called Ansible.cfg and using this particular file you can specify global system settings, we'll get to see what this looks like in the very next video. Crucially though within the configuration file we can also specify where abouts we can find the next component of the Ansible architecture and that is the Ansible inventory.
2:55Now the inventory basically tells Ansible what devices should be managed. Now in our lab environment we have created two particular machines that are going to be managed by Ansible so in order to let Ansible know about this we would specify information about those devices in the Ansible inventory so that could include things like the IP addresses of those particular devices or maybe their host names, that's how Ansible knows which devices it should actually be connecting to. Now as you progress throughout this course we're going to learn that the inventory can be really really valuable, it can use things such as groups as well as by the way groups within groups otherwise known as nested groups but for now as our introduction we don't have to worry about that quite just yet, just understand that as a part of the Ansible inventory and it's one of the reasons why Ansible is so powerful.
3:41Now the third component I want to talk to you about, this is something known as variables, this is a very well known concept within programming because when we happen to be automating things whilst a lot of the information might be very repetitive we can just effectively have the automation system push out the same changes to all devices, we understand that with respect to particular configurations on particular systems we have a requirement for some configurations to be unique, basically they're not going to be the same, they're actually going to be varied depending on the device we are connecting to.
4:14So say for example we're managing two devices right here, let's just call it device one and device two and let's just say this is our Ansible machine right here that can connect to these devices. Now some things may be very common perhaps we're going to push out the same change to both devices, maybe that'd be safe for example some DNS server information perhaps they're both going to be updated to use the server 8.8.8.8 that is absolutely fine, however maybe at the same time whilst we're giving both devices the same DNS we want to update their IP address information and the IP addresses on these devices actually have to be unique we can't give the same IP address to both devices, as you're going to see the way we solve for this particular problem is via the use of these variables now we can have things known as host variables which are variable values unique to a particular host in the inventory but we can also have group variables these could be values unique to a particular group of devices perhaps we happen to have four devices in the UK and all of those UK devices have to get a particular NTP server that is different from all of the servers in the United States we can specify those UK unique values as a group variable and target all of the UK devices in the inventory.
5:25Once again we'll get to see this in more detail later on as we progress now the fourth and final component here this is known as the playbook and really this is how we tie everything together it is inside the Ansible playbook which happens to be written in YAML where we actually tell Ansible what it is we want it to do this is where we write our instructions you know like go and configure a DNS server go and update the NTP configurations go and create a whole bunch of new users on all of these devices so now we have a rough idea about what Ansible is and what it can do what we want to now do is to begin setting up our system so that we can then slowly begin automating tasks across our managed devices now in this particular skill we're not going to be looking at playbooks quite just yet or the concept of variable values but in the very next video we're going to be talking about the creation of that Ansible configuration file as well as the construction of our Ansible inventory once we have done that we will run Ansible against those devices to test for basic connectivity and that will have our lab up and running and put us in a really good place to continue on this journey throughout this course when we will begin using these playbooks to automate a whole bunch of really cool and useful tasks so with that said let's get going .
Configuring Ansible
0:00Okay friends, so let's get hands on with Ansible. So the first component that we are going to talk about is that Ansible configuration file. So if you happen to search for Ansible configuration file, you can click this top link right here. And notice it says here that certain settings in Ansible are adjusted with this particular file Ansible.cfg. Now one thing to note, Ansible is going to seek to find this particular configuration file in a variety of different places, each with a greater priority than the other.
0:33Now it says here the pass where the configuration file is searched and listed as in the reference documentation. If we just click this link here, this here is effectively the locations and priority levels in which Ansible will look for this particular configuration file. So the first thing is that if you happen to set your own environment variable and point it to a particular location, this is the first and primary location where Ansible is going to seek to find this particular file. Now if you have not set this environment variable, the next place it's going to be checked is for a file called Ansible.cfg in the current directory. So whatever you happen to be running Ansible from, it's going to say hey, is there a file in the same directory right here called Ansible.cfg and if it is, then it's going to look to use the configuration specified within that particular file. Now if you do not have the Ansible configuration file within the current directory where Ansible happens to be running, the next location is going to be in the user's home directory.
1:33So we can see this via the tilde character, which we know is their home directory. Now if you've got a key now, you'll notice that we happen to have a dot before the word Ansible. Denoting that in this case here, this would actually be a hidden file. Now suppose you have not created any of these environment variables or the files in these particular directories , the general system way configuration file is going to be found in the exit directory and then into the Ansible folder and the file itself will simply be just called Ansible.cfg. That is the order of operation. Now in my case here, the practice that I tend to follow is just simply putting an Ansible.cfg file within the directory in which I am working. You can specify anything you so wish, but that is the practice that I am going to be following. If you don't use that particular practice, just at least understand the order of operations and where Ansible is going to look to find that particular config. Now if we search Ansible inventory, let's collect this link here.
2:27If we scroll on down, we can see some examples of Ansible inventories. Here we happen to have what is known as an Ansible inventory in the I and I format. The way we construct this is we specify our group names in square brackets. We have a group here called web servers and inside of the web servers just below, we specify the actual nodes which belong to that particular group. So food.example.com and bar.example.com, they happen to be web server devices and below we have to have a grouping of database servers, DB servers, and the nodes belonging to that particular group is one dot example.com, two dot example.com, and three dot example.com. Now in my opinion, this happens to be the easier way to happen to construct your Ansible inventory , just as really simple, doesn't cause any hassle. But ultimately, I would say it's best suited for simple inventories. If you just happen to have some groups, a few nodes belonging to those groups, then it is a very good way to structure your Ansible inventory. Below though, we can see the same type of information specified in the YAML format. Now the interesting thing here is with respect to YAML, we have a lot of emphasis on indentation. We'll talk about that a lot more in an upcoming skill. But basically, the indentation is very, very important if you happen to get the indentation
3:43wrong. The way the information is ingested is going to be completely different. And in fact, it can just be invalid and well not work. So in my opinion, this is a little bit more complex because an armor rose to follow is easier to get the syntax wrong. However, if you happen to have groups within groups, i.e. nested groups in a much more complex inventory, having that information represented in YAML format is actually a lot easier to look at visually because you can easily see via the indentation, which group belongs to which group. And to quickly assess visually, the order of the hierarchy. Now like I say for error purposes, it's going to be really quite simple. So I'm just going to stick to the i and i format. If you so wish, if you're more comfortable with YAML, then feel free to construct your inventory in that manner. So with that said, let's go and begin configuring our Ansible configuration file. Once again, I'm going to specify mine within my working directory. So right now I'm inside of the Ansible Home Directory for the Ansible user. If we do a listing, we can see we have no files or directories within here. So what I'm going to do is I'm going to create a particular file just called Ansible.cfg.
4:49If I create that, do a listing, now that file exists. But as we know, there is no content within that particular file. Let's add to it. So I will just say them Ansible, CFG. If I hide for insert, I can go into insert mode. And similar to the Ansible inventory, this is also going to be written via the i and i format. So I'm going to say within my square brackets, I'm going to create my default group, which is going to effectively denote my default settings. Now the first directive I'm going to give is specifying where abouts my inventory can be located. Now by default, if you did not specify an inventory location, the default is going to be in the Etsy directory . And then within the Ansible directory, there should be a file called hosts. So if we don't specify it here, Ansible will look to this particular file. But in order to keep things simple, I'm going to specify the Ansible, she looked within the current directory for a particular file called inventory.ini.
5:42Now I'm going to specify the directive for the remote user. This is basically going to be the username. The answer was going to use in order to access the remote machines. Now remember, we created a dedicated Ansible user account on the devices that we're going to manage. So right here, we're going to specify that Ansible should actually use that particular account when logging in. Now I'm going to say host key checking, we're going to specify that as false. We don't really care about key checking. And then I'm going to say deprecation warning pretty much very often. Ansible is going to give you warnings about modules and whatnot that happened to be outdated. We don't want to have to worry about that. So I'll just leave these warning messages set to false. So these are our default configurations. What I now want to do is to specify how Ansible can actually elevate privileges. You know the way you do when you happen to have a shell within a device, you can just say, so do and then type in the super user password. That is how we could perform an administrative system wide task. In the case here, we want to tell Ansible how to do that.
6:39So I'm going to say with 10 miles square brackets, once again, privilege escalation, basically how we can escalate our privileges. What I'm going to say is become equals true, which means we are going to seek to become the root user. I will specify how we actually elevate our privileges by specifying the become method. And I'll say we do that via the sudo commands. And then I'll say the become user is simply the root user. And I will say become ask pass. And I'll set that to the value false. We don't want to be asking for passwords after all. So with that now done, if I press escape and then colon wq to writing quit and then hit enter, we have now written this configuration file. Now as per the configuration file, we specified that there should be a file called inventory.ini within the same directory right now that doesn't exist. So let's just create it by saying touch inventory.ini. If I don't LS and now that file exists, and we want to actually specify the content of that file. Okay, so the very first group that I'm going to create is going to be the all group that is going to comprise of all of my devices in the way specify this group is by using square brackets. Now below here, I will just add in all of my devices. Now there are different ways we can solve this particular problem. Let 's maybe say we've got the blue box here, I can tell Ansible is IP address by saying Ansible underscore host.
7:53And then given IP address of the actual device, so 192 168 dot 160 and do 134. And then for the yellow box, I would just say yellow box, then specify the Ansible host value is going to be the IP address of 192 168 dot 160 dot 135. This is perfectly valid. What you can also do by the way, which I would not recommend is just putting in the IP addresses of the devices themselves without any type of resolution going on. So basically you can get away with it, but I certainly wouldn't recommend you do that. Now the way I'm going to show you is we can also do it another way.
8:27If I just delete this right here, and I just specify the names of the hosts I'm going to be managing. So I've got my blue box and my yellow box. Now right now here, we do not have any IP address information. We're going to have the system resolve this via my Etsy host file on the control mode. So let's just save this right here. And if I say pseudo vim forward slash Etsy, forward slash hosts and enter, here's what I'm going to do. I'm going to type in IP address of my devices to have a static mapping. So 192 168 dot 160 dot 134. This is going to be my blue box. So I will type in the domain for blue box, let's just make one up of blue box dot example dot com. This doesn't actually exist by the way. And we can also have an alias shorthand of blue box.
9:10Similarly, I will say 192 168 dot 160 dot 135. And this one here is going to be yellow box dot example dot com and have the shorthand alias of yellow box. So now we have this static mapping on the system. So when Ansible looks up the name of blue box or yellow box, which it finds within its inventory right now, it's going to know to resolve that to the corresponding IP addresses. If I just happened to say, for example, paying blue box, notice what is actually happening.
9:40We're getting the resolution right here. We're actually getting back the correct IP address. And similarly, if I ping the yellow box, now we're getting the correct resolution and response from that particular machine. And if you swished, if you had many more devices, you could add in more groups. So for example, a UK group, and then add in all devices that were part of the UK group, if you swished, and again, add the USA group, like devices three, four and five . But as you know, right now, I don't have any of those devices. So let me just remove them for the moment. So with that now configured Ansible is ready to rock. We are all set up and ready to automate our lab environments.
Frequently asked questions
Do I need RHCSA certification before taking the RHCE EX294 exam?
Yes. The lesson explains that to be eligible for the Red Hat Certified Engineer certification, a learner must first hold a valid and current RHCSA certification, and a separate RHCSA course is available on CBT Nuggets for team members who have not yet earned it.
What does the Introduction to RHCE lesson cover?
In 48 minutes, the lesson walks through the exam objectives the course covers, then builds a working lab: installing Red Hat Enterprise Linux on a virtual machine, registering it for software updates, creating a dedicated Ansible user, and configuring passwordless SSH key authentication from the control node to managed nodes. It closes by configuring the ansible.cfg file and an inventory, then testing connectivity.
What is the difference between host variables and group variables in Ansible?
Host variables hold values unique to a single host in the inventory, such as an IP address that cannot be shared. Group variables apply shared values to every device in a group, such as a specific NTP server for all UK devices that differs from the servers in the United States.
Should an Ansible inventory be written in INI or YAML format?
The lesson shows both formats with host groups such as web servers and database servers. The trainer describes INI as simpler and well suited to basic inventories, while YAML relies heavily on indentation, so a mistake changes how the information is ingested.
What can a team member do after completing this first RHCE lesson?
The learner can explain the roles of the Ansible control node, inventory, variables, and YAML playbooks, and has a lab of three virtual machines with a configured ansible.cfg file and an inventory verified for connectivity. That lab is the foundation the rest of the course uses to automate tasks across managed devices.
Who on an IT team is this RHCE Ansible course designed for?
IT Directors can assign the course to experienced Linux system administrators, especially RHCSA-level practitioners with roughly 3 to 5 years of Linux experience who need to automate Red Hat Enterprise Linux work with Ansible. The full course runs about 19 hours per learner, and Team Reporting gives IT Directors and Training Managers visibility into progress toward RHCE readiness.
Team training path
Turn this skill into assignable team training
This free skill is a preview of the courses your team can assign, track, and report on with CBT Nuggets.
Free training library
More free lessons in Linux
Linux
Introduction to LPIC-1
Free lesson from Linux Professional Institute LPIC-1 (101-500 & 102-500) · 49m
Linux
Understand Linux Fundamentals
Free lesson from CompTIA Linux+ (XK0-005) · 49m
Linux
Install and Configure the Apache Web Server in Linux
Free lesson from Everything Linux · 52m
Linux
Monitor & Measure Resources Usage
Free lesson from Linux Professional Institute LPIC-2 (201-450 & 202-450) · 56m
Linux
Introduction to RHCSA
Free lesson from Red Hat Certified System Administrator (RHCSA) Exam EX200 · 52m
Linux
Linux Evolution and Popular Operating Systems
Free lesson from LPI Linux Essentials (010-160) · 52m
$59
seat / mo, billed annually
