In this video, we will establish connection to our remote clients from our Ansible control node.
All right.
So for that, the first thing we have to do is take a snapshot of our Linux client, one that we created
during our lab setup and then power it up.
The reason we wanted to take a snapshot in case something goes wrong, we make a mistake, we install
a configure something bad by mistake.
Then we could always go back to the point where we actually build the OS.
So the first thing we have to do as we are following this instruction start up our Oracle VirtualBox
here is our Linux client one powered off and you should have this menu.
If you do not have this menu, click on these three dots and click on Snapshot.
Then go click on Take.
Give it a name, any name of your choice.
I'm going to give it a Linux install point which will always remind me this is the time when I finish
installing the Linux operating system on this virtual machine.
Click.
Okay, now it has the Linux install point.
Now go ahead and click start.
All right, so we have our desktop.
Now, if you right click on your desktop, this is sent to seven.
You can just simply right click on the desktop and click open terminal.
This is going to open the terminal.
Now, let's go ahead and close the window right behind it, which is Oracle VirtualBox window.
Now we have that up.
Let's see what is the next step?
Note down its IP address.
All right, so let's get its IP for that.
Run the command if config and move up a little and you will see e np zero three it's ip address ten
250 3.1.115.
All right, perfect.
Now.
Populate the host file with IP or FCN for our clients and this is our client.
So we'll go to our control node.
Our control node is right here and I am logged in.
Who am I?
I'm logged in as root.
Let's see which directory I am in.
I'm in ETSI Ansible and I want to go to host file to modify that.
So host and.
And right here.
We'll put in the IP address.
Ten 250 3.11. 115i believe.
Perfect.
All right, it's there.
Now let's check.
And Sybil.
Inventory dash dash list.
And it is showing our correct IP.
All right.
So that is done.
If you don't have multiple clients and we don't have a different grouping of clients, so we'll just
have one client.
So we'll play with this one.
Only if you have multiple, then use your discretion and define them in grouping as as per your requirement.
All right, then what we have to do, generate a ssh key on the control node and copy over to clients
for password.
Less sausage connection.
Yes.
So in order for Ansible control node to execute command to your remote clients, it has to have a sage
connection without a password.
And for that, there are four different steps that you have to do.
All right, so let's go to our control node, which is right here.
Let's clear the screen.
The very first thing we have to do is to run the command as a search.
Dash Keegan hit enter and it says Leave everything default and just simply enter.
So I'm going to leave everything.
Default, hit, enter and enter and enter.
Nothing else there.
Simply enter three times.
All right.
So the key has been generated.
Now we will copy that key over to our client.
So for that, we have to use a command says dash copy, dash ID.
Now this is the command and we will use the IP address of our client, which is 10 to 50 3.1.115 hit
enter.
Now it says, are you sure you want to continue?
Yes.
Type yes.
And this is going to ask you the route password for your remote client, for your Linux client one All
right, beautiful.
It says number of keys.
One added, Please remember one thing.
If you have more than one or more clients, then you only need to run S-H Dash Key Gen just one time
on your control node, but you have to run as a dash copy dash ID followed by the IP address multiple
times.
Based on how many remote clients you have now try logging into the machine with.
Search this command and check to make sure that only the keys you enter were added.
All right.
And that's what I am telling you here as well now as search into the client to test.
And for that the the command is the sage followed by the IP of your client.
All right, here I am on the Ansible control node and I'm going to type it in ten .2533.1.115.
And you'll notice I am in the remote client.
And it did not ask me for any kind of password.
You see?
Who am I?
I'm logged in this route.
What is the host name?
Where?
I'm logged in.
I'm logged in as Linux client one.
Nice.
All right, then it says Run Ansible ad hoc command to ping remote nodes.
Make sure host file has remote clients IP, which we already did it.
And for that the command we will use.
Let's go back to our control node.
Right now we are logged in in Linux client.
So simply type it in exit to exit out and come back to your control node to confirm type it in hostname.
Sorry.
Let's clear the screen so we can see it clearly.
Type it in hostname and you'll see we are back to our control node.
Now type it in Ansible.
All.
When you define all now it means that it is going to go to Etsy Ansible host file and get all your remote
client inventory information from there.
And you're saying whatever the host that you have in the host file, simply go ahead and ping them.
That said, this is the ad hoc command and hit enter.
This is our test.
To make sure that we could get to that remote client.
And our test is successful.
Beautiful right here.
Says success.
And it's a ping and pong.
So congratulations.
You have created a connection between your control node and your remote client.
And you could also do Ansible dash a uptime all to run a command on the remote clients.
That simple ansible a.
Double coat up time, double coat close.
And where do you want to run them?
Against all, of course.
We have only one remote client, so we'll just use all and enter.
And it should bring back the uptime of our remote client, which is Linux.
Client one Beautiful.
All right, guys, see you in the next lecture.