1 00:00:00,980 --> 00:00:08,180 In this video, we will write a playbook or a second playbook of this course that is going to output 2 00:00:08,180 --> 00:00:12,830 something that you wanted to write and then you want it to output to the screen. 3 00:00:13,220 --> 00:00:15,950 So this playbook will print. 4 00:00:15,980 --> 00:00:19,160 Hello World Unlock Local Host. 5 00:00:19,400 --> 00:00:25,850 I'm sure every time you learn a new language there is one thing they always ask you to learn is how 6 00:00:25,850 --> 00:00:30,680 you could print something on the screen and most likely it will be Hello World. 7 00:00:30,710 --> 00:00:39,980 Same way I'm following the same routine or same ritual and we will create an ansible playbook that will 8 00:00:39,980 --> 00:00:42,260 output hello world on the screen. 9 00:00:43,070 --> 00:00:51,110 So the very first thing we'll do is we'll go into our Etsy Ansible Playbook directory and we will create 10 00:00:51,110 --> 00:00:53,990 a new file called Hello World YAML File. 11 00:00:54,500 --> 00:01:04,370 We'll use the editor then once we are inside of editor will define hyphen, hyphen, hyphen or dash 12 00:01:04,370 --> 00:01:11,300 dash dash that will signify or will identify that it's a YAML file. 13 00:01:11,630 --> 00:01:18,710 Then we will put in hyphen space and name colon space. 14 00:01:18,890 --> 00:01:23,480 My second playbook or any name of the playbook. 15 00:01:23,480 --> 00:01:26,450 You can also put down the output playbook. 16 00:01:26,450 --> 00:01:29,510 So this is going to be the name of the play or playbook. 17 00:01:29,510 --> 00:01:33,530 Then we'll define the host where is going to be run a guest. 18 00:01:33,530 --> 00:01:36,650 So we'll go through local host again. 19 00:01:37,550 --> 00:01:39,530 This will run on local host. 20 00:01:39,530 --> 00:01:46,790 Then the tasks run the following task and the name of the task would be print Hello World. 21 00:01:46,790 --> 00:01:47,420 All right. 22 00:01:47,420 --> 00:01:51,410 What would be the next step in the task that you wanted to do? 23 00:01:51,950 --> 00:02:00,560 Of course you need to pick the module, the module that will actually execute your task and the module 24 00:02:00,560 --> 00:02:05,390 name for printing something on the screen will be debug. 25 00:02:06,160 --> 00:02:12,370 And you have to define its option of a message equal. 26 00:02:13,310 --> 00:02:14,300 Double coat. 27 00:02:14,330 --> 00:02:17,300 Hello world and double coat clothes. 28 00:02:17,300 --> 00:02:25,580 This run de bag module will print statement during execution and then we'll run this ansible playbook 29 00:02:25,580 --> 00:02:28,190 by running the command ansible playbook. 30 00:02:28,220 --> 00:02:31,550 Hello world by eml or yaml file. 31 00:02:31,550 --> 00:02:32,930 It's just that simple. 32 00:02:32,930 --> 00:02:34,670 This is our second playbook. 33 00:02:34,670 --> 00:02:39,080 So we all taking baby step one small playbook at a time. 34 00:02:39,560 --> 00:02:45,680 All right, so let's log in to my Linux machine, which is right here, and we will go to. 35 00:02:46,510 --> 00:02:51,400 Our At Sea and Sybil playbook. 36 00:02:52,320 --> 00:02:57,960 Our playbooks actually, because we have multiple playbooks in this directory. 37 00:02:57,960 --> 00:03:00,730 So it's just a little slide mistakes anyway. 38 00:03:00,810 --> 00:03:01,350 Hit enter. 39 00:03:01,350 --> 00:03:04,050 We are in playbooks directory now. 40 00:03:04,050 --> 00:03:06,780 We will before we do them. 41 00:03:06,810 --> 00:03:09,150 Hello world let's do ls minus l. 42 00:03:09,830 --> 00:03:14,910 And we'll notice that we only have one playbook in it, which is the one we created earlier. 43 00:03:14,930 --> 00:03:18,170 Now we are going to create a second one, so we'll do them. 44 00:03:18,950 --> 00:03:21,950 Hello world dot yaml. 45 00:03:22,700 --> 00:03:23,090 All right. 46 00:03:23,090 --> 00:03:25,580 We are inside of the editor. 47 00:03:25,580 --> 00:03:25,970 That's. 48 00:03:25,970 --> 00:03:28,610 Define our ID. 49 00:03:28,610 --> 00:03:29,880 That's a YAML file. 50 00:03:30,050 --> 00:03:31,610 Dash, dash, hit. 51 00:03:31,610 --> 00:03:33,080 Enter Dash. 52 00:03:33,080 --> 00:03:36,350 Again, space name colon. 53 00:03:36,350 --> 00:03:42,980 My second play book or any name that you wanted to give. 54 00:03:43,400 --> 00:03:43,880 All right. 55 00:03:43,880 --> 00:03:50,870 As soon as you hit Enter, you'll see your cursor automatically comes right below the end letter with 56 00:03:50,870 --> 00:03:53,530 the correct indentation hosts. 57 00:03:53,540 --> 00:03:57,350 Where do you want to run this playbook against? 58 00:03:58,910 --> 00:03:59,840 Local host. 59 00:04:01,310 --> 00:04:02,030 All right. 60 00:04:02,240 --> 00:04:06,380 Give an empty line to keep it well-organized. 61 00:04:06,420 --> 00:04:07,580 Now, task. 62 00:04:09,260 --> 00:04:10,100 Hit Enter. 63 00:04:10,310 --> 00:04:12,590 Dash space name. 64 00:04:12,590 --> 00:04:16,460 What is the name of this task? 65 00:04:16,490 --> 00:04:20,030 It is going to print hello world. 66 00:04:20,290 --> 00:04:21,090 Right. 67 00:04:21,110 --> 00:04:26,930 And what is the module that you will be using that will help you print that? 68 00:04:26,930 --> 00:04:27,710 Hello world. 69 00:04:27,740 --> 00:04:29,840 The module will be debug. 70 00:04:31,350 --> 00:04:38,160 And MSG is the message that will print and it will be hello world. 71 00:04:38,160 --> 00:04:43,200 Now if you are thinking Imran, how do you know that you will have to use the debug module and then 72 00:04:43,200 --> 00:04:46,170 you will use the option message? 73 00:04:46,170 --> 00:04:53,100 Well again there is a list, a huge list of modules that you could get from Ansible documentation. 74 00:04:53,100 --> 00:04:58,380 Once you find the right module, then within the module you'll find all the different options that is 75 00:04:58,380 --> 00:04:59,280 available to you. 76 00:04:59,580 --> 00:04:59,940 All right. 77 00:04:59,940 --> 00:05:02,430 So our second playbook is done. 78 00:05:02,490 --> 00:05:03,120 Beautiful. 79 00:05:03,120 --> 00:05:08,370 Let's save our playbook, our file that is created. 80 00:05:08,370 --> 00:05:09,720 Now, let's run it. 81 00:05:09,720 --> 00:05:12,120 Ansible Dash. 82 00:05:13,110 --> 00:05:20,040 Playbook and the name of our playbook which is hello world are yaml and hit enter. 83 00:05:21,410 --> 00:05:22,160 All right. 84 00:05:22,160 --> 00:05:24,850 It is giving us provided homeless is empty. 85 00:05:24,860 --> 00:05:31,610 This is just a warning sign which is again telling us that there is nothing in the host file which is 86 00:05:31,610 --> 00:05:33,680 Etsy Ansible Host That is fine. 87 00:05:33,680 --> 00:05:34,820 So it's going to use local. 88 00:05:34,820 --> 00:05:35,810 Host All right. 89 00:05:35,810 --> 00:05:39,590 So it went to the local host play my second playbook. 90 00:05:39,590 --> 00:05:43,820 It did task on the local host and task is to print hello world. 91 00:05:43,820 --> 00:05:46,310 And the message came out to be Hello World. 92 00:05:46,520 --> 00:05:47,540 Excellent. 93 00:05:47,540 --> 00:05:56,510 So you have just created your second playbook to output something, whatever you want to do onto the 94 00:05:56,540 --> 00:05:58,010 screen. 95 00:05:58,310 --> 00:06:06,110 So if you want to output the same thing to or output anything to multiple remote clients, you could 96 00:06:06,110 --> 00:06:13,640 use that same playbook and define an Etsy host Etsy Ansible host file, which clients you want to display 97 00:06:13,640 --> 00:06:14,180 it on? 98 00:06:14,540 --> 00:06:15,170 All right. 99 00:06:15,170 --> 00:06:17,390 That's how we run the second one. 100 00:06:17,390 --> 00:06:21,830 I'll see you in the next lecture where we will learn additional playbooks.