Automation with Ansible Playbooks - Hands On !! | Shikhar Verma | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Automation with Ansible Playbooks - Hands On !!

teacher avatar Shikhar Verma, Solution Architect

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

67 Lessons (6h 31m)
    • 1. Course Preview

      3:43
    • 2. Introduction Ansible

      4:48
    • 3. What is Ansible?

      3:03
    • 4. Ansible limitations

      1:36
    • 5. Ansible Architecture

      4:37
    • 6. Ansible Setup

      1:59
    • 7. Practice Lab Session

      3:06
    • 8. Recap

      1:08
    • 9. Ansible Control Node Components

      4:30
    • 10. Control & Managed Node

      3:06
    • 11. Ansible Inventories

      9:34
    • 12. Ansible Installation - Lab 1

      4:30
    • 13. Ansible Installation - Lab 2

      8:09
    • 14. Ansible Installation - Lab 3

      9:34
    • 15. Ansible Installation - Lab 4

      3:13
    • 16. Customize Ansible behaviour

      4:30
    • 17. Lab Session on Privilege Escalations

      8:35
    • 18. AD Hoc - Practice Lab Session - 1

      9:04
    • 19. AD Hoc - Practice Lab Session - 2

      7:56
    • 20. AD Hoc-Practice Lab Session - 3

      4:08
    • 21. Command & Shell Module Differences

      2:54
    • 22. Implementing Playbooks

      8:12
    • 23. Lab-Implementing Playbooks

      6:19
    • 24. Playbook for copying a file

      5:21
    • 25. Lab on copy a file with conditions

      5:39
    • 26. Introduction of Modules in Ansible

      8:12
    • 27. Lab-Invoking Modules

      8:44
    • 28. Idempotent Behaviour of Modules

      3:13
    • 29. Lab-Idempotent Behaviour of Modules

      8:13
    • 30. Multiple tasks in Ansible Playbook

      4:00
    • 31. Lab - Multi task Playbook - 1

      11:49
    • 32. Lab - Multi task Playbook - 2

      7:19
    • 33. Syntax Verification & Dry Check for Ansible Playbook

      4:14
    • 34. Apache Web Server Installation - 1

      4:00
    • 35. Apache Web Server Installation - 2

      11:49
    • 36. Apache Web Server Installation - 3

      7:19
    • 37. Managing Variables in Ansible

      4:42
    • 38. Lab-Managing Variables

      7:14
    • 39. Hosts & Group variables

      3:39
    • 40. Lab on Host & Group Variables

      6:30
    • 41. Lab on Variables

      7:22
    • 42. Ansible Facts

      7:00
    • 43. Conditionals in Ansible

      4:04
    • 44. Lab on Conditionals in Ansible

      8:36
    • 45. Ansible loops - when, when_items etc

      8:19
    • 46. Examples of Ansible Loops

      2:57
    • 47. Ansible Handlers

      2:23
    • 48. Lab on Ansible Handlers

      2:32
    • 49. About Ansible Roles

      4:48
    • 50. Create Ansible Roles

      5:20
    • 51. Lab 1 on Roles

      12:46
    • 52. Lab 2 on Roles

      4:29
    • 53. Overview about Patching on Linux Server

      3:03
    • 54. Lab 1 - Patching using Ansible playbook

      8:35
    • 55. Lab 2 - Patching using Ansible playbook

      3:38
    • 56. Lab 3 - Patching using Ansible playbook

      2:50
    • 57. Lab 4 - Patching using Ansible playbook

      3:50
    • 58. Lab 5 - Patching using Ansible playbook

      6:13
    • 59. Lab 6 - Patching using Ansible playbook

      7:29
    • 60. Lab 7 - Patching using Ansible playbook

      6:34
    • 61. Industrial Project - Stop/Start Control M Applications

      4:20
    • 62. Industrial Project - 2

      5:31
    • 63. Industrial Project - 3

      10:56
    • 64. Industrial Project - 4

      8:17
    • 65. Industrial Project - 5

      2:41
    • 66. Industrial Project - 6

      10:12
    • 67. Industrial Project - 7

      6:11
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

240

Students

--

Projects

About This Class

Who should take this course?

IT professionals across a broad range of disciplines who need to perform essesntial administration tasks and automation.

Graduate Students and also for those who are looking for a job in Automation using Ansible (RedHat Linux) & wants to get hands-on practical experience on Automation & build up a base on Ansible.

What will students achieve or be able to do after taking your course?

Implementation of Ansible Playbooks
Overview of Ansible Installation
Online/Offline Ansible installation
Ansible Conditionals, Ansible Modules, Ansible Handlers, Ansible Loops    
Automate Linux Patching using Ansible
Various Labs to understand the Ansible Playbook for Linux Servers Patching
Managing Variables & Inclusions
Various Labs on Implementing Playbooks from real IT Industry Environment
Gain sufficient skills to perform core system administration Automation
Implementing Tasks Controls
Industrial Live overview of Automation tool using Ansible with Shell Scripting
Ansible Roles
How do we create Ansible Roles
Industrial project of stop/start control m appl/db

Meet Your Teacher

Teacher Profile Image

Shikhar Verma

Solution Architect

Teacher

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Course Preview: Welcome to my course module, Ordovician with ansible. My name is Chicago Irma, and I'm your instructor for this complete course module. I'm having 30 years of IT industry experience and also a professional IT tenor. My passion is to create online job oriented and satisfied courses. I had been teaching over to 25-30 students online and held many learners to pass various certifications, such as are a CSA, RSC, redhead, high availability cost-sharing, Linus virtualization automation with ansible AWS solution architect and money more. So this course module is designed for system administrators who are intending to use answerable for automation, configuration, and management. Students will learn how to install and configure ansible is students will also create and run playbooks to configure systems and learn to manage inventories and many more things. We have discussed this entire course module. Prerequisite for this course module, one should have the PC or laptop with internet connection. Second requirement, if you want to do then civil setup in your laptop or desktop, then you need to have the Eiseley made of Red Hat Enterprise Linux or CentOS. You can do the satyr ansible center one article 67 or eight. Few software is required like VMware Workstation or article VirtualBox. Also redhead satisfied system administration certification is required or equivalent knowledge. About this course module, I have prepared over 289 hours of video content and a half, tried my best to include all the required stoves, which will make you easy to understand the concept of ansible. Cherry on the cake. I have included guided exercises at the end of each section. So this entire course module is covered with theoretical sessions, with various practice lab session. Don't take my words for it. Look at the 1000 of reviews I've received on my videos courses. So after the completion of this course module, with proper dedication, you will win the next one who will start automating your environment. And also I'm keeping my courses updated time to time. Also, you can raise your query concern. Any suggestion into the cushion Ansar forum of this course module? If needed, I will add more lectures, more content of this course module. Believe me, this is not the fig promise. I hope that by now you are convinced is still if you have any doubts, you should know the policy 30 days back guarantee. And this course module will help you to take you to the next level of your carrier. So the question is, I ready for the challenge? If so, then unroll into this course module today on Lee and less learn automation of ansible together. Thank you. 2. Introduction Ansible: In this section, I'm going to discuss what is ansible all about? What are the features of ansible? How ansible is differ from other automation tool? And symbol is a simple IT automation platform that makes your applications and systems easier to deploy. A, let me take an example so that you can easily understand what is ansible all our Bower. Suppose I'm working in an organization as a system admin, where I have to manage hundreds of Linux hours. So there are a lot of tasks that we perform daily manually, like the post configuration part after the cellular bail, batching part, deployment of any application. Suppose all of a sudden someone novelty has attack in your environment and that vulnerability is littered with the SSH. And you need to find out what is the SSH version running in all the solos in your environment? One way, you are longing to Esau's one-by-one manually and fetching that require information. Here you can see lot of manual intervention is required. And you are performing all those tasks manually. But with the help of ansible, you can automate each and everything. And civil can help you with configuration management, application deployment, and task automation. What are all the things we can perform with ansible configuration of solvers, that is your configuration management. Suppose if you want to install the new version of Apache on all the machines present in your environment. It is not feasible for you to manually go and update each and every machine. You can install Apache in one bow on all your machines with ansible playbooks. All you have to do is to create a list. In the list, you have to put the IP address of all the solos on which you want to perform this installation. And then write a simple label to install the Apache and run the playbook from your control machine. And it will install on all your nodes. So this is what it can do with the configuration management. You can also perform the application deployment. So application deployment, we all know that there are number of steps that it needs to be no undergo to deploy any application. So with the help of ansible, you can do the number of steps one-by-one. Continence testing of already installed application that we perform. Provisioning. So provisioning also bare metal is polished them. You can do with any of the software. Likely you can do it via Kickstart. And once you have the bare metal install Linux operating system, there are a lot of inner post configuration part is also there so that the help of ansible, you can do the post configuration or is established when it cannot perform with ansible orchestration. So basically, the meaning of orchestration is the planning, our coordination of the elements of a situation to produce a desired effect. Or we can say, if you have any complex work. So we can divide that complex work in a sequence and then perform the task. Suppose if you have a group of epsilon goes behind a load balancer and civil can upgrade the psoas. And while upgrading I have few requirement. I want that. First, it should remove the current web server from the load balancer. And it should disable the silver deals from the monitoring as well, and then perform the tasks. So in simple or short-form, In short we can see and symbol can handle the complex task as well. Automation of task. You can perform the number of tasks with the help of ansible. So once you have the idea about ansible, then you can start automating your environment as well. So that's all for this lecture. We will see in the next file. 3. What is Ansible?: In this lecture, I will discuss about what is ansible. And Sibyl is an open source software provisioning, configuration management, and application deployment tool. It runs on many Unix-like systems and can configure both Unix-like systems as well as Microsoft Windows. In simple words, if you have a environment where you have to manage hundreds of Linux hours. So very first step, you have to choose one server as your ansible server on which you are going to install and civil software. Or we can say that server is going to manage all your clients. So that server should always be a Unix-like systems on which you are going to install ansible. And your clients could be Windows or Unix like systems. It doesn't matter, but you cannot make your Windows machine as your ansible server. Your ansible servers should always be install on a Unix-like systems. And Sibyl was originally written by Michael De Han, the creator of the cobblers provisioning application. And we will has been widely adopted because it is simple to use for system administrators. Developers ease into using n symbol because it is built on Python, the most important. And Sibyl is included as a part of the federal distribution of Linux. And it is owned by a redhead. And it is also available for Red Hat Enterprise Linux, CentOS, Debian scientific Linux. Article Lennox via extra packages for the Enterprise Linux, Apell. And Sibyl's architecture is Agent less. You do not need to stall any agent at the client machine, which you're going to manage from your ansible. So this is one of the good feature of ansible which MEK gets differ from other automation tool. Instead of creating custom individualized scripts, system administrators create high-level plays in ansible. So with ansible, you have to create the playbooks labels is nothing. It's a file which contains one or more plays. In a playbook. You have to write what exactly you want to perform on the client. So that we'll understand once we'll do the lab share Shannon. So that's all for this lecture. I hope you got some idea about the ansible Wilson. The next lecture. 4. Ansible limitations: In this lecture, I'm going to tell you about ansible limitations. There are many things that ansible cannot perform. Here we have and Sibyl can add packages to establish and, but it doesn't perform the initial establishment of the system. So with ansible, you cannot perform the installation of any operating system that you have to do it via cake is star or OS media CD, or via network. And once you do the minimum installation of Linux operating system, the further post configuration work you can do it via ansible. Although ansible can mediate configuration drift. It doesn't monitor for it. And civil doesn't track what changes are made to files on the system, nor does it track what user and process made those changes. So suppose we have one file on my system. And I want to know why ansible that what changes have been made on that file and who has made. So this sort of work you cannot perform with ansible. Even you cannot perform the monitoring on the system. For the monitoring, you can use some softwares like nebulous and any other third party software. That's all we'll see in the next lecture. Thank you. 5. Ansible Architecture: In this lecture, I'm going to discuss about an architecture of ansible. In this picture you can see a lot of components are there. Left-hand side? You can see the components that's belonged to and Sibyl automation in general. And right-hand side, host one, host to host three. These are the clients which you are going to manage from your ansible. And at the top, you can see publics, less private cloud, nothing. It's a Linux over. You can add this over as a repository for all light installation and configurations. Basically for a big environment where we have lots of departments and domain which we have to manage from ansible. Then we need a repository where we can put the playbooks, where we can put the configurations, plugins, custom modules. So we need a representative for that. And that repository we are going to create on a Linux sour and that Linux server, I wanted to be in a private cloud or a should be in a public cloud that other departments, people, they can also use that repositories. Now let us discuss about the ansible automation engine components. Here we have the host inventory. Who's inventory basically is a list of all the IP address of the host machine which you are going to manage from your unstable like host one and host two. Suppose you want to manage host one and host T2 for the installation of Tomcat, then you are going to create a inventory. And in that inventory you are going to manage only these two servers. And when you run your playbook, you have to specify the inventory. The next components are modules. Here at the bottom you can see it is showing core modules and custom modules. And symbol comes with hundreds of inbuilt modules. And modules are nothing. They are the pieces of codes. Deaths gets executed. When you run a playbook. A playbook contains, please. And a player contains different tasks that you want to perform from your host machine, that is from your client. And the task includes your modules. So when you write a play, in the play you mentioned the modules. Suppose you want to copy a file from your ansible server to the clients, then you are going to use a module for that. So we'll do you want to do the installation of any package? So for that we have a separate module. So for each task and symbol has created a separate module for that. So when you run a playbook, it's the modules that gets executed on your host machine. And these modules contains action in them. So when you run a playbook, those actions takes place on your host machines. You can make your custom modules as well. If you have a very good knowledge on Python, you can create your own model as well. Next in the architecture are plugins. Plugins here are especial kind of modules. These plugins gets executed before a module is getting executed on the nodes. Different types of plugins. We have email login and extract or cache plugins also there. The architecture has connection plug-ins here you can see we know that for the communication between ansible to the client machine, we always prefer SSH, but it is not always needed to use an SSH for connecting with your host machines. You can also use a connection plug-in. For example, ansible provides you with a Docker container connection plugins. And using that connection plugin, you can easily connect to all your Docker containers and start configuring it. So for inter-cell, for this lecture, who've got an idea about an architecture of ansible. Thanks, and we'll see you in the next lecture. 6. Ansible Setup: In this lecture, I'm going to discuss about how to start the ansible setup in your environment. Suppose I am walking in an organization where I have to manage hundreds of soldiers. It could be Lennox SP, and Xolair is AIA x. Now I want to do automation in my environment. I want to do the ansible setup. So very first step, I have to choose one server. And that server is going to be the control node on which I'm going to stall the ansible software. And from that server, I'm going to manage all my clients like anything that PPT. Here I have 2sin server nine dot example.com. This is my control node. On which angle this tall ansible. And from this server I'm going to manage all my clients. So there are two type of machines in ansible architecture, control node and managed host. Managed host is your clients. And at the client n, you do not need to install anything. It's an agent less. And one more thing. You have to make sure that SSS should be walking between your control node and managed host. If it is not working, then you have to involve the respective team. It could be an issue with the firewall, involved a firewall team and open the port for SSH. Sss should be walking between your managed host and control node. So friend, that's all for this lecture. I hope you got some idea about ansible and know what is. We'll have a lot of lab sessions. In the lab session I'm going to show you how to do the setup tactically. So that's all you see in the next lecture. 7. Practice Lab Session: In this lecture, I'm going to discuss about a role and requirements for the control node. So here in the picture you can see I have chosen one server as a control, nor are we can say it's a jump server from which I can access all my clients. Why SSH? So that's the condition that says should be walking between your control load and all your client machines, system administrators login. And initially all ansible operations from the control node. And simple software is also install on your control node. All your ansible configurations are also maintained in your control node. Few more important requirement is that the machine which is acting as a control node must have Python wasn't 2.6 or more. And this machine should be a Linux or any BSD base unix systems. Windows is not supported for the control node at this time. The next is role and requirements for the managed host. Men just hose is your client machines which is going to minus by your control nor are managed host is a system that ansible logs into install modules and execute remote commands to perform configuration task. Suppose I want to perform something from my control node. For that you have to write the playbook. And in the playbook, you have to mention the modules, required module. Suppose my requirement is I want to install some package. So for the Astrologer not package, you are going to use some model for that. And when you start executing your task, your playbook, it is going to log into your managed host one-by-one are parallely and then copy the module to your managed hosts and then perform the task. Sss should be walking between your control node and a managed host. And there is one more condition for the managed host. It must have Python 2.4. We all know that if you install the Linux operating system, RH IL-6, santos, whatever by default comes with Python. In editorial five, it comes with letter version of Python and Era Rachel five is already obsolete in the market. So for that you have to simple install this package. Python does simple Jackson package that must be installed on our HL five. And for other operating system need not to worry. By default they have Python 2.5 or more. So that's all for this lecture. Hope you got some idea about the rules and requirements of the control node as well as managed host. So there's always you in the next lecture. 8. Recap: Let's have a important points about ansible. It is a free open source software. Agent, less no need for agent in stylish and at the client n. It is Python's animal-based, highly flexible and configuration management systems. Large number of ready-to-use modules for system management. So ansible comes with number of inbuilt modules. So you can use as polymorphic cavemen. You can also create your custom modules if needed. Configuration rollback in case of adders. Simple and human-readable, implement sudo password so that normal user needs password to alleviate this privilege. So last point you will understand once we'll do the lab session. So these are the important points or we can say tips about this unstable. So thanks, we'll see you in the next lecture. 9. Ansible Control Node Components: Customizing ansible. You, it is a very important lecture of this course module. In this lecture I'm going to discuss how to customize the behavior of ansible. So this is a diagram of our ansible setup. We have one control node and lot of managed host. And for communication between uncivil server and managed host. I have used SSH protocol and a normal user as Burma. Now, suppose I need to perform patching on my client machine. Why ansible? Here, cannon normally user perform batching? So the answer is no. Because for patching it requires administrative privilege. Or we can say only root user can perform the packing on the client machine. So what is the solution for that? Solution is for communication. I'm going to use a normal user that is S11. And once it is going to log into the time machine, after that, it will elevate this privilege from normal user to the root user. And then it is going to perform the task that is the patching, whatever the task we want to perform. So how we can customize this? So we have the ansible configuration file that is less ETC, slash n symbols less ansible dot CFG. In that file we have a section that is privileged escalation. In that section we have few entries. The foster entries become is equal to true. If you have used that option, what we'll have fun when you run your ansible playbook or any hand-held come on. As a normal user, it is going to log in as a normal user, and then it will try to become a root user or whatever user you have mentioned in this file, then it is going to perform the task. So suppose are used, DICOM is equally true. Now we have few more entries, like become underscore method is equal to two. So what method you want to use to become. So I want it should use the pseudo method. And what do user you want, it should become, I wanted should become a root user. So here are the three things. First, it will, it is going to elevate its privileged. And for elevating his privilege, it is going to use the sudo mattered and what the user is going to become. I want my normal user as Burma is going to become a root user. The next thing is you're unable password prompting. So whenever you are, you know, firing this common from the ansible, it is going to ask you a password if you have used this option too. If you have mentioned falls down, it is not going to ask any password. But for security concern, always use through here. Because suppose somebody setting on your uncivil solver, they have simply fired this command. Without asking you this password, it is going to run those playbooks. But if you have unable this one. So before performing, before, you know, fighting the playbook or ad hoc comma is should ask the password. If that user, that person doesn't know the password, that playbook is not going to run. So let me quickly log in to my server and let me show you what is that file and worldwide entries. So this is my ansible configuration file. And I'm going to add this file and look for the section that is privileged, this one. So here you can see that now all entries are hashed. It means that if you want to use, if you want to run any playable or any adult comma, you have to manually mention all those things. But you do not want to mention all those things. Whenever you are going to fire your simple uncivil come on at oh, come on. By default it is, you know, taking all those options, then you have to put it here. So that will become a permanent suffering there so far this lecture. In the next lecture, I'm going to show you with a lab session. So there's all we will see in the next lecture. 10. Control & Managed Node: In this lecture, I'm going to discuss about a role and requirements for the control node. So here in the picture you can see I have chosen one server as a control, nor are we can say it's a jump server from which I can access all my clients. Why SSH? So that's the condition that says should be walking between your control load and all your client machines, system administrators login. And initially all ansible operations from the control node. And simple software is also install on your control node. All your ansible configurations are also maintained in your control node. Few more important requirement is that the machine which is acting as a control node must have Python wasn't 2.6 or more. And this machine should be a Linux or any BSD base unix systems. Windows is not supported for the control node at this time. The next is role and requirements for the managed host. Men just hose is your client machines which is going to minus by your control nor are managed host is a system that ansible logs into install modules and execute remote commands to perform configuration task. Suppose I want to perform something from my control node. For that you have to write the playbook. And in the playbook, you have to mention the modules, required module. Suppose my requirement is I want to install some package. So for the Astrologer not package, you are going to use some model for that. And when you start executing your task, your playbook, it is going to log into your managed host one-by-one are parallely and then copy the module to your managed hosts and then perform the task. Sss should be walking between your control node and a managed host. And there is one more condition for the managed host. It must have Python 2.4. We all know that if you install the Linux operating system, RH IL-6, santos, whatever by default comes with Python. In editorial five, it comes with letter version of Python and Era Rachel five is already obsolete in the market. So for that you have to simple install this package. Python does simple Jackson package that must be installed on our HL five. And for other operating system need not to worry. By default they have Python 2.5 or more. So that's all for this lecture. Hope you got some idea about the rules and requirements of the control node as well as managed host. So there's always you in the next lecture. 11. Ansible Inventories: Let's continue and do the rest part of the uncivil sat down. So as of now we have simply install the ansible package on the control node. And after that we had created a normal user as former, that is on ansible server, as well as on all my clients, client one client to client three. And also the communication via SSH is password less. That means if I am sitting on ansible server, I can SSS to client one, Cline Two, and client three, and it is not asking for any password. So this is the fastest type we can say that. Now, I'll try to login to client one. It is asking the password. You should not ask for the password. Okay, here you can see that I have logged in as a root user the password list authentication. I had set it for the user S wilma. That's fine. Now, after that, I need to create the inventory file. In the inventory file, I have to mention the name of all my client machines, which I won't to manage from my SQL server. First of all, I should be a logged in as a root user on the NCBI server. And here we have this file. So this file, you can see the permission is this one. So if a normal user, as Burma is trying to, you know, put their servers, it won't allow you. So first of all, let me give full permission to this file. So this file doesn't have any secret information, only this keeping the information of your managed host. Okay, now again, I'm going to log in as it normally, that is S11. Okay. So coming at the bottom of this line. And here after, you know, create a group. So we'll discuss in detail in the later lectures about the syntax of this, you know, the inventory file. So in simple words, I have to give a name of a group. So I'm giving dev. And inside that group I have to mention all the client's client one plane to plane T. So I have simply, you know, chosen a group that is Deaf. You can give any name instead of data. You can give test, you can give proud. Okay, and all the time machine I have mentioned here, that's all. Okay. Now the c'mon is ansible hyphen m. This is for the module. And the argument, the command I want to pass on. I just wanted to get the output of op time. And this is my target group. This command is going to run on all the servers that is mentioned inside the deaf group. So we have client one client to and client three. Let's see. I can see that I have got an output of all the inner plane, machine plane three, plane two, and client one. So this is the uptime from all the servers. Instead of this, let me get an idea of this one. So Kline trays my Red Hat Enterprise Linux 6.2 and client one is 823 is also eight. For the setup of ansible, we have used a normal user, and we know that normal user is having a limited access to the server. So if I'm trying to get the output of any command which can be run by normal user than I would be getting the output for the uncivil. But suppose, if I am trying to do something with ansible which requires administrative privileges, or we can say, which can be done by the root user only. So in that case, I will start getting permission error. So what is the solution for that? So here, what I can do here for the communication between my control node to the client, I would be using the normal user on Lee. But suppose I want to do the installation or I want to run any command which can be run by the root user. So in that case, what I can do for the communication, I'm using the normal user. And once the user is logged into the server as a warmer than it is going to elevate his privilege from normal to root user. And then it is going to, you know, do that task. So let me show you how we can do that. So first of all, I'm going to log in to my client one. Okay, I'm here. And it says to rude user. Ok, now my requirement is that normally user as forma, whenever it requires, it can become a, a root user or normal user can be able to elevate its privilege. So for that, you have to use pseudowords file 3i, sudo. And here are the last. You have to add this entry as Pharma. All is equal to all. No password is equal to 4L. So this entry can be used by the normal user to become a root user. So let me show you how it can become. So here you can see that I have logged into V1 as the S pharma. And if I'll try to elevate my privilege using this command, I can see that normal user as Pharma has become Rudy's or hair, the same angle to use hair as well from the control Lord, if I'm going to fire any command which requires the administrator privilege. So first it is going to log in as a normal user, and then before doing that task, it will elevate its privileged from normal to root user, and then it is going to perform the task. Okay? Same, I have to do it for all my servers that is client to. So let me login to all myself, blind to. And VIA pseudo. Then t is already there. So such fine. Okay. So enter is already there on all the servers. And let me come back. And let me log in to my this and SQL Server. Now I am going to, you know, five this command DID code D, my decode. If I'll try to, you know, five, this come on. As a normal user, you can see that I'm getting this error. So let me first try and Siebel hyphen. Hyphen. I can see that I'm getting this error, right? So what I'm gonna do here, here I am, I'm going to use an option become. So with that option, first it is going to, you know, allowing to the client machine as a normal user. And then it is going to activate its privileged from normal to root user. And then it is going to fire the commanding DID code. I can see that I have got an output. So this command is having a very lengthy output elsewhere. Okay? Vds aren't just fire, we just come on. You can see that I'm getting an output. Again. See that if I, if I haven't used the iPhone f and become, and you can see that I'm getting some Polish and denied error. Right? So for, and that's all for this lecture. I hope you got an idea about how we can do the ansible setup. So that's all we'll show in the next lecture. 12. Ansible Installation - Lab 1: Customizing ansible. You, it is a very important lecture of this course module. In this lecture I'm going to discuss how to customize the behavior of ansible. So this is a diagram of our ansible setup. We have one control node and lot of managed host. And for communication between uncivil server and managed host. I have used SSH protocol and a normal user as Burma. Now, suppose I need to perform patching on my client machine. Why ansible? Here, cannon normally user perform batching? So the answer is no. Because for patching it requires administrative privilege. Or we can say only root user can perform the packing on the client machine. So what is the solution for that? Solution is for communication. I'm going to use a normal user that is S11. And once it is going to log into the time machine, after that, it will elevate this privilege from normal user to the root user. And then it is going to perform the task that is the patching, whatever the task we want to perform. So how we can customize this? So we have the ansible configuration file that is less ETC, slash n symbols less ansible dot CFG. In that file we have a section that is privileged escalation. In that section we have few entries. The foster entries become is equal to true. If you have used that option, what we'll have fun when you run your ansible playbook or any hand-held come on. As a normal user, it is going to log in as a normal user, and then it will try to become a root user or whatever user you have mentioned in this file, then it is going to perform the task. So suppose are used, DICOM is equally true. Now we have few more entries, like become underscore method is equal to two. So what method you want to use to become. So I want it should use the pseudo method. And what do user you want, it should become, I wanted should become a root user. So here are the three things. First, it will, it is going to elevate its privileged. And for elevating his privilege, it is going to use the sudo mattered and what the user is going to become. I want my normal user as Burma is going to become a root user. The next thing is you're unable password prompting. So whenever you are, you know, firing this common from the ansible, it is going to ask you a password if you have used this option too. If you have mentioned falls down, it is not going to ask any password. But for security concern, always use through here. Because suppose somebody setting on your uncivil solver, they have simply fired this command. Without asking you this password, it is going to run those playbooks. But if you have unable this one. So before performing, before, you know, fighting the playbook or ad hoc comma is should ask the password. If that user, that person doesn't know the password, that playbook is not going to run. So let me quickly log in to my server and let me show you what is that file and worldwide entries. So this is my ansible configuration file. And I'm going to add this file and look for the section that is privileged, this one. So here you can see that now all entries are hashed. It means that if you want to use, if you want to run any playable or any adult comma, you have to manually mention all those things. But you do not want to mention all those things. Whenever you are going to fire your simple uncivil come on at oh, come on. By default it is, you know, taking all those options, then you have to put it here. So that will become a permanent suffering there so far this lecture. In the next lecture, I'm going to show you with a lab session. So there's all we will see in the next lecture. 13. Ansible Installation - Lab 2: This is a lab session on customizing ansible. So let me quickly login to my ansible server and you can see I have logged in to my ansible. So as a user, as pharma, which is a normal user. Now my ansible configuration file is this one. Okay? And to modify this file, I have to first route only. And I'm looking for the entry hour, I'm looking for the section of privilege escalation. So as of now I'm not going to do any changes in this file. I'm going to go with the default options. Now. I want to, you know, run any adult comma and symbol hyphen. And before that, let me show you list hall. So I'm going to do in this lab session on a group that is deaf and the dye we can see there is only a one server that is client one. So ansible hyphen M comma N is a module hyphen a. Simply I'm going to fire up time. That is four deaf group. I've got an output here. Suppose I want to run a DC Red Hat release. I'm getting an output right? Coming back to my another server. So this is my claim one on which I am running this one. And this location, I'm going to create a file. So here you can see on client one, I have logged in as a root user and I've just created a file that is ABC right now. And here we have user, that is John either is existing and group that is admin group is also available. That is ket grow. Okay. Now I'm an onset ansible silver and I'm going to change this file permission and almost same. And here you can see this file is owned by the root user. If normally user, as well as trying to, you know, do any changes in that file, obviously, point allow you. So let me show you how we can do the changes and symbol hyphen M. And I'm using the module file a because I'm going to do changes in the file on which file destination is my ten, a, B, C. So this is the file which is existing here. You can see that this is my file ABC that is in temp location. And I want its permission will become triple seven, okay. And the owner, as a heart is rude. I want its owner will become Jon. And group. I want to become a group of admin. So this is what I want and on which service the service belonged to deaf group. So I have simplified this. Come on. Ok. Here you can see that it is getting failed. And for changing the permission, it is using the tone. Come on. And the Arab, I have got this operation not permitted. So this is what the error I have caught. So it means that this normal user doesn't have the permission, right? So the solution is, I'm going to use few option here. Like when it is going to, you know, five this command, first it will become, it will alleviate its privileged. So to elevate its privileged, you have to use hyphen F and become. And what method you wanted should use two elevators privilege, I want it should use sudo and which user it will become. It will become from elsewhere, mod2 or root user. So here you have to mention a rude. And also you want that it should ask for the password whenever it should use the pseudo. Yes. So whenever it is trying to elevate trivalent from normal to rule, it should ask for the password. So everything seems fine. Now, I'm going to fire here. You can see there it is asking for the password. Now that's done. Now, coming back to my client machine, I can see that the permission, the ownership, everything has been changed now. But here you have to mention all the mange, all these options manually. Right? And also, let me show you one thing. If I'll simplify VI pseudo, save G. And the last You can see that I have used past WD is equal to know. If I'm going to fire this command, if I'm not going to capital K, it is not going to run because it is missing the pseudo password. Because here I have mentioned that in my pseudo ours files that whenever as far as trying to elevate its privileges, you need to provide the password. So this is good. We can say the security feature, we can say. So here you have to use capital K then only you will able to chain them. By. This is one thing. The changes are already there. That's Friday showing green. Now. So each time whenever you need to know, elevate your privilege, you have to use all those options. I want. I should not use these options. Whenever I'm going to run this command by default, it should take all those things. So for that you have to put the entry in your unstable configuration file. So let me log into the system as a route that goes to edit the uncivil configuration file only root user candidate and symbol. This one. Now here you can see that I have to move all the hash. So all of these options are active. Now, that's done. Again, I'm going to find the same command. Let me remove this file ABC and the, let we recreate this file abc. Okay, again, I'm going to fire the same command, this one. Okay? First of all, I should will SOM only. Okay? And I'm only use this one. Now I am not going to use any options here. That is less, less become an all those options because I have already mentioned in my ansible configuration files. So it will take all those options from that configuration file. Now changes has been done now. And I can see the Tejas has been done. So by default, no, it is elevating privilege. It is just consulting with the configuration file. In the configuration file are mentioned each and everything. So it is customizing the behavior of ansible here you can see that. So for undersell, for this lecture will be got some idea. So there's always you in the next lecture, bye. 14. Ansible Installation - Lab 3: Let's continue and do the rest part of the uncivil sat down. So as of now we have simply install the ansible package on the control node. And after that we had created a normal user as former, that is on ansible server, as well as on all my clients, client one client to client three. And also the communication via SSH is password less. That means if I am sitting on ansible server, I can SSS to client one, Cline Two, and client three, and it is not asking for any password. So this is the fastest type we can say that. Now, I'll try to login to client one. It is asking the password. You should not ask for the password. Okay, here you can see that I have logged in as a root user the password list authentication. I had set it for the user S wilma. That's fine. Now, after that, I need to create the inventory file. In the inventory file, I have to mention the name of all my client machines, which I won't to manage from my SQL server. First of all, I should be a logged in as a root user on the NCBI server. And here we have this file. So this file, you can see the permission is this one. So if a normal user, as Burma is trying to, you know, put their servers, it won't allow you. So first of all, let me give full permission to this file. So this file doesn't have any secret information, only this keeping the information of your managed host. Okay, now again, I'm going to log in as it normally, that is S11. Okay. So coming at the bottom of this line. And here after, you know, create a group. So we'll discuss in detail in the later lectures about the syntax of this, you know, the inventory file. So in simple words, I have to give a name of a group. So I'm giving dev. And inside that group I have to mention all the client's client one plane to plane T. So I have simply, you know, chosen a group that is Deaf. You can give any name instead of data. You can give test, you can give proud. Okay, and all the time machine I have mentioned here, that's all. Okay. Now the c'mon is ansible hyphen m. This is for the module. And the argument, the command I want to pass on. I just wanted to get the output of op time. And this is my target group. This command is going to run on all the servers that is mentioned inside the deaf group. So we have client one client to and client three. Let's see. I can see that I have got an output of all the inner plane, machine plane three, plane two, and client one. So this is the uptime from all the servers. Instead of this, let me get an idea of this one. So Kline trays my Red Hat Enterprise Linux 6.2 and client one is 823 is also eight. For the setup of ansible, we have used a normal user, and we know that normal user is having a limited access to the server. So if I'm trying to get the output of any command which can be run by normal user than I would be getting the output for the uncivil. But suppose, if I am trying to do something with ansible which requires administrative privileges, or we can say, which can be done by the root user only. So in that case, I will start getting permission error. So what is the solution for that? So here, what I can do here for the communication between my control node to the client, I would be using the normal user on Lee. But suppose I want to do the installation or I want to run any command which can be run by the root user. So in that case, what I can do for the communication, I'm using the normal user. And once the user is logged into the server as a warmer than it is going to elevate his privilege from normal to root user. And then it is going to, you know, do that task. So let me show you how we can do that. So first of all, I'm going to log in to my client one. Okay, I'm here. And it says to rude user. Ok, now my requirement is that normally user as forma, whenever it requires, it can become a, a root user or normal user can be able to elevate its privilege. So for that, you have to use pseudowords file 3i, sudo. And here are the last. You have to add this entry as Pharma. All is equal to all. No password is equal to 4L. So this entry can be used by the normal user to become a root user. So let me show you how it can become. So here you can see that I have logged into V1 as the S pharma. And if I'll try to elevate my privilege using this command, I can see that normal user as Pharma has become Rudy's or hair, the same angle to use hair as well from the control Lord, if I'm going to fire any command which requires the administrator privilege. So first it is going to log in as a normal user, and then before doing that task, it will elevate its privileged from normal to root user, and then it is going to perform the task. Okay? Same, I have to do it for all my servers that is client to. So let me login to all myself, blind to. And VIA pseudo. Then t is already there. So such fine. Okay. So enter is already there on all the servers. And let me come back. And let me log in to my this and SQL Server. Now I am going to, you know, five this command DID code D, my decode. If I'll try to, you know, five, this come on. As a normal user, you can see that I'm getting this error. So let me first try and Siebel hyphen. Hyphen. I can see that I'm getting this error, right? So what I'm gonna do here, here I am, I'm going to use an option become. So with that option, first it is going to, you know, allowing to the client machine as a normal user. And then it is going to activate its privileged from normal to root user. And then it is going to fire the commanding DID code. I can see that I have got an output. So this command is having a very lengthy output elsewhere. Okay? Vds aren't just fire, we just come on. You can see that I'm getting an output. Again. See that if I, if I haven't used the iPhone f and become, and you can see that I'm getting some Polish and denied error. Right? So for, and that's all for this lecture. I hope you got an idea about how we can do the ansible setup. So that's all we'll show in the next lecture. 15. Ansible Installation - Lab 4: As a security point of view, whenever a normal user is elevating its privileged from normal to root user, it should ask for the password. But in the previous example, when I had fired the come on using hyphen F and become a shun. It didn't ask for any password because at the client and in the suit doors files, we had mentioned no password. So I'm going to login to all my clients one-by-one. And I'm changing that option. Now here you can see that I have logged into client one as a normal user and fire the command sudo is pleased as you hyphen. It is elevating its privileged or rude. It is not asking for any password. Ideally should ask. So here I have to use no password. So it means that NADH is going to ask for the password. Coming back. I wanna client one as S1 Irma. I'm trying to elevate my privilege. Now here you can see that it is asking for the password. This is what I want for my ansible setup. Let me log into my claim to changes has been done. Again, I'm going to find the common n symbol hyphen. Come on. And I'm just firing VGS. And death is the group in which we have three servers. Now let's see. I am getting permission denied error because we just come out requires the root privilege. So again, I'm going to use become here. So let's see what output I am getting here. So it is logged into the system as a normal user as Wilma, and it is trying to elevate its privilege. But I have used an option that whenever a normal user is trying to elevate its privileges, we need to supply the password, but we're, we have supplied the password. That's why I'm getting an error here. So I need to supply the route parcels as well. So for that I have to use capital K. I need to supply the root password. Now it is logged into the system as a normal user and eliminating its privileged from normal to root user. And at that time it needs a sudo password. So I am supplying the pseudo password as follows. So this is the best or idle, or we can say as a security point of view as well. So fenders on for this lecture we will see in the next lecture, bye. 16. Customize Ansible behaviour: Customizing ansible. You, it is a very important lecture of this course module. In this lecture I'm going to discuss how to customize the behavior of ansible. So this is a diagram of our ansible setup. We have one control node and lot of managed host. And for communication between uncivil server and managed host. I have used SSH protocol and a normal user as Burma. Now, suppose I need to perform patching on my client machine. Why ansible? Here, cannon normally user perform batching? So the answer is no. Because for patching it requires administrative privilege. Or we can say only root user can perform the packing on the client machine. So what is the solution for that? Solution is for communication. I'm going to use a normal user that is S11. And once it is going to log into the time machine, after that, it will elevate this privilege from normal user to the root user. And then it is going to perform the task that is the patching, whatever the task we want to perform. So how we can customize this? So we have the ansible configuration file that is less ETC, slash n symbols less ansible dot CFG. In that file we have a section that is privileged escalation. In that section we have few entries. The foster entries become is equal to true. If you have used that option, what we'll have fun when you run your ansible playbook or any hand-held come on. As a normal user, it is going to log in as a normal user, and then it will try to become a root user or whatever user you have mentioned in this file, then it is going to perform the task. So suppose are used, DICOM is equally true. Now we have few more entries, like become underscore method is equal to two. So what method you want to use to become. So I want it should use the pseudo method. And what do user you want, it should become, I wanted should become a root user. So here are the three things. First, it will, it is going to elevate its privileged. And for elevating his privilege, it is going to use the sudo mattered and what the user is going to become. I want my normal user as Burma is going to become a root user. The next thing is you're unable password prompting. So whenever you are, you know, firing this common from the ansible, it is going to ask you a password if you have used this option too. If you have mentioned falls down, it is not going to ask any password. But for security concern, always use through here. Because suppose somebody setting on your uncivil solver, they have simply fired this command. Without asking you this password, it is going to run those playbooks. But if you have unable this one. So before performing, before, you know, fighting the playbook or ad hoc comma is should ask the password. If that user, that person doesn't know the password, that playbook is not going to run. So let me quickly log in to my server and let me show you what is that file and worldwide entries. So this is my ansible configuration file. And I'm going to add this file and look for the section that is privileged, this one. So here you can see that now all entries are hashed. It means that if you want to use, if you want to run any playable or any adult comma, you have to manually mention all those things. But you do not want to mention all those things. Whenever you are going to fire your simple uncivil come on at oh, come on. By default it is, you know, taking all those options, then you have to put it here. So that will become a permanent suffering there so far this lecture. In the next lecture, I'm going to show you with a lab session. So there's all we will see in the next lecture. 17. Lab Session on Privilege Escalations: Let's start creating a playbook for Linux OS patching. So very fast task in my playbook, that is for verify the application or database processes are running on not I do not have any application on database to show you. So for testing purpose, I'm just considering the Apache processes as an application process. So it is going to check that Apache process is running or not. If the Apache processes running, we'll throw a message that pleases stop the application fast and then attempt batching. So let me log in. This is my ansible server and this is my client machine. I had created a group that is my host group. Let me show you ansible and climbed six forensics on which I'm going to do the kernel patch. So let me start patching. And the name of my playbook I'm giving my you can give any name. Okay. Betty, Great. And become true. To initiate the patching. You shouldn't be routinely task, clarify, application or database, whatever you want to put, you can put running or not. So how we can check. So let me log into my client machine. So this is my client machine. So if I will simplify a PSI Fund EDF and grab hyphen I edge. You can see number of processor running. It means that the processes are running, the application is running. And let me stop this one. System CTO is top as TBD. Again, if I'm going to fire this command, I am getting this output grab hyphen v grab. So if this process is not running, this application is not running. If l five this command, I'm not getting any output. So this is the concept I'm going to use to check whether the application is running or not. Okay? And here I'm just creating a very simple shell script. So the model, I'm going to use shell module, okay? And the Come on. I'm going to use if-else, if ps hyphen EF. This is the command to check the process. Which process I want to check. I am using e grep. I want to check this process HTTPD, and grab hyphen v. This one. And I just wanted to nullify any errors. So this one, let me copy here. And five, this one. I'm not getting any output, but if I'll fire, if I'll start the service, again, I'm going to fire. I'm getting some output here. I do not want to get any such output when I am, when I will run my playbook. That's why I've used this one. Diagonal. So whatever the output is it is, it should nullify. Then echo. Process running. If I'm getting some output here. If I'm getting some output here, it means that processes running, right? I'll echo process. Not used simple if-else here. I'm closing it. Right. Say will fire this one. Let me copy this one and paste it here. Some typo mistake use here. Okay, it's echo. Ok. Let me copy when by one here. And just copy and paste the same command here. So processes running right. Now let me stop this one. I'm saying come on, I'm firing process not running the same condition I am using here, right? I'm here now. This one. I just want to ignore any errors at this point. So for that you have to use this module, ignore underscore errors true. Now, whatever the output is coming, and then it should be process running, a process not running. I want to save this output inner available. So for that I am using register and you can give any name. I'm giving a prop process application process check. So this is the name of my variable we can say. And what were the output I am getting after running this command is going to save into this variable. Okay? And after that, I just want to debug a message here. And the message is this one is equal to. So whatever the output is here, it is going to save here. And if we want to, you know, see what is the output, whether it is processes running or not. So here I'm going to use this and debug, and this is my variable. And to read the variable you have to use this one. And at the last You have to put std out, right and close this one. So this is my first task. Let me copy and let me check the syntax error. And civil it is running now. Okay, let me check the syntax. Syntax is okay. Okay. So let me cross check whether this task is working on not capital K after US here. Verify the process not running. A. Let me start the process. Started with the process. And again, I'm going to run this one. So this time it should throw a message processor is running. I can see processes running. So till here, my ansible playbook is correct. So if, and that's all for this lecture. In the next lecture, I'm going to discuss how to decide whether the label should proceed further or should we stopped here. So that's always in the next lecture. 18. AD Hoc - Practice Lab Session - 1: Hello everyone and welcome to the lab session of ad-hoc commands. So in this lecture, we are going to do a lot of practice related to the adult commands. So let me first login to my box. This is my ansible server. And from this server I'm going to manage my managed host with Adopt commands. So first of all, we have to look for the ETC. Ansible host file. Here you can see that I have created a group that is called testing. And we have three servers in that group. And if you want to see what all the servers we have in that group with the command line. We have this come on, ansible hyphen, hyphen list, host, and the group name. So with this command, it will list out to you what all the servers we have in that group. Now, very first command, very simple command. You have already know that ansible hyphen em, come on, hyphen a uptime and testing. So it will give you an output of all the solos. The best part is that all the commands run penalty on all the servers. That's fine. I'm getting an output very quickly. Suppose if you have, you know, a 100 of soldiers. So here, the advantage of ansible, it will run, it will throw this come on parallely to all the servers. So within a few seconds you will get an output from all the servers. Next command, suppose, instead of up time, I want to run this Jonelle hyphen app. So you will get an version of your whereas wasn't, you will get immediately. Suppose you want to check the pink connectivity. So ansible hyphen em, and you have to use this module ping. And this is my testing. You can use testing before two. Modulus valid is up to you if you want. This command is also done instead of testing at the back, you can use hair as well. So with this command also you will get an output. Okay, successful means this command has run in all the servers. You're getting endline output. It means it has run and all the solos. Now suppose I want to copy a file to all my managed hosted. So let's take an example. Suppose I want to copy this file list. And one more thing currently I'm running this adult commands using my ID that is S1. It's a normal user. Now, the task which I am going, I am going to copy this file to all my managed host. So the command would be ansible hyphened M. Now I'm using copy module instead of c'mon, I would be copying a is my.attribute source. My source is this one ADC host destination where I want to copy. So for testing purpose I am copying in my tmp directory and with name of host. And I want to run it on all the servers that will be the part of this group that is testing. This command will run on all the manage tos. So let's see what output I am getting here. Immediately it has run. You can see that I have got an output here. So changes to it means they have, you know, copied all the files, the files to all the servers. So let me log in to one of my servers. And will she so what's the IP of my so this is the IP of this client one. So let me login to this server less me cause check. I've just logging to one of my soul was that as a part of testing group. And this, the destination was less time and go. Here you can see the file has been copied. But you can see that the ownership of the file is showing S1, Mom. But I'm the client and the server and that is a control node. If I'm going to see the file permissions and ownership, it is root and root. And the reason being wired, permission has not been changed because this operation, this adult Chrome on has been done with user S10. But I won't that it should be run with a rude so that it will copy with root permissions. So in that case, what we can do here, same, Come on. We can fire here. And at the back-end, what we can do, I can give this becomes, so what will happen? It will again run this command on all the servers. And now it will run with law what it is showing that missing a root password, right? Why I'm getting this because and the client end as a security point of view, what I have done for all the users of S Walmart whenever they will elevate its privileged from normal to root users, it should ask for the password. So you are here, you have to specify capital K. Now, I need to give the password, the password off all the users. I have said the same password now you can see that it has run on all the servers. If I'm again coming here and I will checking the permission of this line, you can see that the permission is still the same. I'm in this. Okay. So what happened here? Why didn't change the permission? It isn't being here. You can see that changed is false. The ansible is very much in spot here. It has found that this file is already existing on the servers, so they didn't touch the file. So if I'm running the same command here, let me show you. If I am running the same command and instead of this, I am giving a new file name like host one. So what will happen? It will copy the files to all the servers. And now you can see it's been changed. I leave it was not showing this one. Let me show you. A command has done successfully, but it was not showing changed, changed was fall because they have found the same file was already insisting on that destination. So they have not touch the file which was already existing on the destination. So now I have given a different file name that is host one. Now you can see that the host one file has been copied with the user as Pharma. So two commands which I have fired here. The first command, this one, which has the alone as a normal user discipline. So normally isn't my S1. So this command has them and it has copied that come this file to all my host file. But it has the ROM with normal user S 41. Again, I have run the same command, but the nation have changed with host one. And also I have elevated ITS privilege. It means that the communication will be that as Burma. But whenever it will tried to copy this file, it will first activate its privileged from normal to route, and then it will copy the file. So if you become the root, that's why it has copied this file as a road. And a file again, firing the same Come on, where this same file is already existing, that it will not touch the existing file. So that's all for this lecture. In the next lecture, we are going to understand a few more modules that is File molecules. Okay? So thanks, and if you have time, please. Dan Friedman in the next lecture. 19. AD Hoc - Practice Lab Session - 2: Hello everyone and welcome to the lab session of ad-hoc commands. So in the last lecture we have understand how we can simply run that out commands. In this lecture, we are going to understand a few more modules which can be used to while running the adult commands. So the model which we are going to understand in this lecture is file module. So file module is basically, it provides the ability to change the systems ownership and permission at the remote location. Suppose I know that there are few files which is existing at the destination and now I want to change the ownership of the file. So in that case, we can use the file module. So let me log in to my ansible server. So this is my ansible server. So let me first run a command this, and now what I have done here simply, you know, okay, I need to give the destination this testing. So what I have done here simply I've copied a file. This is the host and the destination and the destination end. I have copied this file as a host underscore testing. So if I'm looking at the destination, I can see a file, this one. This one, so this file has been copied. Now, I want to change the ownership. It is showing S11 I wanted it should be something like Unix ADM. I am taking example. So the Unix admin should be existing on all the solos. So let me clear the user or the client name. First. Let me go to the second claim. This one, the file is there. Now what I have done here, I am going to change the files, ownership and permission. So file is already copied with this common. Ok. So this is my ansible. So, but what I have done here, I have not catered Unix edim user on client theme. So let's see what output I am getting here. So the command would be ansible. Haifa m. I am using file module attributes. Destination is mice. Let me check. This will host undisclosed testing. So this was the file. I want. It should be full permission. Owner should be your, your next ADM. So unix ADM user I have credit on to client, client one and claim two I haven't created on third one. So let's see what I did. I am getting, I am doing this for the testing purpose normally. And one more thing, I need to elevate my privilege because if I'm trying to change the ownership, if I'm doing with the normal user, normally user doesn't have that much of permissions to change the ownership. So let me become a root hair capital Ks for us, for the password. I'm getting an error because I haven't specified that the targets on which it should be running. Now you can see that on client to, it has done chain and they have changed the permission for client one as well. But unkindly, I am got an error like it got failed. And failed because is a command which is used to change the ownership. And they are saying that this Unix ADM is not there. So that's why it got fail. So let me check on the client machine leg. Whether the permission has been changed or not. I can see the permission ownership has been changed now. And it was S11 might has been changed from S Burma to unix eight min. So let me do one thing, like we login to my client, three as well, and let me create the user as well. Use it in your next. I have created this user on the client Clean Machine. Now again, I'm phi the same command. And I can see the two servers. They have found. The file is already there with the same permission which I'm want to do it. So on plane one and plane two, it didn't change anything. On client three, they have found this file, and the file was with S1 ownership. So they have changed the ownership to your next idea. So with this way you can, you know, do the tinges with using file Module. One more thing, if you want to delete any directory and the file from the destination, you can do the same thing instead of this here. I wonder delayed. So what I can do here, I can mention this tilde is equal to epsilon. So this command will try to delete this file from all the host. So the file has been bigoted, admin cross check. I can see the file is not available on the plane machine. So that's all for this lecture will be to understand how we can use this. And I'll come on to do your operations, day-to-day operations. Thanks for watching and if you have time, please. Jan Friedman, the next lecture. Bye, bye. Check here. 20. AD Hoc-Practice Lab Session - 3: Welcome to the lab session of ansible. So in this lecture we are going to understand few mood aspects of few more testing it related to the adult. Come on. So let me first login to my ansible server. So in this lecture we are going to understand how we can put some content on the files, which is already at the string On the destination. So was, suppose, you know, I have some content and I want to put it on all the files. So all we can do this. First of all, let me create a file. So this is a file here. I'm just copying. First of all, let me create a file layer touch. And so I have just copied the file that is vectors to all my destination. Let me come to my this leg machine. This file has been copied and you can see its size is 0. You that might want to put some content on them. So I will be using ansible hyphen copy attribute. So this is the content I've put it in my file. So destination would be this one that is vectors. Okay? Testing. Some type of mistake is here. Let's see this because it has started with single quoted here. So this has been done. Let me come to the file of a, let me come to check in my client machine. You can see that in the client machine I can see the content in the practice file and later it was empty. So with this, come on, what we have done, we have done two commands here only. So first command is to copy the file practice. And second is just to put some content on the file so that this command, if again I will find the same command, the ansible is intelligent enough. It will not do any changes because the content is trying to copy it. We'll find that the content is already there. So it is not going to touch the file. So this is the beauty of ansible. You can see. Suppose I am doing some changes like I wanted to use the content, right when do the changes. So ansible 1.2.2. So with these commands, it can do a lot of things on the client machines. So guys, I will request you is Todd doing practice, whatever the commands I have shown you in my lab sessions, do it form yourself. For that, you will have some confidence how we can stop automating that different tasks in your environment. And if you have any confusion, please put your carry into the cushion Ansar forum or you can dedicate lease to me as well. But I take care. Thanks. And if you have time, please join with me in the next lecture. 21. Command & Shell Module Differences: In this lecture, I am going to discuss about the difference between Come on and shell module. The command module allows administrators to quickly execute remote commands on managed host. It means that suppose, I just want to know what is the operating system was done running on all mine managed host. Or I just want to know what is the uptime of all, all my managed host. So for such type of task, we always prefer to use the command module. But Command Module has few limitations. That is, the command module are not processed by the shell on the managed host. So what is the impact that that impact is that whenever you are using the command module, then at the manifest holes, the command module is not able to use their variables, their environmental variables, they are local variables, they are global variables. And because of that, few operations are not permitted. Like if you want to use the redirection in your command, if you want to use the piping. So those commands will not fall. For situations where commands require shallow processing. Administrators can use the shell module. So if you have such type of command or such type of war, we have the cell processing is required, then use the shell module instead of the command module. So here we have taken the example. Suppose I just want to know the value of the set command. So set command is basically fill around the set command on any server. It will list you what all the variables that is available on your system. That is your environmental variable, the system variable and the global variables. You are local variables. So if you're firing with the command module to get the set command output, it won't work for that here you have to use the shell module. So I just want to show you and civil hyphen am. So first I am using the command module hyphen a and a. I just wanted to know the output offset. Come on. And I can see that the command module is not able to get the output of the set command from all my servers that is defined under the deaf group. So for that, you have to use the shell module that's on here. You can see that I'm getting an output. So for, and that's all for this lecture. Hope you got an idea that difference between the modules where you have to use the command module, where you have to use the shell module. So that's all we'll see in the next lecture. Bye. 22. Implementing Playbooks: In this lecture, I'm going to discuss about the modules. In the previous lectures, we had used modules in and out commands or playbooks. Modules are programs that ansible uses to perform operations on managed host. Managed host is your client machines. They are ready to use tools designed to perform a specific operations. Modules can be executed from the ansible come online, that is, adopt common are used in playbooks to execute the task. Suppose I want to do some astonishing. I want to execute some script. So for that, I'm going to use the yam module or script module. So you can use the module as per your requirement. So when you run, modules are copied to the managed host and execute there. So all your modules are present on your control mode, that is your ansible server. And one you, once you execute your playbook or an outcome on the specific modules, are copied to your managed host and then it is executed. So this is how it works. And civil comes packaged with over 500 modules available for use. This pre-packed modules can be used to perform a wide range of tasks, such as cloud user, packet, and service management. There are three types of ansible modules. The core modules are included with ansible. So once you install the ansible, the core modules are shaped by uncivil, which is written and maintained by the ansible development team. Core modules are the most important modules and are used for common administration tasks. Extra modules are currently included with ansible, but maybe promoted to code or ships separately in the future. They are generally not maintained by the ansible team but by the community. Typically these modules implement features for managing newer technologies such as open stack. So different, different communities, they are getting their own modules, like they're creating models for the open stack. So you can use the extra Morrill As well. So extra modules are currently include dividend civil only. The next is your extra modules. So extra molecules is also currently included with ansible, but they may be promoted to core OS ships separately in the future. They are generally not maintained bad ansible team, but by the community. So various community they are walking for the modules on danceable. So if those modules has been prepared by the ansible team, so that would be the core modules. And if any modules that has been prepared by any community. So that would be come under the extra modules. Typically, these modules implement features for managing newer technologies such as opening stacked. The next is your custom modules. So custom modules are models developed by end-users. Suppose I am using an signal for my environment and I have to do, I have to perform some specific task. And to perform this task, I didn't get the required module, which is not present as a, which is not present in your core module as well as in the extra module. So in that case, what I can do if I have a good knowledge on Python, I can create my own module. So if you have created your own modules, so that comes under your custom module. If a module doesn't already exist for a task and administrator can write a new model to implement it. The core and extra modules are always available. And symbol looks for the custom modules on the control node in the directory, this one. So if you want to look, you have to simplify this one and signal and a score. It's a library. Core and extra modules are always available. And simply looks for a custom modules on the control node in directories defined by this variable. On record enterprise line x seven or eight modules are installing the villa location. So let me show you if I want to see what all the models we have, you have to go into this location and then this one. So this is my RH Elliot. Elliot. We have Python 3.6 and the heavy after go inside this one and a lot of directories are there. You have to go inside and symbol. And again, you'll even see lot of directories are there. And you have to go inside the modules. Okay? And I'm on this location here, you can see the modules are there. So this is the location where we have all the core and custom modules. Module categories for better organization and management. And say, well, modules are grouped into the following functional category. So these are the categories we have. And apart form that the module documentations. So if you want to have, if you want to read any documentation regarding any modules, you can go to this website. Here we will get the detail about each modules and you can read anything about them, Sibyl hair. And also you can get the detail about modals in your system itself. And let me show you, suppose I want to know the detail about the year module. So you have to use the command ansible, desk dot and anybody limb. Suppose I want to know about the young. So here you can see this is the location we have where we have this molecule. And you can see this is the location and this is my, this is, this model is maintained by the ansible quote him. So this is a core module and all options it is coming here. And a few examples at the end you will see. So if you want to use any modules and if you have any confusion. So what you can do in the last, you can see the examples here as well. So here you can see it has used the yam module and this is the way you can use the module in your playbook. So all options are saying, install the latest version of our partner. You have to use this one. And if you want to install the latest version deposit from the testing rapport. So this is where you can use. So this is the represented tree from where you want to install this package. If you want to remove any package you have to use, the state is equal to epsilon. So for, and that's all for this lecture. Hope you got some idea about the modules. So that's always in the next lecture. 23. Lab-Implementing Playbooks: Hello everyone and welcome to automation with ansible. So this is a lab session in which I am going to show you how to create a simple playbook. The playbook, which I'm going to show you, is just to check or to start any services. So what I'm going to do here with this playbook. So the service which I'm going to check that as VSFTPD. So it will check that particular service we have, VSFTPD is running on all your client machines. And if it is not running, sweet willie, start that service. This is what I am going to perform with my playbook. So I've just logged into my ansible silver and I'm this location, I'm going to create a placebo so you can give any name, but the extension should be dot YAML. So we always start with two dashes and single DES Host. So what all the host you want to perform. So I'm taking all. So it means that whatever the, you know, suppose we have in this group, this playbook is going to run on that become is equal to true. So it means that the communication between both the client and your ansible several would be normal. But whenever it will perform this playbook, it will first elevate its privilege. We know that to start any service or normal user doesn't have that much of permission. We should have the service would have the root then only they can perform this operation. So let me plug in, let me put few more entries. This one become rude. This is, so what it will become, it will become root. So what is the task here? So we have to very much cautious while cutting this playbook. Here, you have to know very much cautious with the spaces and where you have to start. The same way which I am doing here. You can write your label. So stop VSFTPD service. So I'm going to use a module here that is obvious. And which service I want to check. This is VS FTPD. What it will check the status. It will check the estate should we started? If it is not as started, it is not running, it will started. So this is what a simple playbook I have written here. So ansible hyphen F unlist, host all. So this playbook is going to run on all the service because I've mentioned all here at the host. Okay. So let me first cross-check. This is my client one system CTO, status, VSFTPD. It is running. Let me stop it. Okay. On this blank f2, let me check the version. It's not until seven, so system CTO is also running. So let me stop it. So claim one and claim full stop. And this is my this is my uncivil, so this is my claim to how to chill seven system CTO. So in this blank to the service is not as tall. I am bit plane 12. We have one more solar that is Claim three. So let me run this script claim. So this ansible playbook service, I've been capital K. I'm getting a syntax error. So it's good if you have this inter status. So because we have fathered this. And I again, I'm good on it. Now I started running my playbook. It has gathered all the service law, starting the service on two servers. It has started to service this client one and client foo. And inclined to and client three, we can see that it didn't find the Soviets because service is not install on the servers. So let me first cross-check with the client one on which the Soviets has already started. This is what we already know. Don't plan to, the service is not there. That's why we have got this error. And on client folder service has been started. It is running now. And client one, we have already stopped it statistically changing from state to state. So this is a simple playback which I have created just to, you know, check the status. Or we can say just to start the service. And if it is not a started, the ansible playbook is intelligent enough. It is not going to test the service which is already in running a state. So for, and that's all for this lecture. Hope you have got an idea how we can start working on getting a smallest mall playbook. And in the later lectures we are going to create a very more playbooks, complex playbooks are nobodies. So that's all for this lecture. If you have time, please. Jan width in the next lecture. 24. Playbook for copying a file: Hello everyone and welcome to the lab session. So in this lab session I'm going to create another playbook. And that playbook is just to copy the file. So it's another simple playbook I'm going to create for you. So I'm in this location, I'm going to create a playbook. I'm giving it this copy file dot HTML. You can give any name. Insert thi does, is it always top single, dest host. All become too, is equal to root. Task is my copy the file. And here after use the module that is copy. So with copy model, I can use a lot of things like the file I want to copy. I want to copy a file that is placed in my tmp location. And I'm going to create a file ABCD. You can get any file if you have any file that you want to copy it to all your servers. So you can put the same location of the file that you want to copy and where you want to copy to your destination server. You can specify, I want to be on ten. And if you want to give any under the name, you can give sliced ham and if you want to, whenever it will copy with some different name. So like x, y, z. So ABCD will be copied there as x, y, z. And the female condition, I want that the ownership, the owner of the file, that would be your next idea. And I want the group should we rule, right? And the permission on the file I want it should be full permission. That is 777. So this is what I am going to do. So very simple playbook I have created. So one more thing, Unix ADM uses should be exist on all the servers. So I'm going to clear the Unix ADM on all my time machine. So this is my first user. Unix ADM. Good, it's created here. Let me cross check. It's already there. It's already there. Let me cross check for this one. The last one that is, I think it is not heated. So I have created this user on all the servers. And coming back to my this and just get this file. So these are the entries. So let me cross check this file is there or not. So I am going to create this file here. This is a test file to check playbook for copy. Mario. Anything you can put. Now, I've created this file. Let's see the ownership. So showing s, What am I swim. So when it will be copied, the ownership should be changed from S1 to unix ADM. So ansible playbook. And this is my playbook name, capital K. Now I've done it for all the souls, all the service, gathering facts. I it has been done. Let me cause check. This is my client for I can see this file has been copied and it also changed ownership. And also you can see the permission as well. Fantastic. And this server. And I can see that with a simple playbook, I'm able to copy a file from my source server that is my ansible terrible to all my client machines. So this is a very simple play which I have created. So I am again opening it. So this is what I have done. We can do some condition as well, like suppose I want to copy this file and my condition is that a should be copied to only redhead distribution only. So we can put some condition as well. So this is what we are going to understand in the next lecture. So that's all for this lecture. And if you have time please, John Whitman, the next lecture. Thanks. 25. Lab on copy a file with conditions: Hello everyone and welcome to the automation with ansible. This is elapsed ISN. So let's continue. In the last lecture. We have simply understand how we can copy a file from your control node to all your clients. So let me CAD this playbook. So I'm going to put some condition in this playbook, how we can do that. So the condition is that when I want that my this file, it should copy only to the redhead distribution. In my environment. Suppose I have the souls. They are from different flavor of Linux. It could be your federal CentOS, but I want that it should copy only to my red distribution then how we can do that. So Linux, ansible underscore distribution, redhead. So, and I'm going to change this file because this file is already created, so I'm going to create another file. Okay. And let me check what are the Wasn't that we have and Sibyl hyphen. So I have redhead rated t at n and one CentOS in my this all group. So in all group we have fossils. Out of fossil was the 3R redhead, and one is your CentOS. So when this playbook will run, it will copy this file, this one, ABC d1. It will copy to all the redhead distribution and it will skip this source. So let me show you. So I'm going to create a file. Okay? Now it is running. It has gathered all the solos skipping the facility. You can see that it has kept the solvus line too wide as you can see here. The client two is my CentOS. If I'm willing to login into plane two. This is my client too. And if I will search for the file that is ABCD, one, it is not there. If I'm willing to check on how those levels, like ABCD, one file is there. I'm going to do one more condition here. You can see that I have. So therefrom redhead and S2 is indebted also we have the Wasn't like 76. Now my another condition is that I want that my copy should be to direct distribution. And one more condition which I am putting here. Distribution that is misery, novel isn't so ansible underscore distribution. Understood? Mesmer was a seven to two condition upward. One is the redder and redder it also is should we wasn't seven if it wasn't six. So it is not going to copy the file. And one more thing, I'm going to again create another file that is two. So this time it should just skip to sell those funds to those CentOS. And second is at a gym. Six, here you can see that it's keeping to sell was this one is your s2 is, and this one is, but it is added to the six. Here you can see that this is Article six. If I'm going into this, this is climb tree. If I'm going to search for the file abcd to, it is not there. If I'm going into other server, the file has been copied now. So that's all for this lecture. Hope you have understand how we can put the simple condition. So thanks for watching and if you have time, please join with me in the next lecture. 26. Introduction of Modules in Ansible: In this lecture, I'm going to discuss about the modules. In the previous lectures, we had used modules in and out commands or playbooks. Modules are programs that ansible uses to perform operations on managed host. Managed host is your client machines. They are ready to use tools designed to perform a specific operations. Modules can be executed from the ansible come online, that is, adopt common are used in playbooks to execute the task. Suppose I want to do some astonishing. I want to execute some script. So for that, I'm going to use the yam module or script module. So you can use the module as per your requirement. So when you run, modules are copied to the managed host and execute there. So all your modules are present on your control mode, that is your ansible server. And one you, once you execute your playbook or an outcome on the specific modules, are copied to your managed host and then it is executed. So this is how it works. And civil comes packaged with over 500 modules available for use. This pre-packed modules can be used to perform a wide range of tasks, such as cloud user, packet, and service management. There are three types of ansible modules. The core modules are included with ansible. So once you install the ansible, the core modules are shaped by uncivil, which is written and maintained by the ansible development team. Core modules are the most important modules and are used for common administration tasks. Extra modules are currently included with ansible, but maybe promoted to code or ships separately in the future. They are generally not maintained by the ansible team but by the community. Typically these modules implement features for managing newer technologies such as open stack. So different, different communities, they are getting their own modules, like they're creating models for the open stack. So you can use the extra Morrill As well. So extra modules are currently include dividend civil only. The next is your extra modules. So extra molecules is also currently included with ansible, but they may be promoted to core OS ships separately in the future. They are generally not maintained bad ansible team, but by the community. So various community they are walking for the modules on danceable. So if those modules has been prepared by the ansible team, so that would be the core modules. And if any modules that has been prepared by any community. So that would be come under the extra modules. Typically, these modules implement features for managing newer technologies such as opening stacked. The next is your custom modules. So custom modules are models developed by end-users. Suppose I am using an signal for my environment and I have to do, I have to perform some specific task. And to perform this task, I didn't get the required module, which is not present as a, which is not present in your core module as well as in the extra module. So in that case, what I can do if I have a good knowledge on Python, I can create my own module. So if you have created your own modules, so that comes under your custom module. If a module doesn't already exist for a task and administrator can write a new model to implement it. The core and extra modules are always available. And symbol looks for the custom modules on the control node in the directory, this one. So if you want to look, you have to simplify this one and signal and a score. It's a library. Core and extra modules are always available. And simply looks for a custom modules on the control node in directories defined by this variable. On record enterprise line x seven or eight modules are installing the villa location. So let me show you if I want to see what all the models we have, you have to go into this location and then this one. So this is my RH Elliot. Elliot. We have Python 3.6 and the heavy after go inside this one and a lot of directories are there. You have to go inside and symbol. And again, you'll even see lot of directories are there. And you have to go inside the modules. Okay? And I'm on this location here, you can see the modules are there. So this is the location where we have all the core and custom modules. Module categories for better organization and management. And say, well, modules are grouped into the following functional category. So these are the categories we have. And apart form that the module documentations. So if you want to have, if you want to read any documentation regarding any modules, you can go to this website. Here we will get the detail about each modules and you can read anything about them, Sibyl hair. And also you can get the detail about modals in your system itself. And let me show you, suppose I want to know the detail about the year module. So you have to use the command ansible, desk dot and anybody limb. Suppose I want to know about the young. So here you can see this is the location we have where we have this molecule. And you can see this is the location and this is my, this is, this model is maintained by the ansible quote him. So this is a core module and all options it is coming here. And a few examples at the end you will see. So if you want to use any modules and if you have any confusion. So what you can do in the last, you can see the examples here as well. So here you can see it has used the yam module and this is the way you can use the module in your playbook. So all options are saying, install the latest version of our partner. You have to use this one. And if you want to install the latest version deposit from the testing rapport. So this is where you can use. So this is the represented tree from where you want to install this package. If you want to remove any package you have to use, the state is equal to epsilon. So for, and that's all for this lecture. Hope you got some idea about the modules. So that's always in the next lecture. 27. Lab-Invoking Modules: This is a lab session on modules are let me quickly login into my ansible server. This is my ansible server. And I'm going to show you are installing a package on managed host. Why ad-hoc come on using a module YM. So first of all, let me show you the list of host our half on which I am going to do the installation. So I have already created our group that is proud group under which we have to Servo's client one and client tool. And I'm going to do the installation of a package that is three package on these two servers. So let me first login to my client one. Okay. Rpm hyphen QA, grep, I found I three. And I can see that three packages not install on client one. Let me login to my client too as well. Pm hyphen hyphen item three. I can see that T package is not install on both the client machine, that is client one and client to. Now, I'm going to use the command that is ansible and hyphen m. That is module, the module I'm going to use the yam module. Make sure that ym is working on all your client machines. Your client machines should be connected with your local server or the satellite servers, whatever you have configured. So for the testing purpose, what I have done a half credit, the local yum. So what I have done, I've simply mounted my CD drive. You can see that. So this is my SAT drive here I have Monte, and under this I have created a file that is solver.py Apple. And I've given the location, right, because the Yom is simply going to use the yam module. I'm going to fire the come on. But at the client and you client should be connected with the proper repository. Ok, so you should be working. Here, I'm rapid list. It should be walking at all your client machine. Now, ansible hyphen M is module a. And I'm going to install the package. That is three. State should be present. So this is my requirement. I won't install the package. So here you can see that I have logged into the system as s1. S1 is a normal user which doesn't have the permission to install any packet. So for that I have to use Become, so it is going to login to my client machine as S1. And then before you know, installing the package first IT will alleviate its privileged from S1 to root user. And capital K. That is, we need to provide this to the password. I got some error at data missing target host. I have forgot to mention the. Target that is prod. It will take a few seconds. And I can see that install change is true. It means that the changes has been done. Let me see. The package has been installed. I can see that tree package has been installed now, right? So, so this way you can see that how we can do the installation of a packet. And if you want to remove a package the same packet, instead of present, you can just manage an absent. So this command is going to remove that tree package from both the client machine, that is client one and blind to changes has been done. Change is equal to two means some changes has been done. Ok? Again, if I'm going to fire the command, you can see the package has been, you know, not showing the same from my client one as well, RPM IF and QA. Okay, this is one thing. Let me try to install some other package. So instead of this C, I'm trying to stall the packets as two deputy. Okay. And the status should be present. So this time I'm trying to stall the Apache package as HTTPD genius has been done. Here you can see T is true. It means that chain has been done on my client too. Line one as well. And you can see the STD package has been installed. System CDM status, httpd package has been installed. Bus service is not, is started. So let me try to start the Soviets as well. So this is my client machine. This is my ansible server, and this is my client machine. So the package Apache HTTP server has been installed, but the service is not as started here. I'm going to start the service as well. So for that I have to use OK, I have to change the model as well. So that is something I did with the Soviets because I have to start and stop the service. I have used the model's obvious here. I find a and the name of the package is my aesthetic beauty. And instead, I wanted should be started. Okay? So if services already started, it is not going to do anything. If the service isn't a stop is tip is going to start. Genius has been done now. Okay. Okay. Come back here. I've just come back to my client machine and I can see the status of a service. It is inactive, right? Same. Come on. I'm going to use my client one as well because I'm doing the same changes on both of my client. Okay. Now one thing that you are seeing that this isn't disabled state, it means that if you're going to reboot your system, so this service will not come up. So if you want to make it unable, like if we'll take the reboot, the system will come up with this service. You have to make it unable. So this also you can do with the adult come on. So for that here you have to use this one instead of this you have to do here, you have to use enable is equal to yes. And if you want to, you know, in the same command you want to check both the things like the Soviets. If it is not as started, it showed a start. You're gonna use state started. So with a single command, it is going to start the Soviets as well. And also it is going to enable your service as well. So that's done now, coming back here again, I'm going to fight this command. And I can see it is unable. I believe it was showing disabled. Here, you can see that. So for themself up this lecture, hope you got some idea how we can use the adult commands for the stylish and of a package. So that's all we will see in the next lecture. Bye. 28. Idempotent Behaviour of Modules: In this lecture, I'm going to discuss few important points that you have to keep in mind when you write a playbook. When possible, try to avoid the common shell and draw modules in playbooks. Because these modules take arbitrary commands and it is very easy to write non identical ten labels with these molecules. So in simple words, these modules come on shell and draw modules. Dear behavior is non-ideal port ten. So we need to understand what is non item put ten and what is idempotent. So I have taken a very simple example. Here you can see one playbook, very simple playbook in which I have used shell module. So this playbook is basically an outputting this content that is name server space, some IP into this file. And when you run this playbook, obviously, you are going to run this playbook against few hosts overs. So it is going to look for this file and putting this content. First time when you run this playbook, it is going to put this content second time if you run the same command, same playbook. So what will happen second time also, it is going through the same exercise. It is not going to check whether the content is already there on not. Again, it is going to edit this file. It is going to remove the previous content. I'm going to put the same content. So each time when you run this playbook, it is going to, you know, putting the same content again and again. So this is called non-identical ten behavior. So these modules come on shell and draw, they are now non-identical ten modules. So what is the solution for that? So the solution is that instead of this shell module, you can use the copy module. So this copy modules, its behavior is item per ten. So this is the destination file and the same content I want to put into this file. So the copy module is a special purpose and can easily to test, test to see if the state has already been mapped. Suppose first time I have run this command, it is going to put the content. Second time. Again, I'm going to run the same playbook. Second time. It will check that the same content is already there in the file. It is not going to edit the file. It is not going to do any changes on the destination file. So that is called idempotent behavior. So I didn't put ten playbooks can run a repeatedly to NCO systems are in a particular state without disrupting those systems if they already there. So that's the basic difference between identical and non-identical ten. Suffering, that's all for this lecture. I hope you got some idea. And the next lecture we'll do the lab session of the same. So we will see in the next lecture, Bug. 29. Lab-Idempotent Behaviour of Modules: This is a lab session to understand the behavior of non-identity. Put ten and I then put ten modules. So this is my ansible, so I'm at this location and I am going to create a playbook using module shallow. So I'm giving this non item portent dot YAML. It always started with g dishes desk host. And the for testing purpose, I'm going to create a group. And the group, I'm going to put only one server. So I'm putting web so become as equal to true. Become a desk, a user. I want it shouldn't become a road user. Dusk with shell modules. Okay? And here I'm going to use the Shell Eco name. So 12 due to 168 dot 0 dot one. And this content I wanted should be going into any temp file. I'm going to be ten. And that is all dot cough, any file you can put here, I'm just doing the testing. That's all militiamen come out. So here you can see that I have used a website. Okay, I'm going to, you know, add in this file. And so I have created one group that is web silos, and under which I have used only one client, that is Klingon. Okay, so everything seems fine. Like me cause check and symbol. Hyphen, hyphen list. Host will episode. I'm going to run this playbook ansible. Okay? And the name of my playbook is non this one. And that is capital K. That's all. Before to that, let me along into my client machine as well. So as of now there is no result.com file is dead. So that's done now. So some teachers has been done because check the file has been created. So the file has been created now. Okay? Okay. Now the same command, I'm going to run it again. Okay? And let's take the timestamp as well. Okay? So again, I'm going to find the same common. Let me wait for a few more seconds so that the second minute will be K so that we can cross verify. Here you can see that these time it is doing some tinges, changed a little bit that you can understand. It is doing some changes, changes. You go to one. You can see the time stem has been changed now. So this is called non idempotent behavior. Okay? Again, if I'm going to run the same command, again, it is going to open this file, editing this file and putting the content. Okay? So this is one thing. So solution is this is my, okay, let me copy this one. And this one, non item portent. Okay? So here what I'm gonna do, I'm going to use this. First of all, let me change this one and copy. Copy and a destination. And I'm giving dissolve one dot. And the content, what do you want here? This is column contended i1. It should be name so and 100, No.1, 68 Dodge, 0.01. whatever you want. So here you can see that I have used copy module. Okay, again, I'm going to run the same command. Okay? So the file is not there. You can see only one file. The file has been created. Now you can see that this has been done. Let me get this one. So this time it has kicked him this result. This one resolve one. Okay. Again, I'm going to run this one. So this is a, this is a, I then put him approach with copy module. So it is not going to do any changes because it will check the file. I will find that the file is having the same content. Now you can see the change is equal to 0. It means that it has not done any changes on the file because they have Chegg and found the content is already there. So this is called idempotent behavior. So that's all for this lecture. Hope you got an idea about how we can write a playbook with different aspects in mind. So that's all we'll see in the next lecture. 30. Multiple tasks in Ansible Playbook: Hello everyone and welcome to automation with ansible. This is a lab session in which I'm going to create a complex playbook. And that playbook is basically for the installation of Apache web server. We all know that there are a lot of his taps which is required for the complete is totally shut off Apache web server. So this is what I'm willing to do with the playbook. I am going to put all the steps. I'm going to put all the tasks one by one, which is required for the installation of Apache web server. So what are the steps for this college and our budget web servers? Let's understand this first. So we are going to create a playbook for the polish on our budget website. So we should know, first of all, what are the steps for that. So staff for less tolerant of Apache of episode. So very first step is a stall latest package of STDP D. So this is the first step. Second step after this transition, you need to stop and unable. Unable though, as TTP disservice, You have to stop the service as well as enable. Enable means. It will take the reboot that server. We'll come up with this obvious. The third step is install latest package for firewall d, if you are using an editorial seven. So this packet is already installed, but I would include this task as well. And the next tab is same as top and unable. Firewall de service. Fifth step, that is that now you have the firewall that is running on a Web server. So a lot of incoming request will be reaching to your web server. So you need to know, permit the HTTP service at the firewall labeled. So you have to perform it. Permit as TTP service at firewall. These are the steps we have to include while creating the playbook. Sixties you create simple. As T AML webpage. Seven would be defining defining web server name. Like suppose my gland is client one, so I want my web server name would be www dot Klein one dot example.com so that anybody, if they will try to access my web server. So they have to type this at the browser, www.example.com if you want it and gave it some of that as well. Seven is your update, its entry in ETC, host file. So this is what I am going to do with my playbook. So why I'm telling you the steps? Because you know, if you're going to do something, you should have the backbone. So with these steps, I am going to create the playbook. So friend, that's all for this lecture. In the next lecture, I will be continuing from here. So thanks for watching and if you have time, please join with the next lecture. 31. Lab - Multi task Playbook - 1: Hello everyone and welcome to automation with ansible. So welcome to the lab session. So as of movie ever understand the steps for this toleration of a positive epsilon. So let me login to my, this ansible silver and K the label. So you can give any name, Apache web server establish and Ow.ly MLA. So as usual, I will start with CSS here. Now the first task, task would be this one. Install Data spec is of a budget that's tall, latest package of HTTPD. For that I would be using yum. Hereafter we specify the name, which pack-a-day wonders tall, HTTPD is table would be latest. So your first task is this 1. Second task would be A-star that enabled us to give me so as top and S22 DB service. So for that I wouldn't be using a module service. Name is my S two deputy, so it shouldn't be a neighbor. And also a state wouldn't be you started. Now coming to the third task is to formulate the spec it for five already. I'm using them for that name. Five all is leakage. And I need to make sure that it's solvus. I should we started a student. So I just copy and pasting here using service. Five or D enable true. And state would be my started so that it would we started a state if it is not. And also it will just enable the service as well. Now, coming to the next poem is permit SCTP Soviet that firewall. So my, this, this is my fifth task. Fifth toss would be this one. Stdp service. I would be using this module that is five volts. And that I would be using service. So this is my STP, STDP. And I wondered should be permanent. True is good. It should be I enabled and I to should be mediated. So the changes would be immediate only. So this is what you have to do it if you want to enable any service at the firewall. So simple, I have use the module firewalls and specify the service name and permanent state enabled. That's all. Now, my next task would be the sixth one is create simple estimator webpage. So create a simple HTML webpage. So how we can do that? For that, I will be using a copy module. And here I would be specifying this content. As my welcome to ansible. Lemming goes modular. You can put any matter. And where I want to put destination wouldn't be mine. This one where www SHA1 and that we have the file index.html. So it is going to update this file. This file would be there. It will put this content. And if this file is not there, it is going to create this file. Okay, coming to the next one defining the web server name. So my web server name is www.example.com. So for that, I would lose in name. Defining web server name. Here I'm using a model that is line in file because I am going to put this entry in this ETC. Httpd. And that we have the file, and the file we have the main configuration file of your aesthetic beauty, that is your HTTPD.com. So I want to put some content. So here I will be using this line in line file, this module. And the path where it is, it is in this ADC and HTTPD khan STT equity.com. Why, why I'm using this module? I am telling you because I want to insert this line, I won't be insert this after specifying some, you know, after a specific line. Let me tell you, insert after this. So this is my line. This is my file name path. And what I want to insert a line, this server name is www dot Klein, one dot example.com call an empty. So what will happen? This line will be inserted into this file, and I want that where it should be inserted. If you are not specifying this insert after that, what will happen? This line will be inserted into this file at the last of the line. But my requirement is there I want it should be inserted after a line. This one. Insert after this one, it will go to this file. You will find this line, this one server name. So I want that this line should be inserted after the line started with hash server name. Ok. And one more thing I need to update that is update its Antonin, ETC, host file. So name, update its entry in ETC, host file. Again, I am using the same line in file module path where you want to add this line, you have to specify the file. Myfile would be this one, ETC, host. And what do you want to add line? I want to add this the IP of my web server, my client, that is this 1139. And it should we added like this. Ok, so all has been done now. All the eight step has been done Now, let me come out from that. Okay, so this is what we have done. We have created a simple playbook here. You can see that what are the things we have in this file? It's very simple. First, it is stalled early suspected of Apache. Then it will start and enable the HTTP service. Then it will stall the firewall D it will start and enable its services. And then it permits the STDP service at the firewall level and will create a simple HTML page that you can see. Welcome to the uncivil learning. And also we should have, you know, some web page name as well, website page name. So here I have given this www.example.com and it should walk this. And I want that this entry should be added into this file. I'm after this line. So if you open this file, there will be lot of lines. I want. This line should be inserted into this line, this file, and it should after this line which started with hash server name and updated 17, it is the host file as well. If you're not specifying anything here. So what will happen? This entry will be added at the end of this file. So for herself, for this lecture and the next lecture, I'm just going to execute this file for you. So thanks for watching and if you have time, please. January the next lecture. 32. Lab - Multi task Playbook - 2: Hello everyone and welcome to automation with NC. Well, so let's continue. In the last lecture, we have simply create the playbook for the Apache web server installation. So the webpage which I had created, it was this one. So let me first check the syntax error. So for that we have the command ansible playbook and then sin tax refund check. And the name of my webpage. I'm getting some syntax error. Maybe I've done some mistake in the file, my playbook. So let me cross check what happened. Here. You can see that I haven't specified this task. So this line I have missed, taken so many task. I have created so many tasks, but at the starting, I have just forgot to mention task. Again, I want to check this, let see. Now everything seems to be fine. It is saying that you are good to execute this playbook. So let me cross check that my client as well. So this is my claim. Rpm hyphen QA, grab hyphen I, HTTPD. So let me just check whether the service has been installed. This package is not as strong. This is tool, this is different, but I won't STD beauty, it is not as tall. System CTL, firewall status, firewall D, it is not loaded. It is in inactive state, so all seems fine now. And the name of my web page is this one. Let me pin this ellipse, this one. So it is not working at all from the silver and I'm trying to access this website. It is not working because it is not cluttered here. Now I am going to execute my playbook. Uncivil. Label. This one. Let do one thing. Let me do it one by one. So for that, we have this step. Yes, it is getting the facts. First task, it is time to install the package, that is STDP. Install latest package of as T, T p T. It's done now, let us cross check it. The claim. I can see the package is showing they're now coming to the next task. That is start and enable the solvus. So the system CTL status as HTTPD is dead now, after the execution of this next task, it will start at the starting and enabling the service. And I can see the service is running now. Install latest package of firewall. It is saying that green means it is already installed. R is asking you won't do start and enable the firewall services. I said yes, I am claim. Let me check it out whether the service is started now. Now by both the Soviets had been started now now it is asking for the permit HTTP service. So how we, how we can check that the Soviets IS permitted or not. For that we have the common firewall, the cmd. This is my default Joe, getting some error. Miter showing that STDP services already unable. Okay. So let me remove this service because I just want to show that after running by this task, this task, it will enable this so I can remove it. If I will DIE. Cmd hyphen, hyphen remove. Now it has been removed from the client. Now. Palm it this STDP surveys, so it will allow this. I'm putting years done now. If you want to cross check, you can see the Soviets element independent all. After running my task geared a simple webpage here. So let me put yes here. And then defining web page as well. So let me cross check what it is doing this. So basically, you know, it is that file as to this. We have this file as HTTPD.com. So I want to add a line after this line. This is silver name, this one. So here I'm continuing it. Done and ETC, host file also done. So let me show you whether this entry has been added or not. You can see the entity has been added now. And also let me check it. Any DC host file. Host file also does showing there. So everything is done now. Now I'm going to check with my feelings. Come on a links WW dot one dot example.com. You can see that the web server, which I'm trying to x's from ansible server to the client one plane. What is my web server now? Which I have created with the playbook? And I can see that the webpage, it is opening now. So for him, that's all for this lecture, but we have understand how we can create the complex playbook in which we can define so many tasks. Step is taps. So thanks for watching and if you have time, please. Jan Friedman, the next lecture. 33. Syntax Verification & Dry Check for Ansible Playbook: Hello everyone and welcome to automation with ansible. So in this lecture we are going to understand about executing a diagram. Executing it right? It means suppose if you want to run a playbook, but before to actually run the playbook, you want to cross check like if I'm going to run this playbook, but that there's playbook will run successfully or not. So in that case, you can use capital C option, which will do a dry Jack. Actually, this playbook, if you're using with C off, since the playbook is not going to do anything on the surface, they will just, you know, cross check whether this playbook one set will be running on the service. It would be successful or not. So for that you can use competency opsin. And this causes ansible to report what changes would have occurred if the playbook were executed. But it doesn't make any actual changes to the managed horse. The following example C shows the driver of the playbook containing a single task. So let me show you how we can done it. So this is my ansible server and have this playable, this playbook we have already discussed. So this playbook is basically running these other tasks we have. You can see that for five tasks we have in this playbook. So I would be running this as a dry Jack. So, so to run this dry check, we have this option, playbook, deaf, uncivil desk label, the name of the playbook, capital K. I wanted should ask for the password whenever it will elevate its privilege. And capitals sees for the direction. So it will run as a dry check only chain Ms. once it flip era, it didn't get any issue. So this playbook has checked like all the parameters, all the configuration at the client end is correct or not. So we have got an output now, if you want to run it without removing this capital C. So actually it is going to run this playbook Honda managed host. So this is the first thing. Second thing is that suppose you know, this is syntax verification. Suppose if you have created a playbook and you want to check the syntax. So for that we have the command ansible desk label, DES, DES syntax check. So it is always good to check the syntax before, you know, running the playbook. So very simple. Come on. We have, suppose you know, uncivil. So if you have created a playbook and if you wanted to check any syntax error, so you can take with this come on. The next thing is a step by step execution. Suppose if you have the playbook and in the playbook we have multiple task are there. And you want that it should run step by step. So we have to use this command. Let me show you how we can run it. So here I have used this deltas step and I'm just removing this, putting capital C, no issues if it is up to you. Say Tilden is Templates tab, right. We'll ask you gathered information. Yes. Now it has come to the second task. Nobody's asking you, you want to execute this? If you say yes, then it will move to the next. So this is called an step-by-step, step-by-step execution. So if I'm there so far this lecture, hope you have got these are the simple things which is very much required if you are creating a playbook. So thanks for watching and if you have time please. John, in the next lecture. 34. Apache Web Server Installation - 1: Hello everyone. In this lecture, I will discuss about conditionals in ansible. So that's a very important and conceptual topic of this course module. Ansible can use conditionals to execute tasks or plays when certain conditions are met. For example, a conditional can be used to determine the available memory on a managed host before ansible installs are configures a service. Suppose I want to install a package on all of my managed host. Suppose in my environment, 50 servers are there and I need to install a package, but I have a condition. My condition is that the packet should only be installed if the available memory on the Manage host should be greater than four GB. So this is our condition I have with the storage and of the package. So when I create the playbook, so in the playbook, I can use this condition. So when you execute the playbook, it is going to the server. You manage servers, and it is going to check the condition whether the available memory is 4GB or not. If it is not a shortest skip the server and move on to the next server. And if the available memory is more than 4GB, then it should install the package. So this way you can use the conditionals in Antebellum. So here we have few examples. Like you can use the Hod Lipson can be defining a variable, for example, Minimum underscore memory and compare it against the available memory on a managed host. You can also use the ansible facts. So how we can use the conditionals in ansible one writing that playbook. So you have to use the one statement. Sometimes you will want to escape a particular step on a particular host. This could be something as simple as not installing a sudden package if the operating system is a particular was n. So they have just given a few examples. Like you want to install a package, but you want to install a package only for certain distribution of the servers. Like you won't install that package on CentOS or you want to install a package on Debian. But when you define the solvus and a playbook, the numbers of servers are there. So with the help of when condition, you can define what exactly you want, whatever you want to escape. So here you can see a very simple example that is shut down the Debian flavored systems. So when you create the playbook and host, you have mentioned a group and the group that a lot of servers are there. It could be redhead in or it could be CentOS Debian. But do you want to shut down only the Debian servers? So here you can see that I have used a very simple task that is shutdown Debian flavored systems and the command are used for the Saddam, this one. And here I have used a condition that is answerable. Underscore. Underscore families shouldn't be Debian. So this is the n symbol facts I have used here. If I have not used this line. So what will happen if I execute this playbook? It is going to, you know, it is going to shut down all the servers that you have mentioned end up playbook that is in the host. But here I've mentioned this one. So whether in your mind, when you are in a group, whether you have the redhead centre is it doesn't matter. It is going to reboot only the Debian sellers. So if undersell for this lecture and the next lecture, I'm going to do the lab session on one statement. So that's always in the next lecture. 35. Apache Web Server Installation - 2: Hello everyone and welcome to automation with ansible. So welcome to the lab session. So as of movie ever understand the steps for this toleration of a positive epsilon. So let me login to my, this ansible silver and K the label. So you can give any name, Apache web server establish and Ow.ly MLA. So as usual, I will start with CSS here. Now the first task, task would be this one. Install Data spec is of a budget that's tall, latest package of HTTPD. For that I would be using yum. Hereafter we specify the name, which pack-a-day wonders tall, HTTPD is table would be latest. So your first task is this 1. Second task would be A-star that enabled us to give me so as top and S22 DB service. So for that I wouldn't be using a module service. Name is my S two deputy, so it shouldn't be a neighbor. And also a state wouldn't be you started. Now coming to the third task is to formulate the spec it for five already. I'm using them for that name. Five all is leakage. And I need to make sure that it's solvus. I should we started a student. So I just copy and pasting here using service. Five or D enable true. And state would be my started so that it would we started a state if it is not. And also it will just enable the service as well. Now, coming to the next poem is permit SCTP Soviet that firewall. So my, this, this is my fifth task. Fifth toss would be this one. Stdp service. I would be using this module that is five volts. And that I would be using service. So this is my STP, STDP. And I wondered should be permanent. True is good. It should be I enabled and I to should be mediated. So the changes would be immediate only. So this is what you have to do it if you want to enable any service at the firewall. So simple, I have use the module firewalls and specify the service name and permanent state enabled. That's all. Now, my next task would be the sixth one is create simple estimator webpage. So create a simple HTML webpage. So how we can do that? For that, I will be using a copy module. And here I would be specifying this content. As my welcome to ansible. Lemming goes modular. You can put any matter. And where I want to put destination wouldn't be mine. This one where www SHA1 and that we have the file index.html. So it is going to update this file. This file would be there. It will put this content. And if this file is not there, it is going to create this file. Okay, coming to the next one defining the web server name. So my web server name is www.example.com. So for that, I would lose in name. Defining web server name. Here I'm using a model that is line in file because I am going to put this entry in this ETC. Httpd. And that we have the file, and the file we have the main configuration file of your aesthetic beauty, that is your HTTPD.com. So I want to put some content. So here I will be using this line in line file, this module. And the path where it is, it is in this ADC and HTTPD khan STT equity.com. Why, why I'm using this module? I am telling you because I want to insert this line, I won't be insert this after specifying some, you know, after a specific line. Let me tell you, insert after this. So this is my line. This is my file name path. And what I want to insert a line, this server name is www dot Klein, one dot example.com call an empty. So what will happen? This line will be inserted into this file, and I want that where it should be inserted. If you are not specifying this insert after that, what will happen? This line will be inserted into this file at the last of the line. But my requirement is there I want it should be inserted after a line. This one. Insert after this one, it will go to this file. You will find this line, this one server name. So I want that this line should be inserted after the line started with hash server name. Ok. And one more thing I need to update that is update its Antonin, ETC, host file. So name, update its entry in ETC, host file. Again, I am using the same line in file module path where you want to add this line, you have to specify the file. Myfile would be this one, ETC, host. And what do you want to add line? I want to add this the IP of my web server, my client, that is this 1139. And it should we added like this. Ok, so all has been done now. All the eight step has been done Now, let me come out from that. Okay, so this is what we have done. We have created a simple playbook here. You can see that what are the things we have in this file? It's very simple. First, it is stalled early suspected of Apache. Then it will start and enable the HTTP service. Then it will stall the firewall D it will start and enable its services. And then it permits the STDP service at the firewall level and will create a simple HTML page that you can see. Welcome to the uncivil learning. And also we should have, you know, some web page name as well, website page name. So here I have given this www.example.com and it should walk this. And I want that this entry should be added into this file. I'm after this line. So if you open this file, there will be lot of lines. I want. This line should be inserted into this line, this file, and it should after this line which started with hash server name and updated 17, it is the host file as well. If you're not specifying anything here. So what will happen? This entry will be added at the end of this file. So for herself, for this lecture and the next lecture, I'm just going to execute this file for you. So thanks for watching and if you have time, please. January the next lecture. 36. Apache Web Server Installation - 3: Hello everyone and welcome to automation with NC. Well, so let's continue. In the last lecture, we have simply create the playbook for the Apache web server installation. So the webpage which I had created, it was this one. So let me first check the syntax error. So for that we have the command ansible playbook and then sin tax refund check. And the name of my webpage. I'm getting some syntax error. Maybe I've done some mistake in the file, my playbook. So let me cross check what happened. Here. You can see that I haven't specified this task. So this line I have missed, taken so many task. I have created so many tasks, but at the starting, I have just forgot to mention task. Again, I want to check this, let see. Now everything seems to be fine. It is saying that you are good to execute this playbook. So let me cross check that my client as well. So this is my claim. Rpm hyphen QA, grab hyphen I, HTTPD. So let me just check whether the service has been installed. This package is not as strong. This is tool, this is different, but I won't STD beauty, it is not as tall. System CTL, firewall status, firewall D, it is not loaded. It is in inactive state, so all seems fine now. And the name of my web page is this one. Let me pin this ellipse, this one. So it is not working at all from the silver and I'm trying to access this website. It is not working because it is not cluttered here. Now I am going to execute my playbook. Uncivil. Label. This one. Let do one thing. Let me do it one by one. So for that, we have this step. Yes, it is getting the facts. First task, it is time to install the package, that is STDP. Install latest package of as T, T p T. It's done now, let us cross check it. The claim. I can see the package is showing they're now coming to the next task. That is start and enable the solvus. So the system CTL status as HTTPD is dead now, after the execution of this next task, it will start at the starting and enabling the service. And I can see the service is running now. Install latest package of firewall. It is saying that green means it is already installed. R is asking you won't do start and enable the firewall services. I said yes, I am claim. Let me check it out whether the service is started now. Now by both the Soviets had been started now now it is asking for the permit HTTP service. So how we, how we can check that the Soviets IS permitted or not. For that we have the common firewall, the cmd. This is my default Joe, getting some error. Miter showing that STDP services already unable. Okay. So let me remove this service because I just want to show that after running by this task, this task, it will enable this so I can remove it. If I will DIE. Cmd hyphen, hyphen remove. Now it has been removed from the client. Now. Palm it this STDP surveys, so it will allow this. I'm putting years done now. If you want to cross check, you can see the Soviets element independent all. After running my task geared a simple webpage here. So let me put yes here. And then defining web page as well. So let me cross check what it is doing this. So basically, you know, it is that file as to this. We have this file as HTTPD.com. So I want to add a line after this line. This is silver name, this one. So here I'm continuing it. Done and ETC, host file also done. So let me show you whether this entry has been added or not. You can see the entity has been added now. And also let me check it. Any DC host file. Host file also does showing there. So everything is done now. Now I'm going to check with my feelings. Come on a links WW dot one dot example.com. You can see that the web server, which I'm trying to x's from ansible server to the client one plane. What is my web server now? Which I have created with the playbook? And I can see that the webpage, it is opening now. So for him, that's all for this lecture, but we have understand how we can create the complex playbook in which we can define so many tasks. Step is taps. So thanks for watching and if you have time, please. Jan Friedman, the next lecture. 37. Managing Variables in Ansible: Hello everyone. In this lecture, I'm going to discuss about managing wearables in ansible project. So as of now, in the past few lectures, we got an idea about ansible architecture and table setup. Understanding configuration file of ansible, how to run the ad-hoc commands, understanding host inventory file, how to write a simple playable using YAML language. So in this lecture, I'm going to discuss how we can define or wearables in ansible project. So what is a variable? Why doubles in ansible playbooks are very similar to using variables in any programming language. And civil supports or wearables that can be used to store values that can be reused. Throat files in an entire ansible project. Whatever is, provide a convenient way to manage dynamic values for a given environment in your ansible project. So few examples I have taken V or we can, you know, use the variables. Suppose you need to install the users in your environment. So when you click the playbook at that time, you can use the variables. Suppose you won't as tall package for your ansible managed host. So for that, if you are trying to create une playbook or any ad-hoc come on. So at that time also you can use the wider bus services to restart files to remote. So I've just taken a few examples where we can use the variables, naming variables. So how we can, you know, define the variable and we can see how we can create the wearables. Wearables have names, which consists of a string that must start with a letter and can only contain letters, numbers, and underscores. So when you define the variable, it could be any name. It couldn't be as string, that must be started with the letter. So you have to keep in mind when you define the variable name, defining variables. So here it is saying that where all you can define the variables. So very First, you can define the variable global scope. So it means that you can, you know, define the variable in the NCBO configuration file are also, suppose you half kit it ansible playbook. But in the playbook, you have not defined anywhere better. But when you filed ansible playbook at that time also, you can define the viable in a command line. You can also define the variable in your ad hoc command as well. You can define the variable in the ansible playbook, all related structures. You can also define the variables in the inventory file of our antebellum. So these are the places that you can define the variables. Wherever in a playbooks. When writing playbooks, administrator can use their own variables and call them in a task. For example, here you can see I have defined the name of the variable that is web underscored package. So this is the name of my variable and the value of this variable is at HTTPD. And this value, this value of variable can be called by the year module in order to install the package. So here you can see this is a simple example that is for the spallation of Apache package. And you start the solvus. This is the host, a web server. And here you can see I have defined all my variables under this verse. Colon. And five variable six levels have defined y underscore package, this one. So this is the name of my variable and this is the value and the five variables. And here you can see I have defined this one and the third one via underscore package and web underscores service. And the value of the variable is same. So don't be confused with that. So when you call the variables in your task, if you're defining this one or this one, both, the variable is same because its value is same. So you can define, you can use any one of the variables. So for intercept for this lecture. 38. Lab-Managing Variables: This is a lab session in which I'm going to discuss how to define wearables in a playbook. I'll let me quickly log in into my ansible server. And I had already created a playbook. Let me edit this one. And that's a very simple playbook. Initial few lines, the basic requirement of a playbook. After that, here you can see I have defined variables under the web tab. So this is a wes colon. And after that I had defined for variables. This is the name of my variable and its value is H, TTP d. This is my second variable name that is firewall and a scope PGD and its value is firewall D. So like this way I had defined for variables. And after that the task are simply mounting the OS media drive, copied a local repo file that we had already discussed in the past few lectures. And here you can see I'm installing my packages using the yam module, right? And all the packages are, have defined using the cerebellum. So I've just mentioned the variable name. This is Webb Telescope, EKG, firewall underscore, pk, DM, Pol under scope Piketty. So three packages would be stalled. One by one on the solver that is coming under the this host web server. In this left side, I have define only one server that is client one. And after that it is just trying to start the star and enable the solvus that is HTTPD n, this firewall D, right? And a next task is to claim the web content and open the port. So that's a very simple playbook like me come out from this one. And the very first chap and civil hyphen hyphen list host web server. So one client is there that is claimed one. I had already taken the session of client one. And let me check the syntax of my playbook. Syntax is also ok. Let me come to this one. And a. There is no rapport file, RPM hyphen QA. This package is not as sharp. Firewall D is also known installed. And my OS media drive is also not mounted yet. Coming back to my SQL Server. And when you start this playbook, and the name of my one, capital K, And let me do it step-by-step. So let me first clear it. And Sibyl playbook, This is the name of my playbook, capital K. It will ask for the pseudo password and let me do it step by step. Getting facts. Yes. It is. Getting the facts of client one. The next task is to mount the OS media drive ES I1. It should be mounted. So this has been done now. The next task is copy the local repo file you want to continue? Yes. The file has been copied. Now. I can see server.js WIPO has been copied now. Installed packages? Yes. Is going to stall three packages one-by-one. That's done now, you want to cross check firewall the hell when installed. Okay, so everything else is tall. The next task is started. Enable the service that is at TBD. Done. Firewall lead done. Create web content? Yes. Open the port. Yes. So all done now, totally changes. Is six here because they were having six tasks. Now, electric tried to access this website from outside. Okay. Okay. Still not able to access it. Y OK. I've taken the IP of the ansible server, but the changes I have done the stylish and I have done on client. So I need to copy the IP of this one. So the IP of my this client one is this one. I can see the website which I had created with my playbook using the variables is started opening. Now. Now let me come back to my ansible server And let me add it. This one. Let me do some changes here. So content is ansible. Automation classes. Welcome to ansible. Step-by-step. And civil automation classes. Something is ABD on here. And this is my client machine. And load this one. Mit. Coming back to this one, again, I'm going to run this one. So this time, the two changes will be done on the client machine. The first one, it will title mounted, it will mount the CD drive. And after that, the changes in the web content, apart from that, everything is already done on the client machine. So let me done a step-by-step. Step-by-step. Yes. Dean means it has gathered the fact. So it has mounted though is that's why the changes has been this one. Copy the repo file gain means the file is already there. So note, task has been done. Packet already installed. Services are really started. Grade the web container. So this time it is going to create the web content because we have done some changes. I can see the color change. It is this one color. So it means that some changes have been done are also destroying, teased. So total task that has been changed on my time machine is two. Now, let me refresh it. I can see welcome to step by step by step ansible automation classes. So from there itself for this lecture will see you in the next lecture. Bye, bye ticket. 39. Hosts & Group variables: In this lecture, I am going to discuss about host variables and group variables. So these variables can be defined in a file that is called host inventory file, which is available inside slice, ETC, is less and say well, inside this location where we have a file that is host file, which is also known as host inventory file. In that file we can define host wearables and group variables. So let's understand what is host and group and how we can define it. So inventory wearables that apply directly to host fall into two broad categories. The first one is the host variables that apply to a specific host and group variables that apply to all host in a group. So to understand this after going a very simple example. So here you can see this is the name of a group that you can define in a inventory file. So was under which we can have multiple servers like demo dot example.com. And maybe if you, most of us would be there in that group. And here you can see are defined one variable that is ansible underscore user. So what is this? This is a variable and it is having some value that is here you can see jaw. So this variable that we have defined after this server. So this variable is applicable to this server only, not for the entire group that is servers at this variable is only applicable to this server. So it is called a host of Arabella. Now let's understand what is group variables. So to understand group variable, I have just taken a very simple example. So this is my first group that is solvers one under which you can see two servers, demo one and demo T demo tool. This is my another group that is servos to under which you can see few more servers, that is Demo three and demo for. And here you can see a half define one more group that is, so us. Under this group, I want to define my, any other group like the solar one and cellular too. If you want to define both the groups in a new group, then here you have to use like this way. So this is your colon. And here you have to put children. And the soul was 12. So it will try to know what all the, you know, solos under this group that is servers. Now in servers we have force or was that is demo one demo to demonstrate and demo for. So this is one thing. And here you can see solos and colon, verse. And silver is equal to jaw. So here you can see, sorry, u, that is equal to jaw. So here you can see I have defined one variable that is user is equal to Joe. For that, what all the servers that is coming under this service will have this variable. So this variable is applicable to all my force or was because this is for service. Under this service we have two groups that is so u1 and u2. And undersell One, we have demo one, demo two. And so what do we have? Timothy and semaphore. And here you can see I have defined a variable that is user is equal to o. So in actual, this variable is applicable for all my-force overs. So that is known as group variables. So nobody's will do the lab session as well. So from there, so we'll see you in the next lecture. 40. Lab on Host & Group Variables: This is a lab session on host variables and group variables. Let me quickly log in into my uncivil server. And this is my host's inventory file. So in this file, you can define your variables. So lot of entries are already there. And let me get a group, insert. So my first group here. So I have defined one group. So it was one under which I am defining few salvos, mu1, mu2, mu3, like me, KDE, one more group. So was two. This is my another group. And let me put few Mozart was Demo for 567. You can put n number of service. Even you can put the service which is already defined in some other group like demo one. You can put demo one in this group as well. So this is one thing that defining the soul was in a group. Now, what is host variable? So this is my demo one server and I want to define a variable, a host variable for this server. Then you have to give a space here and give any variable name whatever you want. Suppose I am giving ansible underscore user is equal to John. So this is the name of my variable and say, well underscore user and its value is John. So this variable is defined only for demo one. So this variable is applicable only for this server, not for the entire group. Suppose this is my another server. And for this server, a half given another user like SEM. Right? So this is another host variable that is applicable for demo to server. Okay, this is one thing. Now. I'm going to create another group that is solos, right? And in that group, I want to define the solvers that belong to my, so what one group and so was two-group. So for that, you have to use solos, underscore, colon, and children. Now in this group, I want to define the service, which is a part of this group, several ones. And so we're too, so if you have such type of requirement than you have to use children here. And after that, just give the name of the group. So US service tool. So in my soul was grouped. This one, we have all the servers, that is mu1, mu2, mu3 demo for demo 567. Let me show you. First group was so plus one. Some typo mystics I was. Okay. And I can see that in Seoul was fast groups. I was one. We have clean clothes. And for solvers, you can see in that group, we have all the solos that belong to Seoul was one and salvos to grow. Okay? So this is about the host variable. Now, let me tell you about the group variable as well. Suppose in that group. So was, I want to define a variable. Then you have to use this colon and variables. After that, you can define any variable. Suppose I am defining ansible underscore user, and here I am giving some different name, like the some different name like the warm I am defined. Ok. So this variable, uncivil underscore user. This is a variable that is applicable for all my servers. That is demo, demo, demo, demo, demo 5-10, 06, and demo seven. The few things you have to keep in mind, the first, let me read out the host variables, take precedence over the group variable. So what does this mean? Here you can see I have defined this variable. The same variable is also defined at the host level. That is ansible underscore user that is equal to the John. So if the variable is same, that is defined at the group level as well as at the host level. So which, which variable is going to take the precedence? So here, when you run the playbook, so it is going to take this variable for this demo server. And for this demo tube, it is going to take this value, Sam, it is not going to take this value. And for other servers, Demo three, demo for demo five, demo six, and demo seven. Than symbol underscore user is equal to four monophyly. So this is one thing. Suppose I am defining and say, Well, host is equal to anything I'm defining like ABCD. So this is, this variable is applicable for all my host, like demo one, demo t 2345678 because this variable is not defined here. If it is the same variable which is defined at the both the n, So which is going to take the precedence. So you host a variable. We'll get the precedents here. So host variables take precedence over group variables, but variables defined by the pebble take precedence over both. Supposing the playbook, I have defined the same variable and single underscore user. And that I have given suppose x, y, z. So when you run the playbook and symbol underscore, user is equal to x, y that is going to take, it is not going to take this 11 mod this John for all the service. So from there, so for this lecture, hope you got some basic idea about the variable. So that's always in the next lecture. 41. Lab on Variables: In this lecture session, I'm going to discuss about the variables are let me quickly log in into my ansible server. And in this lecture ten, I am going to create a playbook for the creation of a remote directory. Suppose I want to create a directory on mine remote servers. And was the directory would be created on my remote server. I want to copy a file on those directories. So how we can do that? So let me create a playbook for that host Is web server. Because once i was defined in this group, become now I'm going to define the variables. The name of my variable is remote, underscore d a n. So this is the name of my variable and its value is ADC, uncivil, and FX dot dy. So I want to create a directory on my remote service. And this is the directory you want to clean. And I'm going to define another variable, x underscore file. And here I'm defining the name of file custom dot effects. So to laugh created. Okay, now my first task is created or remote directory. And for that I'm going to use the module that is file module is Ted, What do you want to create? I want to create a directory. Okay. I recurse, yes. Suppose on my remote server and civil directory is not there. It is only DC directories there. And he wanted to create this one. So first it is going to create ansible directory, and then it is going to create facts dot-dot-dot directory. Okay? And the path it is asking. So here I'm going to use my own variable that I have defined here. Right? Because this is one thing. After that, once the directive would be catered, I want a file should be copied. Copy a file. So for that I'm going to use copy module. Which file you want to copy the file should be existing, should be existing on your ansi SQL Server. So it is existing on this server on the same location. So here I'm going to use this one. The name of my file. I also, you know, defining the name of file with the variable here again z. So it is going to look for the file in the same location where you are going to execute this playbook, this one, this file. And where you want to copy, I wanted should copy into this location on the destination server. Ok, so that's a very simple playbook I have created just to create a directory and then copy a file. Or let me come out from this few things I want to check. And Sibyl list, host, web server, plane one is dead. And, uh, let me log into my client one. Let me check and see what is there. I can see that ansible directory is not there. So it is going to kick that ansible directly, and then it is going to clip the x-dot didactic tree. And once the DAG that wouldn't be good at it, it is going to copy a file. Okay, let me check the syntax. Syntax is OK, everything seems fine. I'm going to execute this one. Let me do a step-by-step. Ok. Directory has been created. Let me check. You can see and see what has been created. Facts has been created. Okay. And it is saying copy the file. Yes. I'm getting some error. Let's see why I am getting this as it is searching for the file, this one custom and the source location. So let me first open this one. And here you can see that my this playbook is not able to copy the file. So here you can see the source location, this one, the facts. So it means that it is looking for this file on the same location where you have kidded this playbook. So let me check whether this file is theta naught. So the file is not here. So I need to clear this file. Custom effect. This is an application file. So the file is here. Now, again, I'm going to run the same playbook. You can see that this ansible is smart enough. You can see that it is trying to create a directory and the directory is already there, right? Because I have already created this directory with my previous. Okay. So that's why I didn't get it and now it is time to copy this file is the file has been copied Now. I'll let see again, see the file has been copied now. It's friend, that's all for this lecture. I hope you got some idea about the variables. So that's all we'll see in the next lecture. 42. Ansible Facts: In this lecture, I'm going to discuss already easy, unuseful topic, ansible facts. And simple facts are variables that are automatically discovered by ansible from a monotheist host. In simple words, simple facts are the predefined variables. And with the help of set a module from your ansible server, you can retrieve the values of those variables from your managed host at anytime. Facts are pulled by the setter module and contain useful information is stored into variables that administrators can reuse. And simple facts can be the part of playbooks in conditionals, loops, and any other dynamic is statement that depends on a value for a managed host. So few examples where you can use the uncivil facts. A solver can be restarted depending on the current Colonel Watson. Suppose in my environment, they are 50 servers and my requirement is I want to reboot the server. Who's kernel worsen as x, y, z. So in that case, you can use the ansible facts with the help of ansible faxed. You can first find out what is the current Colonel war zone from all your managed host. And then you can use the conditions and reboot the one who's kind of awards on his XYZ. Another example is users can be created depending on the host name. Suppose my requirement is that I want to create to users on client one dot example.com. So fast with the help of ansible fact, you will find out which server is client one dot example.com. And that it is going to, you know, create the users on that. Nobody's will do the lab session, then you can easily understand. Uncivil facts are a convenient way to retrieve the state of a managed host and decide which acts and to take based on its state. Like host name, the kernel worsen. The network addresses, IP addresses, the version of the operating system, various environmental variables, the number of CPUs. So I've just taken a few examples. So, so this command is going to gather all your ansible facts. So the output would be very big. You can use the filter as well. So here you can use the filter like if you want to get the detail about a variable like ansible host name than you have to use this one if you want to get the detail about ansible underscore this default IP address, then you have to use this one. And at anytime, if you have any confusion like what is the name of the variable, you can simply file this. Come on. It will give you the big output. From that output, you can gather the name of your variable. So let me quickly login to my this one. And let me show you how we can use and civil. And suppose I am taking client one, I find M and setup. Let me give it a pair. And I can see it is giving me all the details. So these are the variables. This is my one variable. So if I want to use the filter, if I'll give this, it will give you that this IPs only. So if a simple file setup, it is going to give all the details, all the, you know, facts from the server. So I've got a big output. That is, it has gathered the facts from my managed host. Ok, suppose I want to use any filter here, so I can use hyphen, a filter. And a filter. I want to know about this. Ip was in full. So from client one, I will get a detail about the IP world. And so this is IP. I've got the complete inner detail about DIP from client one. Suppose I want to know host name. So this is the host Navier client one. I want to know the f k1. Then I have to use and civil underscore F. And this is client one dot example.com and civil war chill ideation. I just wanted to know whether it's a VMware or physical server type of virtualization. Since a Vm, Vm initiated. So this way you can use the uncivil facts. You can also use the uncivil facts in a, in a playbook as well. So let me show you. I've already created one, this one. So here you can see I have defined this one. Print various ansible facts, debug massive. And here I've just mentioned default address. And in this curly bracket twice time, you can use the ansible facts. So if I'm going to run this 1 first, it is going to print this one default address off. This one ends will fat and is this is the IP address. So let me come out and let me run this 11 more thing I just wanted to know. Host web server. Okay. Let me run it for two servers. So I'm going to change this one. Broad is a group one which we have to suppose that is plane one and plane two. Okay? So the message I got that default address of client one. So this isn't 90 messes the address. This is the ansible underscore F, q, d, n, and this is the IP was, and this is one next level that is client to this. So this way you can use the ansible facts. So for, and that's all for this lecture. 43. Conditionals in Ansible: Hello everyone. In this lecture, I will discuss about conditionals in ansible. So that's a very important and conceptual topic of this course module. Ansible can use conditionals to execute tasks or plays when certain conditions are met. For example, a conditional can be used to determine the available memory on a managed host before ansible installs are configures a service. Suppose I want to install a package on all of my managed host. Suppose in my environment, 50 servers are there and I need to install a package, but I have a condition. My condition is that the packet should only be installed if the available memory on the Manage host should be greater than four GB. So this is our condition I have with the storage and of the package. So when I create the playbook, so in the playbook, I can use this condition. So when you execute the playbook, it is going to the server. You manage servers, and it is going to check the condition whether the available memory is 4GB or not. If it is not a shortest skip the server and move on to the next server. And if the available memory is more than 4GB, then it should install the package. So this way you can use the conditionals in Antebellum. So here we have few examples. Like you can use the Hod Lipson can be defining a variable, for example, Minimum underscore memory and compare it against the available memory on a managed host. You can also use the ansible facts. So how we can use the conditionals in ansible one writing that playbook. So you have to use the one statement. Sometimes you will want to escape a particular step on a particular host. This could be something as simple as not installing a sudden package if the operating system is a particular was n. So they have just given a few examples. Like you want to install a package, but you want to install a package only for certain distribution of the servers. Like you won't install that package on CentOS or you want to install a package on Debian. But when you define the solvus and a playbook, the numbers of servers are there. So with the help of when condition, you can define what exactly you want, whatever you want to escape. So here you can see a very simple example that is shut down the Debian flavored systems. So when you create the playbook and host, you have mentioned a group and the group that a lot of servers are there. It could be redhead in or it could be CentOS Debian. But do you want to shut down only the Debian servers? So here you can see that I have used a very simple task that is shutdown Debian flavored systems and the command are used for the Saddam, this one. And here I have used a condition that is answerable. Underscore. Underscore families shouldn't be Debian. So this is the n symbol facts I have used here. If I have not used this line. So what will happen if I execute this playbook? It is going to, you know, it is going to shut down all the servers that you have mentioned end up playbook that is in the host. But here I've mentioned this one. So whether in your mind, when you are in a group, whether you have the redhead centre is it doesn't matter. It is going to reboot only the Debian sellers. So if undersell for this lecture and the next lecture, I'm going to do the lab session on one statement. So that's always in the next lecture. 44. Lab on Conditionals in Ansible: This is a lab session on conditionals in ansible. So let me quickly login into my ansible server. And I'm going to create a very simple playbook that is for the shutdown of any specific Linux distribution. So I'm giving any name here. Okay? And here I'm using prod group. In prod group, there are three servers I will show you before, you know, executing this playbook become true. And this is my task here. And I want shutdown CentOS system, so this is my requirement. So I'm going to use a model that is come on module. And the simple I'm using power of. So if I'm, you know, executing this playbook without specifying the condition, what will happen. It is going to shut down all the servers, which is the part of this broad group. But I'll hover condition. My condition is that it should reboot only the CentOS system. So here I'm going to use condition that is when AND ansible fact I'm using ansible oils family should be sent to a so this is the condition I have. So let me save and come out and let me show you what all the servers are having. The product group and symbol, list, host and prod. So three machines that is client to client Klee and client for and symbol hyphen M setup. I just want to check the distribution of all these servers. So for that I'm going to use a filter here. And symbol underscore OLS family. I need to mention the group S1. So all the three servers are from a read head. Okay? And this is my playable. If I'm going to execute this playbook, is going to check all the three servers and it will satisfy the condition. And the condition is, it is going to check whether it's a CentOS or not. So here all the three servers, they are not from the Santo is family, so it is not going to shut down any of the source that is a part of broad group. So let me execute. And civil playable. And lab seven, capital K. It is going to skip all the three servers, is getting some problem and gathering the servers. Okay. It escaped in our client to and client for and it is not able to establish that connection for client too. So like me, pink line two, What are the issue here? Client two is pinky will k and civil hyphen em up time. And that is for client two. Ok. So maybe I, actually, I had just rebooted this system. Again, I'm going to run this one. Maybe the soul was not up. I can see that it has gathered all the three silvers. And when the task comes for the reboot or shut down of the Center's machine. It has escaped all of the servers because all the three servers are from CentOS, from Red Hat, not from CentOS. So this is one thing. Second thing I just wanted to show you here. Suppose I want to add few more condition. Suppose my requirement is I want to reboot the redhead machines and also are few more condition like it should be a redhead six only. So I can use unstable distribution. Maser six. So this is my one condition. The first condition, it should be redhead and also it should be wasnt six. Then only it is going to pour off that system. So after IT systems, let me check the Watson. Okay. So client tree is only aerogel six inclined to and Klein four is 87. So when I'm going to execute this playbook, it is going to reboot. Only. Client is going to shut down only Klein T. Unstable hyphen play, a lab seven hyphened cap. And this is my t is this one. And this is my client for and this is my claim two. So this is my this is my client T and this is my claim for okay. I can see that it has power of the, it has started power of this system, kind three. Ok, and other systems that is a client. Two is still up and your client for this chill up. So the condition was it should be redhead as well as it should be six. Original six. Ok, so the system is down now, let me make it up manually. Ok. Suppose you have multiple conditions and how you can specify. So this is my one condition and I have few more conditions. So you can put one condition in that bracket or you can put on and if you have any further condition like I want, it, should we send two is and distribution should be seven. So you can use the conditions like this way as well. So your condition, if it is satisfied under this one, it is going to reboot. All your condition is satisfied under here. It also going to reboot because I have used or if I have used n here. So your conditions should be satisfied here as well as hair from here till here, right? So these are the basic things you have to keep in mind when you use the whiteness statement. So for, and that's all for this lecture. We have lot of more things to understand and conditionals in ansi Well, so there's all we will see in the next lecture. 45. Ansible loops - when, when_items etc: This is a practice session for understanding loops in ansible playbook. Let me quickly login into my ansible server. And I'm going to create a very simple playbook in which I'm going to define a lobes in ansible. So this is a name of my playbook host. I am defining rod here, and I'm just going to print some messages via the loop. So I'm not going to use become on all because very simple playbook task. My task is, you know, that is unstable loop. And here I want to use a module that is debug. So this module prints statements doing execution and can be useful for debugging variables as well. So I just want to print a mass is so that if I am using this module, coming back here, masses. Okay, so what message I want to print? So here I'm defining a variable that is item. So I have defined a variable, the name of the variable is item. So what all the values that we have for this variable that you have to define. So to define the values for this variable, you have to use with underscore item, items. So it's a loop. Obviously this variable should have multiple values. So I'm defining hello, one, Hello to L3, to three values I have defined for this variable. Now when you execute this playbook, what will happen? First? It is going to check what all the servers that you have in this proud group. Suppose there are two servers. So it is going to pick the first server and it is going to print hello Irwin, hello two and hello t, t times it is going to print, okay? And again it is going to pick the second. So, and again it is going to print hello, hello two and hello tea. So total six time it is going to print. So let me save this. And let me check with syntax. Syntax is OK. So to service, that is a part of this broad group. Now I'm going to execute this playbook. I can see that it has print. Hello one, Hello to hallow tree, that is for client tree. And hello one, Hello to hallow tree that is fault client for. So it's a very simple ansible playbook where we have defined how we can use the loops. Suppose you want to use some condition here. You can use the condition here as well. Okay? And if I am putting this one, let me tell you, suppose I have given one more value. And again, I'm going to execute this 18 times. Write L1, L2, L3, L4 for client L0, L1, L2, L3, L4. That is for client. For. Now I'm going to show you how we can define the conditions here. Suppose a half few condition. My condition is that it is going to print these messages when certain conditions are met. My condition is that like uncivil OS distribution or it was YS family. It should be equal to CentOS. Ok? So if this condition satisfies, then only it is going to print hello, hello two and hello three and telephone, right? But I know that these two servers that is sending that is client 34, they are foramina redhead family. So when I'm going to execute this one, it is not going to print anything. I can see that it has not print anything. It has escaped each and everything. Ok. So let me check. The O is awesome. Come on. Hyphen a ADC, redhead. So one is 61, is seven. Now I want to put some condition that it should be, you know, print hello, hello, hello, hello for fall. And it had seven. Okay, again, I'm going here and say, well, distribution and misery was miserable. X1 is equal to seven. So two syllables, I know that one is 71 is six. So it is going to print only has one Hello to halocline telephone for once ever. I can see that it has printed only for client for because it's a HL7. Okay, you can also specify condition like this way. Let me tell you. Suppose you want to print, like I want to print hello and hello to unhealthy for, for the operating system whose wasn't, is six or more or seven or more. How we can define. So for that, you can use the same thing here. And here you can use like this way teaser and greater than equal to six. So this is my condition. So it is going to check first. It should be distribution, should be rented. And also the distribution wasn't should be six or more. Say if I'm willing to execute this one, it is going to print for both the service, because one is 61 is seven. So here you can see that it has printed four times, 434 times for applying for. So from there, so for this lecture, I hope you got some idea about ansible loops as well. So that's all we will see you in the next lecture. 46. Examples of Ansible Loops: Let's understand few more examples of loops in ansible playbook. Suppose you have to install two packages using the yam module. So you are going to write your playbook like this way, hydronium. And this is the name of your package, is latest and the same you have to write for another package as well. But with the help of loop, you can simply write the same task. And this way as well. These two similar tasks using the yam module can be rewritten with a simple loop so that only one task is needed to install both the packages hyphen yum name, and this is my variable name, state latest. So what are the values? That is for this variable? Here you can define vid underscore items, that is postfix and DOE caught. So when you execute this one, it is going to stall both of your package. The next example is this one. You can also define the loops in this way as well. So at the start of your playbook, you can define the variables. And this is the name of your variable that is male underscore services. And the two values for this variable, one is a postfix and other one is caught. And here I have used yum, name, item. And the item. This is the variable, what all the values within items I can call the wearable value from the mail services. So here I have mentioned Bill services. So it is looking for the mill services, variable and mail services. We have two values. So this will also, you can use the loops in unstable. You can also define multi-dimensional array as well. So when passing arrays as arguments, the array can be a list of hashes. The following snippet shows how a multidimensional array is passed to the user module in order to customize both the Neyman group. So here you can see I have defined two variable. The name, the name of first variable is item.name and instead is present. Also a have defined another, a variable that is groups, that is item dot groups. And within group items here I've defined name. So whatever the values you have defined here, it is going there because it is name, name, and groups. It is going to this one. So this way also you can define the loops in your ansible. So there's always in the next lecture, bye. 47. Ansible Handlers: In this lecture, I'm going to discuss about ansible handlers. It's a very easy topic. A handler is exactly the same as a task, but it will run when called by another task. Or handler, will take an action when called by an even, it listens for a, let me take an example. Suppose I have to write a very complex playbook. And in the playbook, I have to write for the configuration changes. And after the configuration changes, I have to restart the services as well. And this is what we have to do it many times in the playbook. And each time you have to write four or five lines for restarting the services. So what you can do, you can create the handlers for restarting the services. And instead of writing the lines for the restarting the services each time, you can call the handlers. So here we have example. You can see that I'm just trying to copy some configuration file. This is the source and destination. And after that, I need to restart the services of Maria DB as well as Apache. So here what I have done simply used notify, and here I have called handlers. So at the bottom of this playbook, I have just defined this one handlers. And the name I have given this one restart minus kill. And this is the solvus, our name m, state, what do you want? You want to restart the service. So here you have just, you know, notify and call this one restarted MySQL. So whatever the name You have mentioned here, the same you have to call when you notify IDA handlers. And it is going to restart the services. So this way you can define the handlers. So fenders all for this lecture. The next would be the lab session of your ansible handlers. So that's all we'll see in the next lecture. 48. Lab on Ansible Handlers: In this lecture, I'm going to show you how we can use the ansible handlers and a playbook. I had already created one playbook and let me show you. So it's a very simple playbook. And this playbook is running for the product group. And first it is time to mount the OS media drive, copy the local repo file. And here you can see it is trying to installing multiple packages. And here I have used yeah, module for the histology and off package and have defined the loop hair that is ansible loop name. And under this curly bracket, item is a variable name. So what all the values for this variable here I've defined inside the width underscore items. So for packages it is going to stall on all the servers. That is a part of a thought group. After that, it is going to start and enable the required services. That is your VSFTPD and as HTTPD. And here it is going to create the web content. And this is the source file. And when this file, your STL file is copied to your destination server, it will copy with the name of the host name. So here you can see I have used ansible fact here that is ansible underscore host name. And after that I want to restart my Apache services. So here I have used the handler. So to use the handler, you have to use modify and then DES. And here I've used restart, underscore edge HTTPD. So the same name I've used in my handler here. This is the name of my handler. And this handler is basically trying to restart the HTTP services. So this handler, you can use any number of times in your playbook. And also you can create handlers for other task as well. Suppose you want to start any services you can use. You want to stop any services. You can create the handler for that. And wherever it required, we can call the handler using modifier. So I'm going to copy this playbook with this section so you can download and run the same playbook for your environment. So fenders, all we'll see in the next lecture, bye. 49. About Ansible Roles: welcome Toe automation with answer friends. In this lecture, we're going to understand what is sensible rules and how do we create danceable rules. So this is what we're going to understand in the selective, and we'll have a lot of laughs session so that we will have a better understanding what is exactly and civil roll on, how we can use and Civil rules friends. In the last few lectures, we got an idea about answerable. We have understand the concept off the architecture off, uncivil and different technologies, and also, we have understand how to write a simple play ball. So what is uncivil rule and where it is? A quiet in simple words and simple rules are they toe group multiple tasks together into one container to do the automation in a very effective manner with Clean and Derek District Er's. Whenever you have to, you know, do some big task in which we have multiple task. Multiple playbooks are there on. It is difficult to manage in a single file to do the things in a proper way in a organized way. We always go with the rules. Sometimes when you have a lot off task and it becomes very inviting and difficult to maintain in that single file. So rules allow you to create very minimum playbooks that then look to a directory structure to determine the actual confrontation steps they need to perform. So this is what understanding off rules in simple words. The rules are set off task and additional files for a certain role, which allow you to break up the confrontations. And you could also easily reused the court by anyone if the rule is suitable to someone. So this is what the basic understanding off rules organizing things into rules allows you to really use the common confrontation steps between different types of sores. It means that symbols you have to do the stylish in off party on multiple servers, so stylish in itself regret a lot of things like installation off packet. After that, some 10 years in the conflagration file, and also you have to copy the index file off your website. So these three steps one more step, you have to restart the service. I'm just taking a simple example. So therefore, the steps you have to put it in a single playbook, so instead off creating a single file and making $4. We can create rule for that. And each role is having some meaning. Like some was copying the files. You're index file your complication. Finally, a putting in one location, okay. And just creating a single file and just using those. Derek, please. I will explain with an example so that we can understand more on that. So what I'm doing here, I'm just organizing the things in a battery and you can reuse the things, reuse the courts. Their court is suitable to someone. So what is uncivil rule and civil laws are consists off many playbooks, which is similar to models and pop it and cookbooks and chef returned the same unanswerable s rules. Rules are there to group multiple tasks together into one container to do the automation in very effective manner with clean Derek the strictures, role of sort of task and additional files for certain rules which allow you to keep the back of the complications. We can break up the task in two different different files, like extradition off package. You can break it in one does copping off file. You can make a pinto another file another one is like the started service. So this is what he can break up and make it in an organized way. Okay. It could easily reuse the course by anyone if the role is suitable to someone called Invincibles handlers you're using handle means it is starting. The services you have created one court for their on were required to reach travel service . You're simply using those courts. It is easily modify and will reduce the syntax error. So this is what the idea moat rule. So from their soul for the selected in the last lecture will do the lab station on that so that you can understand bedroom and simple. So thanks for watching. 50. Create Ansible Roles: welcome Toe automation with Enseval. So friends in this lab station will understand how we can create the uncivil rules. So I am just taking an example. Suppose I have to do the installation off party website. So for extradition of a party Web server. First of all, we have to use the common answerable desk galaxy toe kill the template for that. So I'm using a common and simple desk, Alexey, which will care a template for it. Let me show you. So this is my soul. Oh, okay. On what I'm doing going to do here, I'm using this answerable death galaxy. And it it is for to initialize the role on it. Always create in the default directory D. C and civil rules. And you have to specify the name off any role. Suppose you are going to do a task toe the party so you can give any name here, the name of the rule. So I'm simply giving a party, and I would be making it offline as well. I'm a friend. Means it will kick it off line. More relevant getting from online depositories. So this is simple command. The first commodities and several days. Galaxy is the command to create that rules using the template. Second is that in it which is to any slice the role after this play that role apart is the name off your role here on offline. It will create the representative using offline rather than going from the online deficit trees. I have just fired the Come on, you can see the ah party role has been created. It means if I will go to this location it is a sensible rules. I can see one direct. Is there a part of it? Is just not get it? No. If I will go inside this directory, I can see a sector of directors are there. This is what I can see here. The lot off files are there. A lot of directors are there. Templates finds where meta handlers tells task default. So this is what it has been kitted using the Common and Civil desk galaxy. It has skated one template for you which will help you to organize the task which you're going to do here. So this is the director structure located here. The 1st 1st thing is here like water. Things like task is here. You can see when directors for tasks task is basically it contains the mean list off task to be executed by the rule. Okay, if I'm going inside this task, I can see this is a mean dot Why my file? It contains the main list off task to be executed by the rule. So this is the main file from here. Here. I'm going toe manage all the directories. So this is what I have to do it. Now I can see when more directly is there. A lot of more directors are there when his handlers so handlers contains it. Contains the handlers which may be used by this role are anywhere outside this rule. So and lives is basically like suppose you have to keep on restart the services during the task off your playbook so you can use handlers. Okay, So here, if I go to this directory, I can see a file may not see. Why am L? So here I will be creating a task for the handlers. Okay. Like this were this is a default. The director for the four less well here. So this is different is basically before variables for the rule. So whatever the default variables you are using, so you can use this territory where is for other variables for the rule that has that higher priority than before? So whatever the variables you are, especially here, it has more priority than divorce. So this is basically four variables. You're gonna specify your variables into this directory files which countries the files required to transform deploy toe the target machine's Suppose you have to fight past for a few files to your client machines so you can put all your files into this directory. You have to go and to distract. You can put all your fights there and whenever you required to send any files from this machine toe control must into your manage schools. You can specified this location, so you have to put whatever the files you have to send it into this location. Like this way, there is one more templates, continued templates which can be deployed by this roll, and one more thing made eyes. They're mai tais basically defines some data information about the role, like author Robert NC worth an example the sector. So this is what information you can keep here. So basically, you have to, you know, take it off these things, like main task handlers, defaults, variables and files Also. So these are the main things which we have to use it toe configure your task. So from their soul for the selecting the next lecture will take an example to create a role . So they begin. Understand how we can use these directories to get the desired hour or so. Thanks for watching. If you have time, please join with me in the next lecture. 51. Lab 1 on Roles: welcome Toe automation with an civil friends. This is a lab session and which we're going to understand How toe create a role for a party of F sever example which I have taken here, the stylish in off a party of server using rules. If rules are not there, not there and we have to create a simple playbook for that. So let's understand, Watford, with the playbook on, then we'll create a rule for that. So simple playbook. You can see if there is no rule than we have to get a simple playbook in which we have the specified different tasks, like the stylish in off as to typically packet okay and then have to copy some confrontation file like us to debate out as to degree configuration file. Also, you have to copy the index fell for that. You can see after did the task, okay, and then I have to restart the services for that, I have to simply use the handler and then at last starting enabled lasted ingresos And in the last you can see the handler have used in the playbook. For that I have credit easing will handler. So this is what your playbook looks like. If you're going toe with a stylish enough about eve of several on your client machine, suppose you have to do the same exercise in an organized village. Then you have to go with the rules. So we understand how we can do the same exercise with the help off how we can make it organized. So whatever the directors we have discussed in the last lecture, we'll understand how we can put East ask this stuff we can put on this directory. So let's start the very first thing I would be, you know, going for the dusk. That is in your rules. So I'm here so first, awful. The command is to create that roll, which we have all of them. Let me do it again. So the command is answerable hyphen galaxy, and it is for the initial A's, and I'm going to create a role. The name of the rules Watch it, and I'm making offline After that, what would happen if that activity kick it? I can see that genetically has been gifted with Lord off. Direct yourself with a lot of similarities. Are there if I fire the tree you can see. It looks like them. Now I have to do the installation off Apache Web server. Okay, So first mean congregation file. That is in your task. So I have to go into this. Okay. This is the main confrontation. Five. Okay, the first thing what I need to do, I have to do the stylish in off extra TV packet on my plane machine. So how we can do it. So for that to let me do one thing, let me kid one entry in my main contribution file. So this is my main confrontation file, which is almost empty. Nothing is there. I'm putting the sentry hyphen. Import does install dot so it will look for this file into this location. Okay, so you can clean the complete playbook here as well, but I am making it more organized. So what I'm doing, I'm creating a different different file for different. So this installing not label what will happen in this file? I would be putting commands for the solution off your estate to be package. It's very simple. So you have to use important the score task here. Simple have put this country so I'm in this location on this is what country I have done it Because what will happen when you learn this role it will look for installed are viable in this location, which is not related. Yeah. So now I have to create this. It's told Dr William. It's very simple. It always started to This is death name. What? It is a astonishing off as tech deputy Beckett. Okay for that, I'm using Jim. Come on. Young name, as you called to ask Deputy on the steps should be the letters. So this is the simple labour. Okay? Can see which can be used to do this tradition off my estate ability. Okay. Just settled and coming nasties to have to copy some file as well. So for that, I'm using it file configure that Wimal. So I'm again going here first Task that you have done it this for the stylish in off my Aston to be the second is conflagration configuration like suppose you have your own Estivill confrontation file on. You want the same file should be copied to the time machine and you can a copy the file from this to your brain machine. Okay. And Also, if you have your index dot estimate file, you can also copy there. Okay. Okay. So this is what I have put here. Okay? Now I have to configure this will put the interest in this. So it's off. No twenties in my This really can see. Now I have to configure this can figure. Don't fight. So I'm just putting copy. My indexed are estimated file from irritable Copy. I know that there is a direct plea filed. If you remember, there was a directory file. It is in the role director like it is sensible rules. A party. I will show you. So I have to put this my index or estimate there. Okay. So what will happen? The source file. It will look for the files files. It is in the it easy answerable. Did you see? And civil rules a party. There is a direct turtles. I will show you and variable Copy. It will copy to this location. Okay, on One more thing I want after the copying off my estimable industry arrestable file, it will restart a party services right so far that I would be using handler here, so notify simple the name off my hand that I can put anything here and putting restart a party. Okay. For that, I would be creating a handler as well. And I have to put the social as well. So this is what I have done here. Now you can see my configure. Is there Can I have toe put this file indexed or estimate? So I'm in this location, it will go a step back. And if you fire the command Alice happen every year, you can see a directors. They're filed. Now he'll have to clear the index Torres demon. So it's a simple website, so I am just kidding. This is my first website. Just fought checking, but Royals this for testing. That was I'm doing Okay, so this will be my website amputee. Okay, so I have put my indexed or esteem a lesbian. Okay, The next thing use that service. I have to start and enable the service as well. How we can do it again. I have to go to this location. Task. Okay. The two things I have done it in my main confrontation file. This is install the party services. After that, it will copy my index fellas will now have to start and enable my service. So for that again, I'm going bonkers on I'm again used another task that would be imported from here in port. Underscored task. That would be I can put any name service start. Okay, So this is what I have created again. I'm getting this file service now. Have to get this far. So this stop White start and And a bill My And they've been asked to be pretty. So this Okay, this is what the message will come. Service. I'm using it. Modern service. Their name asked activity instead. I want it should be. He stopped it on a table enablement it will be. I never want to be with us over yourself will come up in STV service. So this is what then we have put it for their So everything we have done it. The next thing is that we have to create the handler here. We have put if you remember in the conflict file I put after you know, cop in this file it will restart the service as well. So I have to create the handlers. So for handler, I have to go to this location. I'm in this location after Goto Handlers. Okay, Simple in the main confrontation file Have to put the entry. Let me tell you how to This is name the same name which you have specified that at least turn a party. So whatever the name you are using that you need to put the same what it will do Service name asked you to pity instead. Is it going to restart it? So this is what it will do. OK, so whenever it required the service needs instructed. So I stood off. You know, instead of going start off reading the task again Same tax again, again. You're going to simply use the handler. So this is what a function of the handler. So the name the same name? The start handler after used in that main dot com figured out. Why am I so here You can see these Turnabout. Let me Is he Check it again? Okay, I'm again Going to this location does on git config If you start a part It is the same which I have used for my handler. So this is what I have done it now The next is your meta. So I have to edit the meat as well. So much just for putting the information like, who is the author and description license? Everything. Even put it in this file that would be filed. Made up. You can see the different is already there. You can put your name description. I can put testing off roll using for two. So quantification. Okay, My company name. I'm just putting you Don't come here. This is what I have done it So many mai tais Only for the rules Who has created the rules? The author description Okay for their Just saving enough. I'm here. So what I have done I've just created my main confrontation fight on in the main configuration file If you see further divided into three more files, like for the stylish in off animal configuring service. And after that I have used some handlers and I'm also copying my industry estimate to my destination. So this is what the role I have created in the next what I need to do. I have to get a simple playbook on in the playbook. I will call this role. Okay, so from this, that's all for this lecture. In the next lecture, I'm going to create a simple playbook on the playbook. I will call this role. So that's all for this lecture on If you have time, please join with me in the next lecture. Thanks. 52. Lab 2 on Roles: welcome to Automation with Enseval. So first in this lecture, we're going to create a simple playbook on the playbook. We will call the roll which I have created for the installation of Web server. So let me kill a simple playbook. So at any location you can clear and you can give any name. I'm just giving about it fed dot y animal on it Always start with two days is on then on which horse do you want to run this labour? I'm giving my well. And after that, I'm running this playbook as a normal user, a normal user doesn't have that much of permissions toe do the stylish in off any packet. So for that, I have to use become, as you call to to sort of happen. A normal user user will elevators privilege. And it will become a good user after that. Here after he ruled that rules rules, let your light kid him about it. So this is what I have to do. It a simple playbook. I have to create it. And here have just mentioned Apache role. So that's all After that, Bring this. Let me show you what So what would you have selectively at my target? So this is my web danceable hyphen. F A list post my web. So what are the service we have in this target group? So Lennix Group, for example, this is the one servers that has specified in this group. So let me log in tow this summer and refer you. So this is the so what I have Let me see. Has to do back in the stall or not. It is not a stone Estimated pulls out there. But actually package is not a star. Get on down. I'm just running my this labour. Okay, on one more thing. I have to love them as my normal users, which have centred for my ensemble again. I'm going to this location we have this playbook on. I'm running it danceable. Okay. On the name off my label assembled this one. I'm even happen Corruption. What will happen whenever it will Oliver desperately It will ask for the password. Let's see. Everything's OK now. Now my playbook has been started. Okay? It is getting the service line exclude or example, do the first thing it is doing. The stylish in off STD packet second It is copping weigh in next artist Emoto Double, double rude or a Stephen directory And then it will start in a nebulous your service. And at last it will use handler and start the service. So this is what you know. We have created the role in organized recon. Understand? We can do all those things in a single file as well. But that was not in organized way. So this is what that concept off rules. Let me log in, tow my website client and let's see the back. It says Mr So I can see a pack. It has been a story now. And if I will go to this location where this I can see a data This file has been copied to this location on if I'm here on if I am using this feelings on did it? Lennox grew dark. Example dark. Come, let's see whether I'm able toe open the steps. I don't know. Now you can see my website is able. I'm on this control Lord and I have just use the link to the tool which can be used to open any website. So I'm able to open my website which I have just created with the help of this playbook, which is using our whole concept two friends, what we have done here. Symbol We have organized a lot of things in a proper way. We have used our rules. Now you can understand easily. What is the meaning off each directories. So we have discussed different different directors. If I'm going into this location rules a party, you can. Three different directors are their files. Handlers made our house like understand the use off east directories. So, friend, that's all for this lecture and hope. You have understand the concept off rules. So there, salt. And if you have time, please, John, within the next lecture. So thanks for watching. 53. Overview about Patching on Linux Server: In this lecture, I am going to discuss about patching on Linux. So was using ansible playbook. Here's a very important topic to understand. Because in any environment where we have multiple annex soul was to manage v1, all the solos should be properly updated. For that we have to do patching on timely basis so that we can avoid any one multi, attack on our Linux hours. In this lecture, I'm going to show you how to automate the one XOs patching using ansible playbook. And also you have to keep in mind few points, few aspects before initiating the patching. So here we have verified the application database processes are running or not. So this is my foster requirement. When the playbook is initiative, it is going to the host that I want to do the patching very fast tab, it should check whether the application or database is running or not. If it is running at that point, short throw a message that foster stopped application or database, then only we can initiate that batching. This is a decision point to start patching. So at that point it is just going to throw a message that please stop the application fast. Then attempt patching. Suppose the application or database is not running on the system. The next task would be, should copy the required rapid file to the managed host. Suppose I want to do the cardinal patching or I want to do some network patching, a simple patching. So accordingly, you have to create your profile and coupled copy that repo file to your managed host. And then it should initiate the patching, upgrade, the kernel patches or whatever you want to do it. And he kind of patching you want you can do after the patching, check if reboot is required or not. So for that, we are just going to create a simple script. I'm going to show you if the reboot is required, it is going to reboot the system. If the system is rebooting, obviously, it will take some time, maybe a few minutes. So with for a few minutes so that the system or server should come up after the reboot. And then was the solver has come up Debugger masses with a new canon wars than it will debug a message that this is a new camera was done after the patching. Defend herself for this lecture. Next lecture, I'm going to start creating a playbook. And what are the steps I have discussed here? I'm going to create the playbook accordingly. So there is always in the next lecture. 54. Lab 1 - Patching using Ansible playbook: Let's start creating a playbook for Linux OS patching. So very fast task in my playbook, that is for verify the application or database processes are running on not I do not have any application on database to show you. So for testing purpose, I'm just considering the Apache processes as an application process. So it is going to check that Apache process is running or not. If the Apache processes running, we'll throw a message that pleases stop the application fast and then attempt batching. So let me log in. This is my ansible server and this is my client machine. I had created a group that is my host group. Let me show you ansible and climbed six forensics on which I'm going to do the kernel patch. So let me start patching. And the name of my playbook I'm giving my you can give any name. Okay. Betty, Great. And become true. To initiate the patching. You shouldn't be routinely task, clarify, application or database, whatever you want to put, you can put running or not. So how we can check. So let me log into my client machine. So this is my client machine. So if I will simplify a PSI Fund EDF and grab hyphen I edge. You can see number of processor running. It means that the processes are running, the application is running. And let me stop this one. System CTO is top as TBD. Again, if I'm going to fire this command, I am getting this output grab hyphen v grab. So if this process is not running, this application is not running. If l five this command, I'm not getting any output. So this is the concept I'm going to use to check whether the application is running or not. Okay? And here I'm just creating a very simple shell script. So the model, I'm going to use shell module, okay? And the Come on. I'm going to use if-else, if ps hyphen EF. This is the command to check the process. Which process I want to check. I am using e grep. I want to check this process HTTPD, and grab hyphen v. This one. And I just wanted to nullify any errors. So this one, let me copy here. And five, this one. I'm not getting any output, but if I'll fire, if I'll start the service, again, I'm going to fire. I'm getting some output here. I do not want to get any such output when I am, when I will run my playbook. That's why I've used this one. Diagonal. So whatever the output is it is, it should nullify. Then echo. Process running. If I'm getting some output here. If I'm getting some output here, it means that processes running, right? I'll echo process. Not used simple if-else here. I'm closing it. Right. Say will fire this one. Let me copy this one and paste it here. Some typo mistake use here. Okay, it's echo. Ok. Let me copy when by one here. And just copy and paste the same command here. So processes running right. Now let me stop this one. I'm saying come on, I'm firing process not running the same condition I am using here, right? I'm here now. This one. I just want to ignore any errors at this point. So for that you have to use this module, ignore underscore errors true. Now, whatever the output is coming, and then it should be process running, a process not running. I want to save this output inner available. So for that I am using register and you can give any name. I'm giving a prop process application process check. So this is the name of my variable we can say. And what were the output I am getting after running this command is going to save into this variable. Okay? And after that, I just want to debug a message here. And the message is this one is equal to. So whatever the output is here, it is going to save here. And if we want to, you know, see what is the output, whether it is processes running or not. So here I'm going to use this and debug, and this is my variable. And to read the variable you have to use this one. And at the last You have to put std out, right and close this one. So this is my first task. Let me copy and let me check the syntax error. And civil it is running now. Okay, let me check the syntax. Syntax is okay. Okay. So let me cross check whether this task is working on not capital K after US here. Verify the process not running. A. Let me start the process. Started with the process. And again, I'm going to run this one. So this time it should throw a message processor is running. I can see processes running. So till here, my ansible playbook is correct. So if, and that's all for this lecture. In the next lecture, I'm going to discuss how to decide whether the label should proceed further or should we stopped here. So that's always in the next lecture. 55. Lab 2 - Patching using Ansible playbook: Let's continue and do the next task. This isn't point to start patching a let me login into my NCBI will so and edit the playbook. So this is my ansible playbook patching. So here you can see in the first task, I have just verify the application is running or not. And I will be getting an output. Either it should be processes running, a process not running. And it is going to save into this register. Now how my playbook will come to know that I need to proceed further or I need to stop here. For that, I'm going to use a module that is module. So let me show you how we can use this module. So my next task is a decision point to start patching. And here I'm going to use a model that is fail module. So if it is getting filled, what messages you want to debug at that time. So I'm going to use message here. And in fact I'm using inventory host name. So it will find out the name of the host on which the padding is filling is because of application is running. So I just want to debug this mess is the host name, this one having running applications. Please stop. Please stop first. And then a TAM batching. So like this way you can, you know, type message. Here. I need to use one condition as well. My condition is that one. When it is going to fail, when the output of this one should be equal to process a running. If the process is running, I want my ansible playbook should not proceed further. So that's why I've used a condition here. Let me check the syntax here. Synthesis, okay? And this is my client machine. Let me start this. Okay? So if I am willing to run this one, it means I'm going to get a message that stop the application. So here you can see at a decision point, we have got a message that Klein six having running applications. Please stop first and then attempt batching. All right, and let me stop this one. Stop means that we are good to proceed further. Right? Again, I'm going to run the same playbook. So this time it is going to skip and we'll start further. Here you can see that process not running decision point to start fetching it is skipping here and moving further. So further. So for this lecture and the next lecture, I'm going to show you how to copy that required wrapper to the managed host. That's always in the next lecture. 56. Lab 3 - Patching using Ansible playbook: The next task is copy the required repo file to the managed host. So this is my ansible, so and I've already cleared our EPO file and this file I have to copy to my managed host. So let me write it, this one. So in this file, the required information is there because your client machine doesn't know from where I will get the updates. So the client machine is going to refer this file. And in this file it will get all the information like which is your yum repository, which is your yum server, which is your satellite several whatsoever. And what the way the client machine should follow to get the required packages. So we need to copy this file to the client machine. So my next task is copy the sub volumes or Carlo rebel kernel, patch it up or I can put this one so you can give the description according to your environment. I'm going to use copy and source. Source sources in this location, that is destination where I wanted to copy to my client machine, pm dot zappos dot d. Like we check the syntax and civil synthesis. Okay? And this is my claim machine. Okay? I'm going to run this one and similar. So process is not running. So decision point, it has escaped this point and it started further and a copy, the kernel patch ripple. Let me see whether the file has been copied and I can see the file has been copied, this one. And in this file all the required information out there. So when from the client machine, I'm going to fire the command, yum update whatever. It is going to refer this file and we'll get all the required packages and will update the system so fast they're so for this lecture, Wilson, the next lecture, bye. 57. Lab 4 - Patching using Ansible playbook: Let's continue and do the next task. That is upgrade the kernel or packages. Like we log into my ansible server and edit the playbook. So before we initiate the Kano patching, I just want to capture the Quran kernel version of the system. I'm going to use a shell module and you name hyphen OK. So this is a command which will give you the kernel was an office system. And I'm putting in a register here. You can give any name. I'm giving this one. I want to initiate the patching. And I'm going to use the module yum here. Name. What patching you want to do. I wanted to do KML patching a state. It should be latest, You can put according to your requirement. And here also I am going to use a register. I just want to put it in a register. The name I have given EM underscore update. And after the patching, I just want to debug a message that is colonel has been updated. But maybe you are doing the patching and there were some ARRA. The patching was not successful because of n number of reasons. But if our debug this message here, the patch has been updated. So there's a wrong message I'm giving here. So I am going to use a one condition here, that is when this one yum update. And here I'm going to use exit status dot RC is equal to 0. It means that this Come on. Your yum update kernel. If it has run successfully, the exit status should be 0. So let me show you another terminal here. Suppose I'm simply firing ls. Come on, I'm getting some output. It means that the ls command has been done successfully. So how would I know the exit status simplify this one? On this one, I'm getting 0 output. It means that my command has run successfully if given any epsilon, you can see that I've got some error. Again, I'm going to fire this one. I'm getting some number which is apart from 00 output means that the last command, whichever one, it is successful. So that's why I have used this one. Right? And let me come out from here. Let me check the syntax. Syntax is OK, but I'm not going to run as of now because I have few more task. That is, check if reboot is required after the kernel update reboot the system, wait for few minutes and debug a message. So that's all for this lecture. In the next lecture I'm going to add these task. So therefore we will see in the next lecture. 58. Lab 5 - Patching using Ansible playbook: Let's continue and do the next task. That is check if reboot is required after kernel update. To accomplish this task, I need to write a very simple shell script. Before to write a shell script, I just want to show you few commands. So this is my client machine and file fire this command. It will show you the updated kernel worsen. Suppose a half updated my Canon. And if l five, this come on at the top, you will see the new Colonel worsen. So here you can see that both the command and the output is same, the kernel worlds and is showing the same. Suppose I have updated my system after the addition of kernel updation. If l five, this command, you name hyphen r. It will start showing the new kernel worsen, but it will fire this command you name hyphen r is still, it will show you the old kernel was done. For that. You have to take the reboot. So I'm going to use the same concept. I'm just going to compare both the output. And if there is a difference in the output, it means that my kernel has been updated. If it is the same output, it means that candle has not updated. So this is my client machine, this is my ansi SQL Server. A task is check if a reboot is required. Okay? And write a symbol shall hear shell script. So first of all, I'm going to create a variable here. And, and that variable, I'm going to use few commands. This one. Okay? I want to know the, I want the topmost output for that I am will be used Head minus1, that top-line output. And also, OK. I just want to print the first line, right? Because I need to compare with this output. Okay? So I just want to get this output only. I need to cut this one kernel, this one cardinal dish, this one from this output. So I'm willing to use shed here. And This, I need to cut this one. This one. Ok. Now I can see this output and this output is same, the same I'm going to use here. Let me put here, right. This is my new corrosion. And now we can say the old kernel. That would be you name hyphen r. So you name hyphen r. Output will only be updated after the reboot. But this output, the kernel underscored knew it doesn't require a wood. Okay, so two variables. We have this one and this one. I want to compare both. So for that I'm going to use if dollar, this variable and if it is not equal to this one. So it means that gunmen echo kinda has been updated. Inebriated means a reboot is required. Reboot is required. And else echo. Reward is not required. Right? I just want to ignore some errors. And register. I just wanted to register this one, the output. So there would be output either the reboot is required or reboot is not required. So I am just saving the output into this register that is reboot. Check. Right? So this is one thing here. And if we want to debug message, you can debug message here. And here you can put this one off. And that's all we'll see in the next lecture. 59. Lab 6 - Patching using Ansible playbook: The next task is a reboot the system by default and symbol will run the task one after the other in sequence silly. That is, ansible, executes the first task. And after the completion of the first task, it will go for the another task. This is the behavior of answer level. But when you reboot your client machine using any common shut down hyphen RY. Now, what will happen? The communication between your ansible server to the client will be broken because system is rebooting, the SSH communication will be broken. So what will happen at that time? Immediately, your playbook will throw an error messages that the client machine is unreachable and your playable would be terminated. So what is the solution for that? Solution is when you create the task for the reboot, you have to use few more models for that. So you can use a module that is module. So using ansible arcing module, we can put the task in background, which is taking more time, and we can continue with the other tasks. So here, when we create a task for the reboot, we will use one more module, that is, module. It will start rebooting. It really started firing this common in background, and it will go for the next task. My next task is debugger masses with new kernel Watson. But also here we one more condition. We can only debug this masses was the server should reboot and come up. So here we have to, you know, pause the playbook for some time. So for that you can use sleep, come on, wait for connection or pause. So let me log into my server and complete this playbook. So my next task is reboot the system after patching. And I'm going to use shell module here. And this is the shutdown hyphen RY now. So if I will simplify this, come on without using any optional other module, what will happen? The communication will be broken and immediately you will, it will throw an error messages that your client machine is unreachable. So after use few more module that is housing and I'm giving one minute. So basically it is telling how much time that this command will take. So I am putting in one minute. Or you can put whatever time you want. And immediately it will, you know, go to the next task. And also, you have to use one more option that is Paul. So Paul basically indicates to ansible how often to Paul to check if the command has been completed. So here we know that the system is rebooting. So I do not want the ball should check the command should completed or not. So here you have to use 0. So 0 means fire and forget. If you do not need to wait on the task to complete, you may run the task are synchronously by specifying a value of 0. So I'm putting 0 here. Now what will happen? It will just reboot your system and immediately will move towards your next task. So I just want to wait for some time. I'm going to wait for the system to come up. And using the module that is pause. And a minutes. One minute I want to it, I know that my system it won't take much time. Hardly, it will take one minute. You can put according to your environment. And the next task is my that is the last task is debugger masses, that is new conversion. So I know that my system after the reboot has come up. And I'm going to use a model that is shell and the commodities you name hyphen r, You can use. Come on modelled also. And I'm going to use registered. And you can give any name here. I'm giving this new Cardinal. And then debug amasses new kernel. What isn't. And all kernel wasn't was before starting, before initiating the batching. I had, you know, capture the Kindle was in here, you can see that. So it was that a district here. So I'm going to use this one only. So my playbook has been computed. Now, let me cross check the syntax. Syntax. Check syntax is OK, everything is fine now. So i had Keita simple playbook, faster. It is going to verify the application. Then decision point, whether it should stop or should move further. And if everything fine. First task, it is going to copy the required repo file to the managed coast, and then it is going to upgrade the carbonyl, check if reboot is required after the kernel update and the Buddha system. And when you use this reboot the system, you have to take care that the communication will be broken. So it should not terminated your playbook. So for that you have to use few modules that is arcing and Paul, and then wait for few minutes. Otherwise, it immediately it is going move towards the next task. So you can use a lot of models like sleep Modelica use pause module you can use, you can wait for connection, and you can give any specific time and then debug a message with the new canal was m. So for, and that's all for this lecture. The next lecture I'm going to initiate my final Plato. 60. Lab 7 - Patching using Ansible playbook: Hello everyone. So let's continue and initiate the final playbook for patching online Excel wars. So this is my final playbook. In the previous lecture, I had shown you the command for the reboot was shut down. Hyphen are white now, this is the correct common shut down hyphen r now. And I just want to check the syntax as well. Synthesis also, OK. And the Solver name. That is for the group patching. Kind six, let me log into climbed six. This is my client six. And let me remove all the files from here. And the UNM hyphen up, this one showing an RPM hyphen QE, last canal. So all the output is in front of you. And I'm going to initiate my playbook. And Sibyl playbook, my playable capital K. And I'm doing step-by-step gathering facts, ds, verify the application is running or not. Let me cause check system CTL is status HTTPD. It is not running. Let me stop and let's see. So I have just started. It has checked whether the application is running and not continue. Yes. The process running. So decision point continue. I can see that it has a message that kind six having running applications, please stop fast and then attempt batching. I'm going to stop this one. Again. I'm coming back to my label process not running decision point. Let me take it a little bit up. Yes. Copy the kernel patch depo. Yes. It has been copied. Let me check. It has been copied now. And it is just capturing the current Colonel wasn? Yes. Initiating patching is patching has been initiated now. It will take some time. They can see that betting has been done. Now. If alpha is common, you can see that it is started showing that new carnivores than this one. But if we fire this combined Union High fauna is tailored to showing the old one. So to make it reflective, You have to reboot your system. Okay. Coming back, debug. Yes. Kendall has been updated. It is checking whether reboot is required or not. It is going to compare both output, this output comma, and this output come on. And if there is a difference, it is going to take the reboot. And you can see difference is there. It is saying the reboot is required. It is required a rebooting the system. And I can see that the system is rebooting Now. This is my system Client C here you can see the new Colonel he started showing here. Now, coming back here, I can see that the playbook is still running. It has not terminated because of that module. I'll sync and Paul module. Now my system has come up after the reboot, this one, it is, it will wait for 60 seconds here. And if you want to continue, can prove press control C and then C. Okay. Continue. Yes. Now you can see the new Colonel wasn't as this one and the old canal wasn't was this one. So from there, so for this lecture, I hope you got idea how we can patch your environment so you can use the same script, the playbook, and modify this playbook according to your requirement, you can add on few more options with that. And also you can remove any options which is not suitable for you. So that's always in the next lecture. Bye. 61. Industrial Project - Stop/Start Control M Applications: welcome toe automation with uncivil. So friends. Today we're going to discuss one industrial project on which I was working in my organization on last week only I was ableto complete this project successfully, So I wanted to discuss this project with all my students so that they can have better in the standing unanswerable and we'll get some exposure on it. And you can also understand what sort of the work you're going to get on instable if you are going toe support any uncivil project. So friends, first of all, we need to understand what is the project. The project was very simple. This is Pacific Team Application Team and out of his team. They're supposed to stop some applications for that. They're using some scripts there, some sort of a scripts they're supposed to, you know, on those scripts manually one by one. First it will stop the applications, then databases, and after that they have to perform some activity. And what's the activity will be completed that I love. This team is supposed to start the service, and then application teams started the application using some short of buskers. So what? Basically, the scripts are doing so scared. Basically, they're stopping instances at the beckon, so we're not supposed to focus much what exactly the scripts are doing. Our part is to automate the stop and start a scripts, that's all. So the condition waas We have to stop application and other based on a sewer using answerable on. After that. Once it will stop the application team and deal with him. They, they're supposed to know, perform some activity on the server, and then we have to again start the Debian application. So cancel E on the server using ensemble playbook. So the playbooks is toe created in such a way that it should start the application one by one. And also they have one condition. If any issue issues come while performing the activity, then the script should not move further and provide all affiliate logs, I suppose, for stopping an application. They have provided me three skips first is kept running successfully on it, moved to the 2nd 1 and while moving to the 2nd 1 it will first check whether the first escape run successfully. Omar. If my first just kept on successfully, it will move to the second. And while learning the second is good for stopping the application. It got some matter. So they want it should have stopped at the same time. It should not proceed further on application teams should able to know what exactly they show is coming. So this was the exact requirement. So wear supposed to create danceable scripts, danceable playbooks in such a way that what are the conditions they have provided us it? Should we fulfill all so friends in the next lecture will understand how we can create an instable on more where you can see these are the sculptures, Travis scripts, the CTM underscore. Stop Noticed. They have provided me, You know the location. Okay. On the name of this group you can see in this activity. So the prescribes you can see one is CTM. Another one is a t m t p DF db Stop an agent start to stop. So our part is to, you know, Rundle scripts with the help of answerable with some conditions, we do not need to bother much like what exactly the scripts are doing. It's an application issue if your scripts in ordering every skirts are getting some error. So our part is to provide them These other locks we have got while learning this curve. This is what we call why we got there. They're supposed to handle on the application. Teams are supposed to handle it. Our part is to automate this word. So from that's all for this lecture in the next lecture will understand how we can design our and simple playbooks using these conditions. So thanks for watching. And if you have time, please. John had been the next lecture. 62. Industrial Project - 2: welcome toe automation with answerable. So friends. Let's stop. So we have to create one playbook and civil playbook for stopping over applications. So the application name is C team. Underscore stopped, and I said so First playbook will stop the mention it scripts in soup kitchens one by one, and also debate the escape clocks. Escape plot means. So while running the well running the skips for stopping the application, it will give some output. Okay, so we want to capture the outputs I want. It should be display while running the label. And moreover, we have to make sure if any off the scripts got failed, then it should throw the fair locks and play book. Should not run. Move further. So this is what we're supposed to do in our first playbook. So let me log into my time machine. Andi, we'll show you if you're running those curse manually. What are the output were getting? So I'm going toe loving toe my plane machine, Vera, that I am supposed to run those cursed. Okay, so those scripts are level on my client machine. So first off, all I'm going to run those keeps manually. So this is my claim machine. Okay? And I'm in this location. These other scripts are here to the first kiss kept. You can see the CTM stop underscored. Assess it. So this was my This is my first escape. See? Demons Stop that. I said Okay on if I'm going to run the script, so let's see to run in this kip, we have to use asset stopping control. Um, application. It is trying to stop him control an application. I'm doing your mentally We have to, you know, do such things with help off danceable. So first, I'm trying to explain you how the people are doing mentally so mentally they have to supposed to run the script like this. What? I wouldn't do you. No, Karina. Danceable playbook for running this scripts. So you can see it is running and desired. Output were getting so well running the scripts they want this output should be capturing. So this is the first pregnancy. The second skills, a pretty deaf underscored the b stop. So let me run the 2nd 1 as well. Stopping for assistance. This is for that. None of this. First, it has stopped the application. Then we have to stop them. None of this. So it is topping for assistance. The first INS has been sexually stopped stopping second instance first off, what we need to understand. What is victory come in? That's why I'm focusing much on to understand what exactly the requirement is. If you understand the requirement, then only we can create the labels. These other scripts we have to run it in seconds with Okay, it will take some more time. Okay. The third is times have been his talk. Okay. Stopping for instance, I believe, for his Chances are they're only four. Distance has been a stop successfully. Okay, so it's very, you know, simple skips. Basically, we have to run the script, that's all. And this is what output is generating while running the script. So they want this. Our ports scripts, output should be captured. One more is for the agent says, Well, I can see one escape, but also agents trump. So this is your stop stopping control imagines. So the 3rd 1 is stopping the controlling agents. And one more thing. One condition I have to put like some issue will come. Some matter will come. It should not proceed further. So I have discussed with the application team like what should be the other? So they said Like while running this groups If you get any failed keyword Phil, keep what is anywhere it will get So it should be stopped at the same time. So this is what they told me And they have provided me one. The script I'm just running It would control you were short of the other will get if any failure was there. So they have given me so that while creating this script we have to keep all the things in mine. So if it is feeling so, we'll get says type of edits We have to create our playbook in such a way that all the conditions should be Fulford. So this is what you know. I'm been trying stopping the application, but let's see, they have provided me one motor skills and saying that if you're getting such type off errors in your and civil playbook, so it should be stopped at the same time, it should not proceed further. So we have to put the condition. Now we're getting controlling application field. Okay, so if you're getting any failed keyword while learning the scripts. It should not proceed further. So this is what the requirement. So friends, that's all for the selective in the left lecture will start creating that our animal playbook. So thanks for watching. 63. Industrial Project - 3: welcome to automation with danceable so friends in the selector via going toe develop our answerable playbook for stopping the control of applications. You can see the sequence of the scripts name like city Monusco Stop Doctor said that with the first we have to, you know, put it in our ensemble playbook and then a PT M underscored a UNESCO DB and it's constructed, I said, and then last agents. So that would be sequins off the scripts that should be running one by one. So let belonging to my on several Several on will start developing our labour. So this is my answerable silver You can give any name Stop control I am dot It always started with two dresses and then you have to give the host host name is I'm putting my web become I got a confirmation from the application team They said it should be run as a route only so become musical true I'm putting what methods before to matter we can put become underscored user it should be ruled and for matters should be sugar Okay on Duh So I'm task The first task is my name is topping the control am applications. And I can mention the escape name as we'll see him in the school. Stop! Assist! That was the name off my application. So what will happen while executing it? So this name will be displayed so that you can I got an idea what exactly is happening. And I'm here using shell Shell model so you can use the shell here. Why? I'm not using Come on model because come on model is having some limitations. Like if you go with the common it will or exterior shell, it will not execute the environmental variables as well as shell operations like re directions and piping. That is not possible with the come on models. So that's why I'm using Shell Mortar. Shell model is basically for executing the and this script, but it is also taking the environmental variables as well as three directions and piping. So all these features were getting with shell morning. So I'm using shell model here. And what is the name off my script that is in o pt eight pt m on then the name off my skip please ctm and just go to stop. Don't s it. This was the script on my name on my script. Okay? And after that to I'm just getting a very simple and then we'll make it a little bit adding more, more things on that. So what will happen with this? It will execute the script. Okay. And whatever the output of the script I'm putting here check under school application check . You can put anything okay. And it Now I want to put me back. My sister message is according to CTM application stop. Sex is fully when I'm putting one condition here. When my this app on the school check Don't ask. The exit status should be zero. What is this skip to has done successfully. Then we'll get this happened at school check. And the school dot assay should be zero. So this is what one condition? I'll put it here. Okay. And it what will happen with this? You will come to know that too. The script has been done successfully, but it is not a completed script because as for the equipment, they want to also put the long messages for control. I'm as well. So that first minute let's see what is output I'm getting here. So to run it danceable Aun said. Well, playbook on the name of my just, you know, simply learning that my answer will playbook in which you have just mentioned the name of my scripts there. So I'm getting a lot of federal here. Let's see, it is telling that no such find is there some type of mistake is here. So type of mystic is it's small as What is it, honey? No, but it does. Stopping the control am application and the name off the scrip is also coming there. C team underscores topped or less it it is funny. It will take some time here because the computer script will didn't take a few minutes. Now you can see the CTM application stop successfully. This is what the message we have got. We have not put any conditions here. I'm not able to get any, you know, application log message here. So I want to make it more specific. Then let me do some martinis here. So as if not what I have that I have simply, you know, executing the script that so, Andi, if it is running successfully for that, I just put a single condition here now I want to get the output as well here. So let me put some conditions here. So what I'm doing here, I'm just the American doubt Put off my come on and do any file and putting to file. And I'm just putting somebody reduction here. So whatever the output, like errors and everything that would be coming into this fight Okay, on did it head what I'm doing and I can see after learning this escaped output off this skipped is going to this file, and I want to read the content of this file. So what I need to do, I'm doing one option here. Name, log message. This is what I'm putting here long, mrs for control applications I'm using. Come on here because I do not need to get any enorme until available. Nothing like they have to. Just simple. Can't this file on did what? A Without what is coming. I'm putting in this register Log Gemesis Whatever name you can put it on. Then this day book underscored. Massive. So what will happen? This will and good kept on this. Get this file. And this file is having the detail off this script while running this script. It will give some output and that are poor will be going to this file. Okay. And I'm again doing this. No. One more deal here. So it will. Can't this file on do whatever the output is coming? It will be, you know, saving this variable. And then with the help of the book, I'm getting an output here, so let's I'm running it. Let's see. Hold. Output is coming now Are getting to take some time stopping the control. Um, application. I can see I've also able to get that log misses off the You can see the scripts, output and the answer Bill playbook. With the help of Enseval playbook, I'm able to get the script locks as well. Morgan. See, I'm getting the stopping control application. Everything is coming there on control. Um, application had been stopped successfully if suppose my script is getting some added. So the person who is running this answerable, they were able to know what exactly the error. Yet we're getting with the well in the scripts. I can understand. How have you how have used created my answerable scripts to get such desired output? So it's very simple here. What? I have been simple. I have created a label. Okay, so this is simple, but who have created But it's still, you know, I have not able to, you know, put the conditions for if it is getting filled, how it will come to know that has been flayed failed and it should not proceed for them. This is also we need to understand that we will understand in the next victim from their soul. For this lecture on the next lecture will add three more conditions Seymour options so that make it complete as pathetic. Government. Thanks a lot you 64. Industrial Project - 4: Welcome to automation with answer Bill. No friends. We have to add one condition. Like when running the script. The control on the script. If there is any fail keyword, it was doing an error named as Field. It should not proceed for them. And how we can do achieve this? For that, we have to add a simple, shallow scripting here with the shell model. Let me show you. So here what I have done along I've just executed my script and what they were. The output is coming. Well, running it it is putting in this file. Okay, now simply have to check in this file time. Nobody. Is there any failed keyword? There are not. If Phil Key, What is there? It should not proceed further. How we can check it. Simple. I would be using exited staters exhibited. Basically, it would be, you know, can't this file on will search for the keyword field. And if it is there, it means my script is not run successfully and it should not pose it for them. So let me show you how we can donate. Simple. I'm here. Okay, I'm carried this file on. Did it will grab for Phil keyword in this file, they and I'm just putting Dagnall so that you were learning it. It will not show in the front. Okay? I just want to know about that. It turns successfully or not. This is what it should tell. Okay, on, then, if I'm using existing is here, as he called zero. Okay, so what? What does it mean? Let me show you that copied. Let me first log into my This is my claimed machine. So same command would have sooner than here. It is their only support. Am running this? What does it mean? This is our put off my script and I'm not able to get any fill. Key word. It means my escape from successfully. And if I'll fire this echo dollar cushion Mark, I'm getting any number of our farm deal. Okay, So it means there's Captain successfully if I run this. Come on. And I got an output like feel keyword is there? So what will happen? My equal status would be zero. Let me show you if I'm here, I'm just putting some field in the file and the last anywhere. I'm putting this just for the testing purpose. Okay, And again, I am running it. I got Phil on again, eh, Francis? Come on. I got an hour. Put zero. Okay. The same condition I'm using. If I'm getting an output zero, it means there is a film. Keyword and output of the script on it. Should consider that application stop filled. Application is not start properly. Okay, so I'm using it. If dollar question mark is equal to zero, what does it mean? It means then echo application stop filled means I tried to stop my application with this. I tried to stop the application with this script, but I got another so stop filled. I was not able to stop my application. But that's good else. If I'm getting any other number, it means Phil, keep what is not there. It means application is a stop successfully. Application stopped. Right. So this is a simple thing I've used here. Okay. And now we're learning it. Well, my learning this come on and that it will throw this application stop or obligation Stop filled. The biggest in the storm. So what difference will throw application stopped our obligation, publican, stop feel or application is stopped. it will be saved in this variable tonight and here we have to teach the condition like first condition Is that now I'm going to change. Here happen the school check dot Ask Tedy out is equal toe my obligation Stop and I application message Stop! So what does it mean? Support? I'm getting this. Okay. Application to stop, then see them application to stop successfully. I put one condition where my this Ap underscored checked out the city out. It should be equal to application is stopped because while learning this come on, one variable will be coming one out, Purple becoming. I love this application to stop feel or our biggest in this stop and whatever the output is coming, it will be saved here. So with this condition, I'm justifying whether my application is stop successfully or not. So I'm just putting CD America's in a stop successfully when this should be abolition this stop. Okay, Onda, If it is fear, then he can put another check for that. Okay, De book CD. Um, application stop has been feeling when this as he called to this one, right? Simple. So I'm just copying it and I don't think running it, stopping the application, controlling application. And if it got fear, even though I'm getting there, log message. So if it got feel so without put off my stem or put too, we come to know what exactly the issue. What exactly the error message upcoming. So this complete Now you can understand it is running the application. It is checking with a legacy. This control arm application has been stopped successfully. Right now you can see the seat controlling application. It stops successfully. It didn't get feel here on also, I can see the messages supported. Got Phil here. Okay, then. But this log message will come to know why it got field were in court. Failed. Okay, so, like this fail, you have to double up the labour. So, friend, that's all for this lecture. Okay? And the next lecture will understand something more about this kid. Thanks. What you 65. Industrial Project - 5: welcome toe automation with an civil. So let's continue. So, friends. As of now, we have understand we're learning our playbook. It is executing the inspectorate scripts as well as we a guard getting and desired output and will come to know whether my scripts around successfully Let's test it whether if I'm getting some feel keywords. So I got one a script, this one on day you can see here. I got this script. Andi, feel running this skip will get some feel keeper. So let me try with this my answerable playbook, Andi will come to know that if it is, any field keyboard is there, whether I'm able to get the message or not, so let's do the changes. So I stood off this. I'm putting the name off my this application. This just for the testing was and bring it, stopping the controller on. Did I know that we're learning to the skip A field keyword will be coming in output off the file on with the shallow script. What will happen? It will check whether the field keyword is there or not, and it will find it. And then it will throw a message like it got feel. Stopping is not happened properly. So this is what I was expecting from the script. Now let's see. Stopping it distinguished off the control. And I can see I got that. I'm ctm happening. Stop has been feeling and you can see here Application controlling application got field. Okay, so what I have done Simple. You know, I have for the testing, but was I've seen my script so that just to cross check whatever I'm doing is correct or not. So while learning the manuscript on, maybe if some fill keyword is there, so it should not proceed further. And you will come to know that with the log message why it got feel on. It was through a message. So this is what I was expecting and I gotta decide our poor so friend, that's all for the selected in the next lecture will understand a few more suspects off this answer. Political. Thanks for watching 66. Industrial Project - 6: welcome to automation with answer. No offense as if no, we have done the testing with the single Skip Now on did it at the singles clip. If any field and it is there, it will toll. But one more condition I want to put here while moving to the second escape after the first is kept have been done successfully while moving to the second script. If it got feel, it should not proceed. This is what I need. If it got field while at the fastest clip, I do not want it should proceed for the father. So let's see how we can do it. So again I'm putting it here. I have put the corrected script. I've just changed with the film. Okay, I would think it's done. Find no. So I'm moving to the here I want, like the well moving to the next kid. It should wait for some time. And you can use a simple you know, model Here, let me show you Wait for several sample and waiting for 10 seconds. So the more delivered for you can use here. Time out is equal to 10 seconds. What will happen before moving to the next script. It will wait for 10 seconds here. Okay, Now my next task is stopping every tm None of this. And what was the name for that? A PDM on the school death underscore. Devi underscores. Stop. My daughter said so. That was the name of the script. Okay, Onda shell I'm using with shell here on the name off. My skin was a B if we tm on and let me check it from here, okay? We have to make it up so that you can understand more. Okay, so I'm running my second script here, okay. And the same thing again. I have to put it here. Some conditions, Like while running it should through an output. Tim, I'm putting t here. Whether all outputs whether it's useful error, it will be connecting into my this time. Nobody out three again. I'm putting the same condition here. Can't champ out, t I blew it with such for field keeper. Definable if exit the status is equal to zero. Stan Echo, D b stop. Feel anything you can put it. It's just availability in. See if it is some key word that we were saving available else cool. Did they stop? If we the tongue and condition I need to put when? No, I'm putting one condition here. When? What condition? I'm putting here. I'm taking for my previous one This as you could do this one. So I need to understand one thing Suppose have run this script. Okay? And it was done successfully. It means that I got this app. Stop. Okay, So while learning the second descript, I'm checking my condition with my first descript. It will check whether my first script run successfully or not. My first escape plan, Waas City went to school to stop. So if it is done successfully, it will go and output. APPA, stop! So here what? I have checked here. So that was my variable. Okay, on the same condition have put it like autumn disc loot, techno tested. It should be equal to stop. So this is what simple condition I have used Okay on did it if it is running here. So again, I'm putting it in variable db underscores tutors. It's going to chat. So whatever the I would put off this company is coming. Whether it's David stop field or a stop it would be saving It would be, you know, seven to this variable That is your db underscored. Check Devi on this question to the best click check. Okay, again, I'm putting some The big message EP idiom TV Stop Feel when God feel commission When my this Okay, don't ask t out in the cold with this one. Same condition I'm using here. Just a game off putting conditions. Okay. And the log my says you can put here name, log message for happy to you maybe stop. Okay on do for that I'm using Come on, more do legal new shallot with no issues Get this one It would be coming into this file and I'm putting register here. So what with output is coming log Emmis one Because Lagrimas de I already used here. So I'm using some of the name and then de book messes as you call toe this one message log message one. Don't ask Tilly out under school lines This one So that wanted with output were getting while learning this crap, It will give in front off you Okay, on one more condition. I'm putting here like my diva. If you tear tv have been stopped successfully when Debbie and her school stop status. Check this one. Don't ask Tedy out condition. Is this on David? Stop. Okay, on I again I want to sort of stop for some time. Name over here for some time with for 10 seconds or whatever. It was a requirement. Like while moving to the second script should wait for some time. No. You have London Vokey. One more model. That is how to wait for some scripts. So friends were condition I have used here, so first discovered will run. So whatever the output is coming into this file, okay? And whether stop or fail to keywords, really one keyword we're becoming like, whether stopper feel it would be saved here. No, While running this my second script medium. So it should check like it will only execute the script when it will satisfy this condition . The condition is this one underscored. Check this one, Pastor visible to application start. If your first application is stop successfully, then only it will go for the 2nd 1 Okay, So this is what I have created the playbook. Okay. So, friend, that's all for this lecture in the next lecture will execute this one on. Well, she that we'll see that how that would put this coming. So thanks for watching. 67. Industrial Project - 7: welcome to automation with answer So French less continue. So in the last lecture we have configured about two scripts. One is for the CTM. That is for stopping controlling applications on Once it got successfully, it will move to the 2nd 1 That is for the stopping the database. Instances on condition was there. If your first descript got fear, it will not proceed further. So we'll do what the chickens first I'm going to run my label on. Let's see, this is my answerable Silver on Dio, This is what I have created for you. Get with check for the first script and it will move to the 2nd 1 Okay, I'm just coming out and I'm running it for you. Let's see. Stopping control. Um, application first. The CTM on this was stopped on a set. It will take some time here. I can see that my city My application hasn't stopped. And also I got the log message night. It has moved to the second ISCO's topping A pt m. D B. It has voted for 10 seconds. This is what the model have used for weight for 10 seconds. Now you can see the beautiful output. I'm getting The skipper is running and also I'm getting an output as well. The log messages again I just stopping a pretty MDV. It will take some time because a lot of services are stopping. The four databases are stopping us for instances Idea. I don't know what is likely The scripts are doing at the beckon our bodies to just to execute that skips on water without foot is coming that, after shown at the front of the interval skips this That's all for our our job is to But what? This information That's all I can see that this is what I I got it. Like my extensive returning the PMDB has been successfully stopped And the log my says you can see how beautiful the log Mrs I'm getting here. So this is what the beautiful output I have got it. And this is what exactly the requirement? No, my equipment. One more requirement is like my first escape got field should not force it for that. So I am doing some 10 years and my first escape. It's for the testing poppers. I'm doing it. Okay, so here I'm just putting a script. I know that there is a script for that. This one. So what will happen? This couple them it will feel on, did it? If it got Phil, I will get an error message. Like why it got filled. But I just want to check one more thing here. It should not proceed to the second script this year. A BDM stopping off the database instances. So let's see. Let me cross check whether my script is correct or not. Okay, I'm just school food, right? Everything's fine. Now again. Have it on my script. Stopping the control. I'm application. I know that the script which I have given in this playbook it got feel. And as for the condition, it should not proceed to the second escapes. Let's see. Okay. Again. See the C team. African stop has been feeling some failures out there. Night treated for 10 seconds. I don't wander. Should proceed for the 2nd 1 It should get another. Now you can see it shouldn't. It hasn't moved to the 2nd 1 because the condition has not made here. You can see that David checks to this condition has not made here. So now you can see that if my first script got feel, it will not proceed to the 2nd 1 So this is what exactly I was looking for. Okay. And let's move to my property. So in the ppd, everything is there. This is for the skipper have created on this paper. It is already a test. With my course model, you can go through the people, see and understand this couple to have credit. Okay, Andi, the agents also, you have to read it so well, adding the agents, you can again put the conditions like if my devi status is fair, it should not pursuit for the A pretty imagines like this where you can get in the script for the starting as well. Everything would be the same. You have to change the script, name and the conditions. That's all. Okay. So from their soul for the list this lecture hope you got an idea how you can deal with the , you know, small, small projects. And how can you can create the automation scripts using answerable on do a little bit off shell scripting. It's also required if you want to make your descriptor more I could it and useful So you have pain or LEM shall scripting as well. So, friend, that's all for this lecture. Thanks for watching. If you have time, please. Joanne Whitman and ex lecture.