Okay friends, so let's walk through the solution then.
So what I will do here is make sure I'm in my home directory.
What I'm going to do is I'm going to create a directory simply called rows
because as we recall in my Ansible CSG file,
I actually have my rows here as part of my path.
Okay, this is going to be a place where Ansible looks for these rows.
So if I go into the rows directory right here,
in order to generate the directory skeleton,
I will say Ansible Galaxy, roll a net,
and then I'll give the name of my row.
So it's going to be called a welcome row.
So if I hit enter, now the row has been created, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So if I hit enter, now the row has been created,
we can see it's right here.
If I go into this directory structure and I just do a tree,
we see we have all of our necessary files.
Now the row is really quite simple.
We're going to just render a simple template
and then a reference that template within a task.
So like I say here, we have this templates directory.
This is a good place because this is where we can use our actual template.
Let's create a little template, let's just call this,
or let's just say welcome.j2.
So that's going to insert mode.
And all I'm going to have to say here is hello,
my name is and then specify the name of the device within the Ansible inventory WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
my name is and then specify the name of the device within the Ansible inventory
.
So I can use my double curly braces and then say,
inventory_hostname.
And then I'll just say welcome to RHC.
So if I just write this out and quit,
if I now go back and I now go into my tasks folder here to actually invoke a
task,
we have this main.yml file, let's go in and modify this,
go into insert mode.
And all I will do here is give this little task a name.
I'll just say render a welcome message. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I'll just say render a welcome message.
So I will use the Ansible built-in template module right here.
Now recall, if we don't remember how to actually use this, what can we do?
We can say Ansible.dulk, Ansible built-in template.
And to insert, we access to this documentation,
we can see all the ways we can use this if we scroll all the way down,
we come to some examples right here,
so we can actually just copy this if we so wish,
or just copy here.
And let's just paste this in here actually, keep thinking this in simple.
So I've already created the name and referenced the actual modules,
let's delete these parts right here.
And now I have all of my available parameters.
Now what I want to do here is I want to specify the actual source. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now what I want to do here is I want to specify the actual source.
Now by default Ansible, we'll look for the file within the template directory.
So I'll just specify the name of the actual template,
which is going to be called a welcome.j2.
Now in the case of the owner, the group in the mode,
we're not actually concerned about that right now,
so we'll leave the defaults.
And recall, where about do we actually have to write this to on our target
devices?
Well, I'm going to target the temp directory,
and the filter be called welcome.txt.
So with that now done, we have written our template,
we have created our task, we want to tie this together with then an actual WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we have created our task, we want to tie this together with then an actual
playbook.
So let me go back to my main directory right here,
I'll just now recall this welcome play dot yml, going to insert mode,
have our three hyphens at the very top.
I'll just say using my welcome role.
Now who the host I'm going to target,
in this case here, I'll target the all group.
Once again, I'll set gather facts to be false.
And now all I have to do is to specify the roles I want to use.
I'll use the keyword roles and then a list object to determine which roles I
want to include.
Now in this case here, it's only going to be a one role,
which is in fact simply called welcome role. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
which is in fact simply called welcome role.
So if I just save this, and if I just say,
"answerableplaybook" will come play dot yml, and to enter,
now we're going to use the welcome role, and it seems to be actually have made
a change.
Now I can log into all devices, but in order to just check things really
quickly,
what I can do is also to say, "answerable all" dash a,
and then I can just attempt to cat that particular fair,
which is forward slash tmp forward slash welcome dot txt.
If I enter, we log in to our devices.
And as we can see here, we can see the content here as device number two, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And as we can see here, we can see the content here as device number two,
it's been rendered as hello, my name is device two, welcome to RHCE.
And then we have device number one, hello, my name is device one, welcome to R
HCE.
So we did correctly render the templates and populate the value with the
inventory name
of the device itself with an answerable.