So friends, let's walk through the validation challenge.
So the very first thing that we're going to have to do is to define a DNS
server of 8.8.8.8.8
and the host variable file for the first managed device in the inventory.
So in my inventory right here, my first device is Blue Box.
So I'll go into my blue box dot yml.
And what I have to do is to go into insert mode, have my three hyphens at the
top,
and then define my DNS server.
So I'm going to say is DNS hyphen servers.
And I'm going to actually make this plural because even though I don't happen WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And I'm going to actually make this plural because even though I don't happen
to have
multiple DNS servers, but as a possibility for expansion in the future.
And more importantly, the keys have to be consistent across the different files
.
That is if we're going to call the same key from the same template.
So I'm just going to use DNS servers plural.
Then I'll have my hyphen and specify 8.8.8.8.
So like I say, there's only one value in this particular array at this moment
in time.
So let's write in quits.
And now going to the second managed device now in this particular file here,
we have to define two DNS servers of 8.8.8.8.8 and 8.8.4.4. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we have to define two DNS servers of 8.8.8.8.8 and 8.8.4.4.
So we're going to insert mode once again, have our three hyphens at the top,
use the same key, which is DNS underscore servers once again plural.
And then we'll have an array object and specify all the aids for the first
server.
And then below we'll have 8.8.4.4.
If I press escape colon, write and quits.
That is the first portion of the validation done.
The next thing we're going to have to do is to write a ginger two template
called validation dot j2 that's going to render the DNS configuration WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
called validation dot j2 that's going to render the DNS configuration
for each device's etzer resolve dot conf configuration file.
So if I go back and I go into my templates directory,
I'm going to create one called validation dot j2.
And let's just go in and modify this now.
Now in this case here, what I want to do is to invoke a loop
because we can have multiple DNS servers.
So I'm going to insert mode.
I'm not going to use my three hyphens at the top because we're not dealing
with the yaml file now.
What I will do is have my curly brace and then my percentage sign
to indicate my control.
And then I will just say four and create a name for a variable. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And then I will just say four and create a name for a variable.
I should say server and then we specify the DNS servers key.
Again, this is why we want to have the same key consistent across both files.
And then I'll have my percentage sign and then curly brace.
And all I'm going to do here is say name server.
And then use my double curly braces here and populate the variable value.
So I'll just have server in here.
And then what I'm going to have to do, I'm going to have to close off this for
loop
by saying end for perfect.
So if I just escape colon, write and quit. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So if I just escape colon, write and quit.
The next thing I'm going to have to do is to write an answerable playbook
that is going to target all the devices in the inventory.
So let's go back a directory and I'll just say them validation dot yml.
Again, call this playbook, enter new so wish.
I'm going to insert mode.
Now we'll have my three hyphens.
We're back using yml once again.
And at the very top, I'm going to have my hyphen and then specify a name for
this play.
I'll just say validation for templates.
Okay, call this the important part here is that we target the hosts of the all
group. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
group.
And now I'm going to define my tasks.
So hyphen name and the name of the task will just be render conflicts.
And now I'm going to use the answerable built in template module.
So what's the source going to be?
Well, the actual file we're going to use this time is going to be validation J2
and the
destination.
But what does it actually specify?
As per the instruction, the destination file should be called it say resolve
dot com dot
backup or not actually wanting to modify the real configuration file.
So in this case here, I will say forward slash it say forward slash resolve dot WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So in this case here, I will say forward slash it say forward slash resolve dot
com dot backup
here.
Okay.
So what that now done, all I will do is press escape colon wq write and quit
and I will
say answerable hyphen playbook validation and hit enter.
Now because you the changes have been made, let's go to our devices to verify.
So if I say cat, it say resolve dot com dot backup and I enter as we can see
here, the
yellow box has name server eight dot eight dot eight dot eight and name server
eight dot
eight dot four dot four.
Now if we go to the blue box here, if we go into it say resolve dot com dot WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now if we go to the blue box here, if we go into it say resolve dot com dot
backup and to
enter, as we can see here, the configuration has been rendered name server
eight dot eight
dot eight.
So that is us for our validation challenge for gender templating.
I hope it's been informative for you and I'd like to thank you for viewing.