Okay friends, so let's walk through the solution.
So the very first thing that I asked you to do was to define a variable in the
all.yaml file called ntp_server, and this should have the value 5.6.7.8.
So the all.yaml file as we know should be located in the group var directory,
and inside here I will just say vim all.yaml,
I'll go into insert mode, and I will add the key ntp_server,
and I'll give it the corresponding value 5.6.7.8.
So press escape wq to write and quit, and now what I need to do is to write an WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So press escape wq to write and quit, and now what I need to do is to write an
answerable playbook to print this variable out for all hosts in the infant
story.
So let's go back and I'll just create a little variable called validation 2,
and go in here, go into insert mode to have my three hyphens at the top,
I'll give a name validation test, what we're going to target the scope is going
to target
all the devices, I will specify my tasks, and I'll just give this a name,
I'll just say printing out the var value, and then I will use a debug module,
and the message parameter, and I will just simply within quotation marks, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and the message parameter, and I will just simply within quotation marks,
I will add my double curly braces, and then just call the name of the variable,
which in this case here is going to be ntp_server, so I'll just press escape wq
to write and quit.
So if I say answerable playbook validation 2, and to enter, and as we can see
here,
we are successfully printing out 5.6.7.8 for both the blue box and yellow box
devices.
So the next thing I'm going to have to do is to select one device in the infant
story,
and override the ntp server value that it inherits from its group membership, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and override the ntp server value that it inherits from its group membership,
and I'm going to give it the value 4.3.2.1, so basically pick any of these
devices in your infant story,
so I will go in to my host files this time, and I'm going to modify, let's say
the blue box.
So inside of this particular file, all I'll do is go to the end here,
and I will say ntp_server, and I'm going to give it the value 4.3.2.1.
So if I press escape, and then wq to write and quit.
If I say answerable playbook on validation 2, hit enter.
As we can see here, the blue box is now overriding its group membership, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and it is printing out 4.3.2.1 whilst the yellow box still retains its original
value from the group membership.
Now the next thing we're going to have to do is to without modifying any host
or group variable
files, we want to rerun the playbook and ensure that the ntp_server value is 1.
1.1 for all devices.
We're not going to modify any host or group variable files, but what we can do
is we can modify the
playbook itself, so we're going to validation 2, and at the very top here I'm
going to say vars,
and I will just create the ntp_server variable right here, and give it the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and I will just create the ntp_server variable right here, and give it the
value 1.1.1.1.1.
If I press escape wq to write and quit, clear the screen, add a warp, and rerun
again.
Now we're printing out the value 1.1.1.1 for all devices overriding both group
and host variable
membership. So we could solve it that way, but just to be clear, if I go into
validation 2 once again,
and I delete this part of the solution, so just press dd and dd. Now we have
not defined the
variable directly within the playbook, what we also could do is I could just
run Ansible playbook
and say validation 2, and then say -e for extra variables, and then with the n WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and say validation 2, and then say -e for extra variables, and then with the n
tp_server,
is equal to 1.1.1.1, n my quotation marks and hit enter, and as we can see here
, without modifying
any host or group vars, we have successfully overwritten the value of the ntp_
server.
Now the next thing we're going to have to do is to create a brand new file with
the key value
password secret, and not just that, we want to ensure that this brand new file
is encrypted.
So that will say Ansible vault, and I want to create, because it's a brand new WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So that will say Ansible vault, and I want to create, because it's a brand new
file not
encrypt, which is what we use for an already existing file, and just call this
file
ntp_server, or just call this bla.yml, does that actually matter? If I hit
enter, I'm going to
create a password, let's just say the password is jiohgen for john, and I will
confirm it.
And inside of here, I now have my vencation, so I'll press i for insert mode,
and then just type
passwords colon to create it as a key, and then the corresponding value is
going to be secret 1.
Now if I press escape colon wq to write and quit, notice if I cat the file, it WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now if I press escape colon wq to write and quit, notice if I cat the file, it
is in an encrypted
state. Now what I want to do is to view the unencrypted content of this file
without
actually decrypting the file on disk. So the way I can do this is by saying Ans
ible vault,
and then view, and then specify the name of the file, and then type in the
password,
which in my case here was jiohgen, if I hit enter, now we can actually see the
contents
without actually disturbing the unencrypted state of the file. The next thing I
want to do
is I want to change the password of this file once again without fully decrypt WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
is I want to change the password of this file once again without fully decrypt
ing it on disk.
So I will say here is Ansible vault, and I want to rekey, blah dot yml if I hit
enter,
type in the vault password of jiohgen, I will type in the new password of Keith
,
hit enter, and confirm it as Keith, hit enter again. Now the rekey is
successful and we can test
this, but once again try to view the file, this time using the new password
Keith. So if I type
Keith then hit enter, as we can see, we have the contents of the file. So that
is us for our validation
challenge. I hope it's been informative for you and I'd like to thank you for WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
challenge. I hope it's been informative for you and I'd like to thank you for