1 00:00:00,760 --> 00:00:07,360 In this video, we are going to learn all the additional commands that are available within Ansible. 2 00:00:07,630 --> 00:00:13,960 Ansible software comes with additional resources and we can utilize those resources through built in 3 00:00:13,960 --> 00:00:17,170 commands that comes with ANSIBLE software. 4 00:00:17,680 --> 00:00:23,890 Following are the list or the list that we will go over with Ansible commands as of now. 5 00:00:23,890 --> 00:00:30,940 So when I put it down as of now, meaning at this time while I'm doing this recording, all these commands 6 00:00:30,940 --> 00:00:37,990 are available and can be used, but maybe a month, a year from now and you're watching this video, 7 00:00:37,990 --> 00:00:43,570 maybe a few commands have are added to it or some of the commands have been deprecated. 8 00:00:44,140 --> 00:00:51,460 So anyway, the most famous three commands that we have already covered, one of them is Ansible, just 9 00:00:51,460 --> 00:00:52,690 the name Ansible. 10 00:00:52,690 --> 00:00:58,750 We ran this command many times, a few times when especially when we ran the ad hoc command. 11 00:00:58,750 --> 00:01:00,430 So you are very familiar with that. 12 00:01:00,430 --> 00:01:08,260 The next command, which is used the most, and we have used this command the most throughout this course, 13 00:01:08,260 --> 00:01:10,120 and that is Ansible Dash playbook. 14 00:01:10,450 --> 00:01:17,980 We ran this command when we created a playbook and we run this command with the option of a playbook. 15 00:01:18,790 --> 00:01:22,920 All right, then we have a command which we learned later on, which is Ansible Dash. 16 00:01:23,070 --> 00:01:26,200 What this command is used to. 17 00:01:26,210 --> 00:01:32,590 When you want to secure your environment, more specifically, you want it to secure your playbook or 18 00:01:32,590 --> 00:01:35,140 you want it to secure a string. 19 00:01:35,590 --> 00:01:35,980 All right. 20 00:01:35,980 --> 00:01:40,660 So these are the three main commands that we learn so far in this entire course. 21 00:01:40,660 --> 00:01:45,520 And you will be using, I will tell you, 95% of the time, only these commands. 22 00:01:45,640 --> 00:01:45,940 All right. 23 00:01:45,940 --> 00:01:52,000 So here are the other 5% of the commands that you could use and you might find them useful. 24 00:01:52,960 --> 00:01:55,510 The first one is ansible config. 25 00:01:55,600 --> 00:02:03,940 You will use that very rarely or maybe one time to do the configuration this shows or modifies ansible 26 00:02:03,940 --> 00:02:04,990 configuration. 27 00:02:05,290 --> 00:02:09,100 Not all configuration options are present in the command line. 28 00:02:09,100 --> 00:02:16,840 Just the ones deemed most useful or common settings in the command line will override those paths through 29 00:02:16,840 --> 00:02:18,760 the configuration file and the environment. 30 00:02:18,760 --> 00:02:24,460 So if you do have the configuration file, which is ansible cfg, so pay close attention. 31 00:02:24,460 --> 00:02:30,370 The last line is settings in the command line will override those paths through the configuration, 32 00:02:30,370 --> 00:02:31,660 file and environment. 33 00:02:31,900 --> 00:02:38,080 By the way, all of these commands, you could get the additional information on these commands if you 34 00:02:38,080 --> 00:02:42,550 tied the command followed by the dash, dash or hyphen hyphen help. 35 00:02:43,300 --> 00:02:45,040 Then we have another command ansible. 36 00:02:45,040 --> 00:02:48,580 That's connection, connection command for the remote clients. 37 00:02:48,580 --> 00:02:52,540 And by the way, this command, I try to do a lot of research. 38 00:02:52,540 --> 00:02:57,760 I try to run this command many times to find out the exact purpose of it. 39 00:02:57,760 --> 00:03:02,710 I couldn't find a lot of help, but so far I know it's a command that can be used for remote clients 40 00:03:02,710 --> 00:03:04,930 and configuration moving on. 41 00:03:04,930 --> 00:03:06,910 And then we have Ansible console. 42 00:03:06,940 --> 00:03:16,360 Right now this Ansible console is somewhat, I would say, not clearly shown as to what it does, but 43 00:03:16,360 --> 00:03:19,300 so far that I have used this command, I see. 44 00:03:19,420 --> 00:03:22,000 I think this could do a lot more. 45 00:03:22,000 --> 00:03:29,560 And if you understand this commands, functions or how to use this command accurately. 46 00:03:29,560 --> 00:03:38,980 So this command allows for running ad hoc tasks against a chosen inventory from a nice shell with built 47 00:03:38,980 --> 00:03:40,270 in tap completion. 48 00:03:40,360 --> 00:03:46,570 It supports several commands and you can modify its configuration at runtime. 49 00:03:46,990 --> 00:03:51,250 You can run a name of the listed command followed by the help as well. 50 00:03:51,250 --> 00:03:58,360 So it's command, the option that are listed within this command and then the help to get more information. 51 00:03:58,360 --> 00:03:58,660 All right. 52 00:03:58,660 --> 00:04:00,700 So let's take a look if you want. 53 00:04:00,700 --> 00:04:07,690 If you run the command ansible dash console, it will bring you to its own built in menu. 54 00:04:07,780 --> 00:04:13,120 And within that menu you will get a list of additional commands that you could use as an option. 55 00:04:14,080 --> 00:04:19,600 You can run help followed by that option to get more information about that command. 56 00:04:19,600 --> 00:04:19,930 All right. 57 00:04:19,930 --> 00:04:25,630 So let me go into my Ansible control node and I'll show you while I'm explaining that right here is 58 00:04:25,630 --> 00:04:27,100 my Ansible control node. 59 00:04:27,100 --> 00:04:28,120 Let me log in. 60 00:04:30,870 --> 00:04:31,410 All right. 61 00:04:31,830 --> 00:04:37,350 I am logged in as rude, and I am in a slash root directory. 62 00:04:37,380 --> 00:04:37,860 All right, good. 63 00:04:37,890 --> 00:04:39,750 Let's go ahead and clear the screen. 64 00:04:39,780 --> 00:04:45,840 Now let's run the command ansible dash console and hit enter. 65 00:04:46,230 --> 00:04:53,220 And when you hit enter, you see it's telling you welcome to the Ansible console type help or question 66 00:04:53,220 --> 00:04:57,660 mark to list commands, the commands that will be used as an option for this command. 67 00:04:57,660 --> 00:05:00,060 So you could use help or question mark. 68 00:05:00,060 --> 00:05:03,150 Let's do help and you'll get a list of all the commands. 69 00:05:03,150 --> 00:05:10,050 Or you could say a modules that we could use for those commands that we could run inside of this command. 70 00:05:10,350 --> 00:05:13,530 So right here, for example, this is the DNF is the module. 71 00:05:13,530 --> 00:05:19,920 If you wanted to know more about this, you could do help DNF and you'll get all the information about 72 00:05:19,920 --> 00:05:21,270 what this module can do. 73 00:05:21,300 --> 00:05:25,950 You could read through it and understand what you could expect when you run the Help Command. 74 00:05:26,400 --> 00:05:26,940 All right. 75 00:05:27,660 --> 00:05:32,760 It's the next command you can see is if you want to copy a file on the remote client, you could just 76 00:05:32,760 --> 00:05:37,650 use the CPP, which is a shell command that you could use under more clients. 77 00:05:37,650 --> 00:05:44,460 And by the way, this will copy the file locally available under more client to its local location. 78 00:05:44,460 --> 00:05:52,890 So let's say if I go to my Linux machine right here and this is my control node and I will let me go 79 00:05:52,890 --> 00:05:55,620 back into Ansible Dash Console menu. 80 00:05:57,590 --> 00:06:04,790 And if I do keep that home so I keep temp ance. 81 00:06:06,050 --> 00:06:09,050 This is the file that I wanted to copy. 82 00:06:09,050 --> 00:06:14,060 So before I do that, I wanted to make sure this file exists in there are more clients. 83 00:06:14,060 --> 00:06:16,310 So here I am in temp directly. 84 00:06:17,600 --> 00:06:22,670 I see myself here in temp so I do not see an s file file. 85 00:06:22,670 --> 00:06:23,990 So let me clear the screen. 86 00:06:23,990 --> 00:06:29,540 I will just simply touch in five. 87 00:06:29,540 --> 00:06:30,770 The file is created. 88 00:06:30,770 --> 00:06:40,730 Now if I come back to the Ansible control node then I could use CP the shell command and do slash temp 89 00:06:40,730 --> 00:06:48,770 ans, which is the source and the destination is I so and it should copy on to your. 90 00:06:48,770 --> 00:06:57,860 If you go to Linux client and you go to home, I absol you will see the file file has been copied over. 91 00:06:58,520 --> 00:06:59,360 See you right here. 92 00:06:59,780 --> 00:07:00,470 There you go. 93 00:07:01,040 --> 00:07:04,040 See, that's what you could use if you wanted to use a shell command. 94 00:07:04,040 --> 00:07:10,700 Now there are many other commands and modules that you could use within this console. 95 00:07:10,700 --> 00:07:16,400 I haven't tested every one of them, but I will definitely encourage you to go ahead and test and see 96 00:07:16,400 --> 00:07:21,560 if you could run these ad hoc commands within this menu. 97 00:07:21,560 --> 00:07:23,270 And that is easier for you. 98 00:07:23,270 --> 00:07:30,680 Or simply just running the Ansible command with the ad hoc parameters is easier for you. 99 00:07:31,130 --> 00:07:31,640 All right. 100 00:07:31,640 --> 00:07:39,860 Anyway, so there are certain commands which are misleading in Ansible dash console, for example, 101 00:07:39,860 --> 00:07:43,820 CD, which changes the host instead of changing the directory. 102 00:07:43,820 --> 00:07:49,580 So, so here this is the CD command inside of Ansible Dash Console. 103 00:07:49,580 --> 00:07:55,190 That's another one that I checked and I notice this CD does not mean that you wanted to change the directory. 104 00:07:55,190 --> 00:07:57,020 It means changing the host. 105 00:07:57,530 --> 00:08:00,320 All right, so that's that's about ansible console. 106 00:08:00,350 --> 00:08:02,210 The next one is Ansible Dock. 107 00:08:02,210 --> 00:08:03,470 Ansible Dash Dock. 108 00:08:03,500 --> 00:08:09,050 You can access manual on plug ins and module through this command if you need any information. 109 00:08:09,050 --> 00:08:15,500 So one of the modules or one of the command that I mostly run is Ansible Dash Doc minus L, which lists 110 00:08:15,500 --> 00:08:19,100 all the modules that I have available out of the box. 111 00:08:19,100 --> 00:08:23,720 So here is my client control node. 112 00:08:23,720 --> 00:08:32,510 Let's clear the screen and if I want to get Ansible Dash Doc and a list of all the modules here I have 113 00:08:32,510 --> 00:08:38,810 all the lists you can hit, enter or hit spacebar to go one page at a time and you'll get information 114 00:08:38,810 --> 00:08:43,190 about every module and a short description of that module. 115 00:08:43,760 --> 00:08:44,990 All right, good. 116 00:08:44,990 --> 00:08:47,510 Moving on, then we have Ansible Galaxy. 117 00:08:47,510 --> 00:08:53,930 That's another command, a command to manage Ansible roles and shared repository, the default of which 118 00:08:53,960 --> 00:08:59,390 is Ansible Galaxy, ACP Call and slash slash galaxy does ansible. 119 00:08:59,390 --> 00:09:04,070 By the way, all of these commands that I'm showing you and giving you all the information about you 120 00:09:04,070 --> 00:09:10,370 could get the list of all these additional commands of Ansible by going into control node, and you 121 00:09:10,370 --> 00:09:17,150 could just type simply Ansible and hit tab twice and you will get see these are the list of all the 122 00:09:17,150 --> 00:09:19,640 commands that are available right now. 123 00:09:20,060 --> 00:09:26,990 As I said, you could see some of them being deprecated or a few new of them will be added depending 124 00:09:26,990 --> 00:09:28,520 on how the project goes. 125 00:09:29,770 --> 00:09:35,080 The next command we will cover is Ansible Dash inventory, which we slightly touched on when we were 126 00:09:35,080 --> 00:09:44,330 talking about adding our remote or hosts our clients to the Etsy's host file to create our inventory. 127 00:09:44,330 --> 00:09:50,650 We are using the Ansible Dash Inventory Command provides you with the details of your hosts inventory 128 00:09:50,650 --> 00:09:51,250 files. 129 00:09:51,250 --> 00:09:56,680 It can be useful if you want to get an idea of how your hosts are grouped or grouped. 130 00:09:56,680 --> 00:10:03,070 For example, run the following command ansible dash inventory minus EI option host SpaceX dash dash 131 00:10:03,070 --> 00:10:03,720 graph. 132 00:10:03,730 --> 00:10:14,470 Let me go to my control node and I will run this command and simple dash inventory dash I for host dash 133 00:10:14,470 --> 00:10:16,030 dash graph. 134 00:10:18,450 --> 00:10:26,550 All right, so right here, you see, I have everything as under all just one host that what I have 135 00:10:26,550 --> 00:10:31,850 in the host file and there is nothing under Uncropped category. 136 00:10:31,860 --> 00:10:32,220 All right. 137 00:10:32,220 --> 00:10:40,020 So then what we could do also to get a list of all hosts in your host file, you can run the same command 138 00:10:40,020 --> 00:10:42,300 with the option dash dash list. 139 00:10:42,300 --> 00:10:43,740 It's just that simple. 140 00:10:43,770 --> 00:10:49,260 Hit up arrow key, get rid of all the other option and do a dash dash list. 141 00:10:49,620 --> 00:10:55,050 And you will see it will give me all the hosts that I have in the host file. 142 00:10:55,050 --> 00:10:59,100 I have only one and it's showing me the IP address of that one remote client. 143 00:10:59,100 --> 00:11:03,900 There isn't anything under on grouped category. 144 00:11:04,380 --> 00:11:04,740 All right. 145 00:11:04,740 --> 00:11:08,280 So also one more thing I wanted to tell you before I move on. 146 00:11:08,280 --> 00:11:17,700 You could get the the help or the additional options of a command by simply running ansible dash inventory 147 00:11:17,700 --> 00:11:19,380 or any other command for that matter. 148 00:11:19,380 --> 00:11:25,620 You could do help and you will see that it has the list of all the options that are available to you. 149 00:11:25,620 --> 00:11:30,960 You could try each one of them one by one, and see which one is useful for you. 150 00:11:31,200 --> 00:11:35,670 So these were the additional commands that I wanted to cover in this video. 151 00:11:35,880 --> 00:11:42,750 As I said initially, almost 95% of the time you will be using those main two commands. 152 00:11:42,750 --> 00:11:47,880 One is the Ansible and the second one is Ansible Dash playbook. 153 00:11:47,970 --> 00:11:54,120 And those commands are very useful to do all the work that you need to do for automation. 154 00:11:54,480 --> 00:12:00,450 All of these other commands, you could get a lot more information about it through Ansible documentation. 155 00:12:00,450 --> 00:12:07,770 So I will definitely recommend you that you please go to that website and find out what other information 156 00:12:07,770 --> 00:12:11,490 that is available to you regarding these additional commands.