So friends now that we've been able to devise our inventory as well as our
login credentials
What we've done so far is effectively just run some ad hoc commands, okay?
So we're not really actually running playbooks as such or rather not even as
such playbooks at all
What we want to do now is to learn how we can actually run those playbooks
Utilizing this automation controller so now what I want to do is to look at
something known as projects as well as templates
Basically these projects is where we can define our playbooks and we can WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Basically these projects is where we can define our playbooks and we can
essentially run these playbooks
Utilizing our templates kind of strange terminology
I do admit because it isn't very clear that a template would run a playbook as
such but nevertheless
This is what the nomenclature is so we're going to stick with it
So let's go and check out our projects them. So let's click this link on the
left right here now again
That is a demo project. That's not what we want to do. Let's create our own one
So let's just add this and let's just call this I don't know. Let's just say n
ugget project one
Okay, call it anything used to wish now what is the organization? WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Okay, call it anything used to wish now what is the organization?
Well, it's going to be the nugget tech organization after all and then we can
specify our execution environment
Now again, just going to use the default execution environment
Just choose select and now I'm going to specify my source control type pretty
much
This is effectively how we're going to source whereabouts or playbooks come
from now
What you actually can do is you can actually define the playbooks on the
controller itself
And I'll show you how to do that if we just go to the drop down menu here and
you happen to select manual
Let's scroll on down now right here. It says there is a warning there are no WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Let's scroll on down now right here. It says there is a warning there are no
playbooks within the particular directory
This is the directory that it's going to look into var lib a wx and projects
So it says either that directory is empty or all the contents are already
assigned to other projects
So basically if you want to have your playbooks held on your own system
You can define the actual path which in this case here
This is the default path and any playbooks stored within here will be
accessible to this particular project now
I would just say this is generally not how things are done at all WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I would just say this is generally not how things are done at all
Typically in the real world which is what this particular skill is all about
after all
It's about more real world application of Ansible you are much more likely to
use a source control system
The most commonly one known as get tub now
I'm not going to go through all the details about what get hub is that as an
entire different course after all
But the quick overview is basically that get tub is an online website
That is used for the collaboration of many different code based projects with WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
That is used for the collaboration of many different code based projects with
things like configuration files or Python code or
Ansible playbooks that type of thing can all be shared and stored on get hub
online
So what I want to do is I want to actually go and create what is known as a get
hub repository
And that's going to have my Ansible playbooks with thinnets
So let me go to a browser here and if I just search for get tub and I click
this link here
Now what you want to do here if you don't have an account is to click sign up
They're going to ask you for some particular details such as your email address
and the password that type of thing
But in my case here, I already have an account WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
But in my case here, I already have an account
So I'm just going to sign into it. So just type in the username and password
Okay, so I have logged into my personal get tub account and all I will do here
is I will create a new repository
So if I go up to the top here and then go to your repositories all I will do
now is I will create a new one
Okay, so I'll give this repository a name. Let's just call this or don't know a
AP
Test and I'll just say this is a test repository for Ansible automation
platform cool now very very important points
You can make this repository public which effectively means that anyone on the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
You can make this repository public which effectively means that anyone on the
internet can see this repository
Which means that you don't have to have any type of credentials to get the code
on this repo
But to be aware if you happen to be working on sensitive data
That is internal within your own enterprise
You would probably want to create a private repository and in which case you
would actually have to generate some type of API token
So that you can actually authenticate remotely with this report and access its
contents after you generated this API token on get tub itself
You would actually have to go and create some new credentials within the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
You would actually have to go and create some new credentials within the
automation controller
In fact, you know what let's just go through the entire process
So it's clear because ultimately this is a real world skill and it is going to
be helpful for you
So let's create a private repository here
So no one can see it and I'll just say I'll add a read me file care now
If I just choose create repository here it is right here now if I just go and
click the plus sign right here
I can create a new file so I can do here is effectively create my Ansible
playbook now
Traditionally what you wouldn't do is actually create the playbook directly on WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Traditionally what you wouldn't do is actually create the playbook directly on
github itself
You would more likely create this locally on your system and then push the
changes to github again
This is not a github course. So we're not going to go into too much detail. Let
's keep it as simple as possible
So let's just get this playbook a name
We'll just say play one test playbook the host I will target
Let's maybe just go with the yellow box and now I'll define my task and just
say install engine X
And I'll use the Ansible built-in
DNF module and I'll say the name I want to install is engine X the state should
be present and now I'll have an WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
be present and now I'll have an
Another task which would just be to start the engine X server so this time
I'll use the built-in service module and I say the name of the service
We're targeting as the engine X server was just installed and the state should
be in the started state
Kill so all I will do here is name my playbook
Let's just call this engine X test dot yml and all I will do is I'll choose
commit these changes
And they'll just come at the changes again and now we can see here within the
repository
I have this actual playbook so pretty much what I want to do is I want to allow
access to this particular repository WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
access to this particular repository
So people within my team who should have access can get access to this playbook
So what I will do here is I'll go to my settings here
Let's get into settings and if I scroll on down if I go to developer settings
and then go to personal access tokens
And now I specify the tokens classic okay, and all I will do is I will click
generate a new token and again generate new token classic
And let's give this a token a name just call a AP demo token now
How long should this token last for you can specify how long I would just give WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
How long should this token last for you can specify how long I would just give
it a custom time and I'll pretty much specify
That it should expire by the 15th of April, which is about two days time
Then I specify the scope of what this token should be allowed to do
So should I have full control of the private repositories?
Let's say yes, should I have the ability to delete repositories perhaps be able
to have right access to our discussions that type of thing
Define the rules as you so wish but from now all I will do here is I will go
down and I'll choose generate token
So right here I have this particular token and all I'm going to do is I'm going WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So right here I have this particular token and all I'm going to do is I'm going
to copy it
Okay, now check this out. Why I want to do is to go back to answerable
Okay, so now that we have created our token over on the github website
Why do I want to do is I want to go to my credentials here on answerable the
automation platform and I will just add the new credential
So let's just call this github creds just a creds for github the organization
is going to be nugget tick
Just choose select and the credential type this time. It's not going to be
machine
It's going to be source control. So let's just select this and now go to my WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
It's going to be source control. So let's just select this and now go to my
details now
What I want to do is I want to specify my github login username, which is just
simply IPV0 and it's at gmail.com
And now for the password what I'm going to do is I'm actually going to just
paste in that token that I just generated here
Okay, so if I just paste this in right here
We can see this as the very very large token and all I will do is I'll scroll
on down and I will choose save
So now I have this new token here called github creds with that now done
If I go to my projects here and I choose to add the project WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
If I go to my projects here and I choose to add the project
I'll just call this my projects one or whatever just a test project was the
organization
That's nugget tick execution environment as default and now choose the source
control type
Now the type here is going to be get and now what I will do specify the source
control URL
So I'll go back to my repository to here if I go to code and I just copy this
link right here
And now I paste in the source control URL and now if I scroll on down
I'm going to have to specify my source control credential that I just created WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I'm going to have to specify my source control credential that I just created
there
So if I go to my magnifying class
We should have these github creds that's going to associate and just choose
select and now if I scroll on down
I can choose save and now I have effectively created this project
That is going to pull any playbooks from within this repository if I want to
execute one what you can now do is go to my templates
So all I will do now is choose add to add the templates
And I'll just say add a job template and I'll give the name of the template
I'll just call this maybe engine X template
I'll just call this test job the job type is it to run or is it to check we WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I'll just call this test job the job type is it to run or is it to check we
talked about this earlier on within
Ansible remember we had answerable check mode if you want to just check you can
specify check in this case here
I really wanted to run now. What is the infant today?
I want to use I want to target my Linux infant or a and now specify the actual
project with a project
I just created was my project one choose select here and now we can see here
I actually have this drop down menu of all of the playbooks within that
repository now right now that is only one
So the only one available is engine X - test yml WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So the only one available is engine X - test yml
But if I added more to that repository then more would be available for me to
select
So let me choose this playbook here and for credentials for the actual
execution
It's going to be the rail credentials that will allow me to log into my devices
And if I scroll on down we have some additional options such as privilege
escalation do we want to do that?
But for now all I will do for the moment is just choose save now recall the
actual engine X test playbook is going to
Specifically target the yellow box and attempt to install engine X now
What I want to do here is over on the yellow box as I just want to say system c WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
What I want to do here is over on the yellow box as I just want to say system c
ta
Status on engine X and we can see here engine X indeed is not installed on this
system after we run the playbook
This should now be present and running so if I go to my templates here
What I can now do is I can just choose to launch the template with this icon
now
It's going to begin to run and we can see the playbook begins to execute
however
It appears we happen to have a failure if we go to details and again go back to
output
Let's actually look at the output here if I scroll on down
We can actually see this command has to be run by the root user and that is DNF WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
We can actually see this command has to be run by the root user and that is DNF
Now that is because if we go back to our templates here and we go back in if I
go into edit modes
And I scroll all the way down notice
I actually want to select privilege escalation
So we actually become the root user to install a particular package
So we're effective with the sudo DNF. So if I save this now with the change and
I now go back to my templates
And I attempt to launch it this time
Let's see how we go on the second attempt and this time WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Let's see how we go on the second attempt and this time
It says that output is successful so if we go back to our details and then go
back to our outputs
Scrolling on down
We can actually see the play recap
And if I go back to the yellow box and I add a lot and to enter notice now
engine X is running on the system