In this video, we will write a playbook or a second playbook of this course that is going to output
something that you wanted to write and then you want it to output to the screen.
So this playbook will print.
Hello World Unlock Local Host.
I'm sure every time you learn a new language there is one thing they always ask you to learn is how
you could print something on the screen and most likely it will be Hello World.
Same way I'm following the same routine or same ritual and we will create an ansible playbook that will
output hello world on the screen.
So the very first thing we'll do is we'll go into our Etsy Ansible Playbook directory and we will create
a new file called Hello World YAML File.
We'll use the editor then once we are inside of editor will define hyphen, hyphen, hyphen or dash
dash dash that will signify or will identify that it's a YAML file.
Then we will put in hyphen space and name colon space.
My second playbook or any name of the playbook.
You can also put down the output playbook.
So this is going to be the name of the play or playbook.
Then we'll define the host where is going to be run a guest.
So we'll go through local host again.
This will run on local host.
Then the tasks run the following task and the name of the task would be print Hello World.
All right.
What would be the next step in the task that you wanted to do?
Of course you need to pick the module, the module that will actually execute your task and the module
name for printing something on the screen will be debug.
And you have to define its option of a message equal.
Double coat.
Hello world and double coat clothes.
This run de bag module will print statement during execution and then we'll run this ansible playbook
by running the command ansible playbook.
Hello world by eml or yaml file.
It's just that simple.
This is our second playbook.
So we all taking baby step one small playbook at a time.
All right, so let's log in to my Linux machine, which is right here, and we will go to.
Our At Sea and Sybil playbook.
Our playbooks actually, because we have multiple playbooks in this directory.
So it's just a little slide mistakes anyway.
Hit enter.
We are in playbooks directory now.
We will before we do them.
Hello world let's do ls minus l.
And we'll notice that we only have one playbook in it, which is the one we created earlier.
Now we are going to create a second one, so we'll do them.
Hello world dot yaml.
All right.
We are inside of the editor.
That's.
Define our ID.
That's a YAML file.
Dash, dash, hit.
Enter Dash.
Again, space name colon.
My second play book or any name that you wanted to give.
All right.
As soon as you hit Enter, you'll see your cursor automatically comes right below the end letter with
the correct indentation hosts.
Where do you want to run this playbook against?
Local host.
All right.
Give an empty line to keep it well-organized.
Now, task.
Hit Enter.
Dash space name.
What is the name of this task?
It is going to print hello world.
Right.
And what is the module that you will be using that will help you print that?
Hello world.
The module will be debug.
And MSG is the message that will print and it will be hello world.
Now if you are thinking Imran, how do you know that you will have to use the debug module and then
you will use the option message?
Well again there is a list, a huge list of modules that you could get from Ansible documentation.
Once you find the right module, then within the module you'll find all the different options that is
available to you.
All right.
So our second playbook is done.
Beautiful.
Let's save our playbook, our file that is created.
Now, let's run it.
Ansible Dash.
Playbook and the name of our playbook which is hello world are yaml and hit enter.
All right.
It is giving us provided homeless is empty.
This is just a warning sign which is again telling us that there is nothing in the host file which is
Etsy Ansible Host That is fine.
So it's going to use local.
Host All right.
So it went to the local host play my second playbook.
It did task on the local host and task is to print hello world.
And the message came out to be Hello World.
Excellent.
So you have just created your second playbook to output something, whatever you want to do onto the
screen.
So if you want to output the same thing to or output anything to multiple remote clients, you could
use that same playbook and define an Etsy host Etsy Ansible host file, which clients you want to display
it on?
All right.
That's how we run the second one.
I'll see you in the next lecture where we will learn additional playbooks.