So friends, throughout this course, one thing we have consistently referenced
is the Ansible
documentation. This is proven to be very, very useful. But one thing you may
have noticed is
that when we go to retrieve the documentation, we're always using the internet,
we're opening
up a browser, we're using the big Google machine and searching for whatever it
is we want to see.
What if I told you that we actually don't have to do that? Now, to be clear
here, I haven't been
misleading you. This is actually still my preferred way to inject the Ansible
documentation that WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
documentation that
happened to light the way it is presented within the browser. But for the
purposes of the examination,
isn't it quite good and reassuring to know is that you can still consult the
documentation
directly via your terminal. So what is this? What's up, Jay? What is this magic
? Well,
what we're going to be looking at is a command known as Ansible hyphen dot. So
in this short video,
what we'll do is look at the browser version and compare it to what we actually
see in
Ansible documentation via the command line. So let's go and boot up our browser
. So let's maybe say WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
. So let's maybe say
we want to look for the Ansible file module. Okay. So with issues, Google to
search for it. And if
I just click the link here, as we can see by scrolling on down, we get a basic
overview about
what this module is. It's part of Ansible core. We can see the fully qualified
collection name
Ansible built in file, which is what we would use within our playbook. And we
get some basic
information such as the synopsis. What exactly does this particular module do,
but it allows
us to set attributes for files, directory, sim links and the targets, we can
remove files, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
remove files,
that type of thing. And we also see crucially, the parameters that this module
takes, how do we
actually use this particular module? Say, for example, you want to use the
access time parameter,
it tells us exactly how to use this and what it actually does. And very cru
cially, if that happens
to be a particular parameter that is required, we can actually see that
directly via the outputs
if I stroll on down, say, for example, this parameter right here, the path
parameter, we can indeed
see that this is required. So we know if we go to use this module, we have to
supply this parameter WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
supply this parameter
and provide the value. This is how we see things on the browser. But check this
out. If I go back
to my terminal right here, if I say Ansible, hyphen, doc, dash dash help, and
to enter,
what we actually see here is all the ways in which we can utilize this
documentation.
So say, for example, we use the dash L option or alternatively dash dash list,
this is going to
allow us to list the available plugins. If I now just say Ansible hyphen, doc,
dash dash list,
or if I so wish to dash L and to enter, look at this right here, we have all of WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
or if I so wish to dash L and to enter, look at this right here, we have all of
these
Ansible plugins right here. So if I just press spacebar, we can see everything
that we can do
here. We have a rail system roles, we have our built in Ansible modules, that
type of thing.
Say, for example, therefore, if I go up to the Ansible built in file module,
which we were
looking at online, here is what we see right here. You see that we can see it's
going to allow us
to manage files and file property. So what I'm going to do now is if I just
want to look at this
particular documentation for this particular module, I can just copy this here, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
particular documentation for this particular module, I can just copy this here,
then press
Q to quit, clear the screen. And I just say Ansible hyphen, doc, and then paste
in the actual module
I want to inspect. If I hit enter, check this out. Does this look a little bit
familiar? We see
the same type of information that we saw before, this is going to allow us to
say attributes of
file directories and sim links, that type of thing, we get the basics and
options. We can also see
all of our parameters to see this access time, and we get the little
description as to what it
actually does. Notice if we happen to see the equal sign, this indicates that
this is mandatory. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
this is mandatory.
So if I press spacebar and go all the way down, and I get to path, notice path
doesn't have a
hyphen, it has an equal sign indicating that this is indeed required. And it
tells us this is the
path to the Fairbeam managed. Now if I scroll on down a little bit further,
look at this right
here, this is super, super helpful. We actually get some examples that we can
use. This is the
same type of thing that we would expect to see in the browser version. Big
difference here,
though, is we have it directly available to us on the command line. So for WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
though, is we have it directly available to us on the command line. So for
example, this one right
here, let's say we wanted to change the file ownership group and permissions we
see we use the
Ansible built in file module as supplied here. Then we have the path parameter
to specify the path
that we want to modify. Then we can use the owner parameter specify the owner
as well as the group
and the actual permissions in this case here, denoted in optomotation.
Similarly, let's say we
were curious as to how to create a symbolic link, well, this example here shows
us exactly how to do
that. Once again, we use the Ansible built in file module, we're going to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
that. Once again, we use the Ansible built in file module, we're going to
specify a source,
which is the path to that particular file. And then the destination, which is
going to actually
denote the sim link, once again, we can supply the owner, the group, and
specify the state in this
case here, it's not going to be a directory or file, it's going to be a link.
Whereas below,
we can see how we can create a hard link, we specify the file module once again
,
the source, the destination. This time, though, the state we specify is hard,
that is going to give
us the hard link as opposed to a sim link or a soft link. And the cool thing is WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
us the hard link as opposed to a sim link or a soft link. And the cool thing is
, this is true for
the other modules too, let's say for example, we went into Ansible.org dash L,
and let's maybe say
we wanted to look at the, oh, let's go with the command module. Well, again,
let's just copy this
particular module here. And all we need to do once again is the exact same
process, Ansible.org,
and then paste in the particular module we want to inspect this time, we get
this in Optus here,
telling us it's going to allow us to take commands, follow back a list of space
delimited arguments,
and once again, if we scroll on down, we see our options, the equals sign den WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and once again, if we scroll on down, we see our options, the equals sign den
oting any options,
which are mandatory to be supplied. So again, we see options such as CMD, which
is going to allow
to specify the command to run. If I press space bar all the way down, once
again, we come to our
examples. If I want to register the message of the day to a registered var,
this is how we
do such a thing. Use the Ansible built in command module, we can cut the
particular file and then
register it. In this case here, my MOTD. So let's say for example, just go back
into the file
documentation here, and we'll just scroll on down to the examples. And let's WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
documentation here, and we'll just scroll on down to the examples. And let's
try to create this
symbolic link. So all I will do here is I'll just actually copy this directly.
Okay, so that's
copied. And all I will do is I'll create a playbook called play three dot YML.
So we have our three
high-fins at the top, which is play three, create Simlink. The host I will
target, I will just target
the blue box this time. I'll set gather facts to false. And in this case here,
all I'm going to do
is I'm going to paste in that example. Now, one thing we may notice here is
that the indentation
is not exactly correct. So all I will do is indent everything two spaces. So WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
is not exactly correct. So all I will do is indent everything two spaces. So
there is correctly aligned.
And now I have this nice little template that's going to allow to create Sim
link. All I will do
is modify some of these values here. So on the blue box here, let's create a
file. So in my working
directory here, let me just create a file called, or I don't know, let's just
say link example dot
Txt, okay, doesn't actually matter. And all I will do is I'll supply those
values here. So I'll go in
here, and I'll use the path of home nugget user, and I'll say link example dot
Txt and the destination.
Let me just put in the temp directory. And I'll just call this my link example. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Let me just put in the temp directory. And I'll just call this my link example.
Okay. Now the owner
can be nugget user. The group is also going to be the nugget user group, and
the state is going to be
a link. So it's going to be a Simlink. If I wanted a hard link, I would specify
a hard link here. But
in this case here, let's just keep it as a Simlink. And just before I actually
run this, one thing I'm
going to have to do, of course, is I'm going to have to use my task keyword to
specify that I'm
actually creating a task here. So let's write and quit. And let's then run the
playbook. So we
execute and it appears we have a change on the device. So we go into the blue WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
execute and it appears we have a change on the device. So we go into the blue
box, if I go into
the temp directory, and I do an LS, we can see my link example. In fact, let's
do a long last thing
on that. If I scroll on up, check this out right here. This is my linked
example. And what does it
actually point to? It points to the home nugget user link example file. We did
successfully create
that Simlink. And how did we do that? Well, we just copied it directly from the
Ansible
documentation available to us directly within our terminal.