In this video, we will look at a little more on integrated details about how Ansible works and how you use it in an environment. As I mentioned earlier, you set up a control machine where you install Ansible and the various modules that you want to use and you write your YAML files, which are basically playbooks with the set of instructions that are to be executed. Every time you run a playbook, it is called as a play, you can decide on which collection of servers it has to be executed. Ansible can be used to execute a variety of either ad hoc commands or orchestrated playbooks or predefined set of instructions that you want to execute. All of them, do using SSH login into the host in which you want to perform the operations. It uses SSH by default but you can enable Kerberos authentication or any other supported authentication mechanism, because when a program has to be executed on another computer, this computer should be able to login to the other server and perform operations. Depending on the type of OS and what Ansible supports, you can identify different means of doing that. The inventory is the crux of the whole execution and inventory is fundamentally a collection of hosts in Ansible. You create a file, which we will come in to later as to where it is located, in which you give the list of host names or IP addresses, and you can group them into a collection of hosts so that when you are performing an operation as a playbook execution or an ad hoc command execution. You can tell on which collection of hosts you want them to be executed. Let me go to the slide where we have an example here. What is given here is, I have a simple playbook wherein I want to install and start Apache on a collection of hosts. Which host do I want to execute? I have given here a name called webservers. Which are the hosts which are part of webservers? In general, the default inventory file in Ansible in a server is located under the Ansible directory under etc. in the host file, wherein you can have various servers written and grouped into a particular collection. In this example, webservers is here, maybe you can have database set of words or applications set of words, whatever you want, or you can change the location where the host file is kept by configuring Ansible. But by default, this is the location where Ansible host file is kept, which is called as the inventory of hosts and when you run a command in Ansible, you decide where to run it. That's the idea about how Ansible works at a high level. For the simple reason that Ansible is going to execute on specific host, you need to have the SSH key of the private key available on the Ansible control machine so that we can use that to login to the remote host. If you are executing a command which is connecting to a server for the first time, typically you will get a pop-up saying, do you want to surely connect? That's called as a host key check and if you want to disable it, you can configure Ansible to tell, do not worry about doing that check. So, we know inventory is the location of all the hosts in the host file. You can have a dynamic list of hosts in which you want to execute or a predefined collection. A Task is a call to an Ansible module. For example, you might want to download something from YAML and install it, start or stop a set of service or manually install a software. Each module is collection of commands pertaining to a particular operation. There are various Ansible modules predefined and given and Cloud providers give you Ansible modules to manage infrastructure. A Play is an execution of a Playbook. A Playbook is written in YAML where you have a collection of Plays, wherein you could use tasks and roles mapped based on a directory structure and beside, how they have to be executed. Remember, this is a configuration management tool, so you need to give the instructions in the order in which they have to be executed to get a desired output. Ansible will not be able to figure out on its own the right order. The way you write your playbook has to be in the intended order in which they have to be executed. Thus, we come to the slide where I showed earlier. Host parameter tells which collection of hosts you want this to run and an example of the task and which module is being used. Yum is the module which will look up for this particular software to be downloaded, state equal the present meaning, get the latest version and name. Start httpd is a name I've given to this task where in the module, use the service is to start this particular service in a computer. This is an example of a collection of commands you have written as a Playbook, you can include as many tasks, but ensure you cannot write it in the reverse order. If you start and then followed by installing, obviously, the start will fail without the software being installed. As we saw earlier, the host file is where the inventory is created with a list of computers which you want Ansible to execute on and with Ansible, you have two types of operations that you can do. The first one is ad hoc commands. When we say ad hoc commands, it is just that you want to run a particular command on a collection of hosts. Let's say, you just want to see what are the version of a software written or installed in a particular group of hosts, maybe, a website or something that you can write an ad hoc command and get it executed. Of course, SSH keys are required and you can disable host key checking as I told you earlier, this is the parameter in Ansible configuration file which you can set up. Some examples of ad hoc commands are given here. Look at this, I don't have a YAML file. I use Ansible executable on a particular control server, tell the list of servers in which I want this particular command to be run, a shell command to touch and create a file or a yum command to install a particular software, start a service. Remember, in an ad hoc command, one command is executed at a time, if you want a collection of commands to be executed, then you write a playbook using the YAML construct. Each of these are specific modules ; shell command module, package management, managed services, these are all built-in modules that come as part of Ansible. Some typical problems one might have when using Ansible is given here. If you don't have the private key of the SSH key pair on the control machine, obviously you are not having the means to get authenticated and an example of where the host key checking was not disabled. Hence, when you're trying to perform an operation, it gives this. You can very well disable this in Ansible in its configuration as we saw earlier to disable host key checking by setting it to false. When we look at Playbooks, the whole idea behind Playbooks is to write a collection of commands and to quickly understand what we are doing in this example, we have decided we are going to run a collection of commands in the webservers. In the inventory, you should have had a collection of nodes, group tasks webservers. An example that we already saw, here is the two IP addresses given. What do we want to do there? We want to have two variables declared as http_port and max_clients. Take remote access as the root user and install the latest version of httpd software, which is the web server to the latest state, that is what is given in this example. You can have more commands in the form of individual instructions that can be given, through which you can execute it on a collection of servers and get your configuration management done. That's the overview about how Ansible works.