Okay friends, so let's see how we can actually build out this inventory file.
So within my actual directory right here, all I'm going to do is I'm going to
save
then and I'll call this inventory dot ionized.
I'm going to be using the I and I format.
So the very first thing I'm going to have to do is to create two different
groups.
One is going to be called the test group and the other one is going to be
called the production group.
Now the way we denote a group is utilizing these square brackets.
Now within each group, we also have the constituent host.
The first one is going to be device number one and for the production group, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
The first one is going to be device number one and for the production group,
we're going to add in device number two.
Now also, we want to place both of these groups and all of their constituent
members inside
of a parent group called rel servers.
Now the way we do this is again have our square brackets and we'll just say rel
underscore servers.
Now here's the thing, you can't just close your square brackets and then
specify that the
groups that belong to this parent group is going to be test and production.
That is almost correct, but we're missing a very key detail.
We want to specify that these actually are child groups and the way we do this WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
We want to specify that these actually are child groups and the way we do this
is by
specifying the colon and then children.
This tells us that the test group and production groups both belong inside of
the rel servers group.
So if you have to get that correct, give yourself a pat in the back, that is
the right way to
solve this particular problem right now, if writing quit to save the changes.
Now we can see here we have this inventory file.
Now what we want to do here is also create an Ansible.cfg file.
So here's the thing within our inventory.
We want to provide a path that is going to point to that inventory. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
We want to provide a path that is going to point to that inventory.
I and I fail that we just specified.
We also want to configure privilege escalation.
How do we actually get to root privileges?
So we're going to specify that we want to be able to use the sudo command.
We also want to specify that the super user account is going to be known as
root.
And we also want to specify that we don't have to require a password when elev
ating
through our privileges.
Now that's not the only thing we want to do.
We also want to specify a path for where our collections are going to reside.
In a similar fashion, we also want to specify a path specifying where our rows WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
In a similar fashion, we also want to specify a path specifying where our rows
actually reside.
Now we want to have a default directory for our collections inside of the user
Ansible
Home Directory.
And the same thing is true of the rows directory that would be the default.
Now what does this actually mean?
Well, the user will be happy to be here as Ansible.
And if we cd to that Home Directory, if I did PWD, this is the Home Directory
right here.
So inside of here, we should also have another directory called collections.
That should be our default collections path. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
That should be our default collections path.
And also similarly, we should also have a rows directory within this directory
structure.
And that should also be our default path for our rows.
And lastly, in our case, we want to specify that the Ansible user is going to
be the user
that is logging in to both of the managed nodes.
So pause the video, try to write up this configuration file and see how close
you get.
For now, I will just go and show you what my solution was going to be.
I will save them Ansible.cfg.
I'm going to insert mode and then I will specify my square brackets and pass in WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I'm going to insert mode and then I will specify my square brackets and pass in
my default
directive.
So the remote user, we're going to log in as will be Ansible.
I'm going to specify that my inventory here is going to be in my Home Directory
.
So I could either specify that as Home Ansible and then specify the actual file
, which is
inventory and I gave it an INI extension, although you don't actually have to,
or alternatively,
what I could do is I could say the tilde sign forward slash, which is affected
by Home Directory
to or alternatively, I could just provide the relative path and just say
inventory.ini. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Each of the solutions all are fine.
So I'll just leave it in the simplest way.
Now what I want to do is I want to specify the as pass as equal to false.
We don't have to ask for a password to use our particular account.
And also what I want to do to specify my privilege escalation directives also
privilege underscore
escalation within my square brackets.
And what I want to do here is I'll say become is equal to true.
This is how we elevate to super user and I will say they become method.
How do we actually get our super user privileges?
We use the command sudo and I'll say the become user, which is going to be the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
We use the command sudo and I'll say the become user, which is going to be the
super user.
That is going to be the root accounts.
And similarly, I don't want to have to use passwords.
So I'll say when I become the root user, I want to specify that the become as
password
is equal to false.
Now we also want to specify what our rows path and our collections path is.
Now let me just show you a little tip that we can use to make this a little bit
easier.
If you have it going to Vim, it's the answerable and then answerable.cfg.
We actually get a little sample configuration file now.
It actually doesn't really help us out too much in that it doesn't show the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
It actually doesn't really help us out too much in that it doesn't show the
actual parameters
of what we want to use. But what we can see here is we can actually generate a
little file
by copying this particular command.
Now what I'm going to do here is I'm going to copy this.
Now like I say, I've already created this answerable.cfg.
So I actually don't want to create another one and overwrite the existing one
with the configurations I had.
So all those are just changed in name here to be answerable template.
So what it's going to do is going to generate this new file here, which we can
see if I go into the answerable template.
Inside of here, we actually get all of the information that we can specify WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Inside of here, we actually get all of the information that we can specify
within
that these answerable configuration files.
Now we want to be able to specify a path for a collection.
So if I just search for collections, we can actually see collections path.
All I'm going to do is I'm going to copy this particular path that we see here.
Okay, so let me grab this.
And if I go into answerable.cfg, let me go back into my defaults here.
And I'm just going to say collections path.
And then what I'm going to do is say equals and then paste in that part I just
copied.
Now what we're actually seen here are comma separated values.
These are pretty much all the locations whereby answerable is going to search WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
These are pretty much all the locations whereby answerable is going to search
to find your collections.
The one at the beginning is going to be our first one, which in this case here,
it specifies forward slash collections.
Okay, now this actually is in the root directory here because it starts with
the forward slash.
We want to have our collections within our home directory.
So what you could do is just like before I can go in and I can add in a tilde
or if I so wish I could just use the relative path
and remove the forward slash and then we specify that the first place we'll
check will be in the home directory.
I either direct it in which this file resides and then we look for a WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I either direct it in which this file resides and then we look for a
collections folder.
Then we also search another path which in this case here is going to be user
share answerable collections.
Okay, so we include both of these.
Now let's go back in to the template once again.
If I also search for rows path, we can see we have this particular path which
also has an additional component
or rather an additional directory should I say so let's copy this back into the
answerable CFG
and all I will do here is I will say it rolls path is equal to and all I will
do is I'll paste this in right here WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and again, these are comma separate values.
So the first one we're going to look in is going to be forward slash rolls,
which is going to be at the root directory.
So we don't want that.
So let's just keep this relative path.
And then the second location will be user share answerable rolls.
And then if we can't find the role in that particular directory, we're going to
search in the Etsy directory
for Etsy answerable roles.
Okay. And in fact, what I've just noticed is that I'm going to have to remove
these little quotation marks right here.
So let me just remove this right here.
So that is correct.
And the same is true for my role right here.
Let's just do the same remove view and remove view. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
That is much, much better.
So let's just save this.
And what I've now done, what I want to do is I want to create an answerable
user account on all my managed nodes.
So right now, in both of my managed nodes, I actually have an account called n
ugget user.
Whatever account you have, you can also substitute that value in.
So what I'm going to do here is because I have my basic answerable
configuration, i.e.
I have my inventory file, which we can see right here, as well as my answerable
cfg.
In fact, what I can do here is just remove this little template file.
We don't need that anymore.
So all we have are these two. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
What I can now do is run my answerable ad hoc commands against both of my
devices, which is going to allow me to quickly set up these particular values.
And again, this is not something we're going to have to do in the examination.
It's just something we're going to have to run through to get our own lab
environment set up in this case.
So the very first thing I'm going to do here is I'm going to say SSH with the
user name of nugget user.
And then I'll target device number one.
Now we can see here, I'm going to have to add the fingerprint if I just say yes
.
Right now, I don't even have to log in.
I would just press ctrl C as long as I've added the fingerprint. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I would just press ctrl C as long as I've added the fingerprint.
That's good.
And if I say device two, and to enter, again, yes, to add the fingerprint in c
trl C to terminate the connection.
Now what I want to do is I want to use answerable here.
So I'll say answerable all then dash you and the user I want to log into or
rather in with is nugget user.
Then I'll say dash k to ask on my password dash B to become the root user dash
capital K to ask for the root user password and then dash N to specify the
module, which in this case here will be the user module or then say dash a to
specify my argument, which is simply which account I want to create. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
specify my argument, which is simply which account I want to create.
So I'll say name is equal to answerable. And if I answer and just type in the
password or password one and again password one.
Now we can see here we have actually created this answerable user account on
both of my devices.
Now what I want to do is I want to give my answerable user a password of simply
answerable.
So let me clear the screen.
If I add a what I'm going to do a similar thing, but this time I'm not going to
use the user module.
The module I will use will be the shell module and all I will do here is say WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
The module I will use will be the shell module and all I will do here is say
dash a and then echo in the password of answerable and then pipe it into past w
d and then also dash dash SD D and then answerable, which is going to be the
account for targeting.
So if I had entered again type in my passwords and to enter now we can see here
we've updated the password for answerable.
Now what I want to do is I want to ensure that these answerable accounts have
super user passwords or rather super user access and we don't have to supply a
password when we happen to invoke that super user access. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So again, I will just add a what and the module I'm going to use this
particular time is going to be the copy module and I want to copy over this
particular contents.
So I will say dash a and then with the quotation marks, I will say content is
equal to and then within single quotation marks, I will say answerable all in
capital letters is equal to within parentheses all and then a space and I'll
just say no past wd colon all and then have my single quotation mark
So I will specify that the destination is going to be copy to forward slash it
say soudores dot D forward slash answerable. Basically, all we're doing is what WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
say soudores dot D forward slash answerable. Basically, all we're doing is what
we did with the control node.
We are copying over this particular content and we're targeting the it say it's
to do or answerable file. Okay. So if I hit enter here and again type in my
passwords and to enter now that information is copied over.
So what I should be able to do now is I should be able to say ssh answerable at
device number one and then type in the password of answerable and I should be
able to say so that's right on the account and we should be able to list or WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
able to say so that's right on the account and we should be able to list or
rather the
the content of the right to which we can without having to enter on a password.
Similarly on device number two, typing the password of answerable. Now again,
if I just happened to say LS on the route itself, we're going to say
progression denied, but we can say pseudo LS on the route without a password
and we do get the content.
So this is looking good. What we now want to do though is to set up password
less logging in. So on the control node, I will say ssh hyphen Q gen. Okay, and
I'll just hit enter, enter and enter.
And all I want to do is I want to say ssh hyphen copy ID and target device WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And all I want to do is I want to say ssh hyphen copy ID and target device
number one. So all I will do is type in the password of answerable and to
answer.
We now copy over the key. Let's arrow up to the same thing for device number
two again, type in the password of answerable and to answer.
Now we've added yet another key. So if I just simply say ssh at device one,
enter the automatic log in straight away without any password authentication.
Similarly on device two, we log in straight away. Okay, so let's exit back out
with that. Now done. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I can just say answerable all dash M and I'll just say paying to try to ping
all of my devices with the all module and to enter.
Then we can see here successful target or devices and similarly if I just
happened to say answerable all and then say dash A for the argument and then
say LS dash L against the route account and to enter.
Now we can see the actual see the contents of the route directly for both
devices.