Ansible for an absolute beginner | Vikas Yadav | Skillshare

Playback Speed

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

Ansible for an absolute beginner

teacher avatar Vikas Yadav

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

38 Lessons (4h 19m)
    • 1. Welcome

    • 2. Basics of Automation

    • 3. Overview of Devops

    • 4. Basics of Configuration management

    • 5. Pull based vs push based configuration management architecture

    • 6. Ansible: A birds-eye view

    • 7. Overview of YAML

    • 8. Lab Setup

    • 9. Virtual Box on Windows 10

    • 10. Create your first virtual machine and install Ubuntu Linux on it

    • 11. How to create a full clone of your virtual machine

    • 12. Establish connectivity between your virtual machines

    • 13. Setup Local name resolutionn

    • 14. Installing software in our lab

    • 15. Setup passwordless ssh

    • 16. Ansible Terminology

    • 17. Running your first ansible command

    • 18. Navigating ansible documentation and writing your first playbook

    • 19. Use Git to clone course repository

    • 20. Inventory management explained

    • 21. Working with host variables

    • 22. Working with group variables

    • 23. Things to know when working with variables

    • 24. Inventory Parameters

    • 25. Working with playbooks

    • 26. Idempotency

    • 27. Privilege escalation

    • 28. Handlers

    • 29. Facts

    • 30. Type of Variables in Ansible

    • 31. register

    • 32. variable files

    • 33. Dynamic variables

    • 34. Resuable Playbooks Import

    • 35. Resuable playbooks import tasks

    • 36. Vault

    • 37. Roles

    • 38. Project: Playbook to replace Sudoers file using Ansible

  • --
  • 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.





About This Class

In this course, i will help you master the concepts of DevOps and automation and after that i will help you start on your journey to become an Ansible Expert. We will cover the following topics:

  • Basics

    • Basics of Automation

    • Basics of DevOps

    • Basics of Configuration management

    • Pull vs Push based configuration management architecture

    • A birds eye overview of Ansible

    • Overview of YAML , the language of Ansible playbooks

  • Setup Ansible lab environment

  • Understand Ansible Playbooks

    • Concept of idem potency in playbooks

    • Understand Privilege escalation

    • Understand handlers and how you can setup your own event handling system in Ansible

  • Organizing playbooks using

    • Imports

    • Includes

    • Roles

  • Deep dive into inventory management

    • Understand host and group variables

  • Gathering facts about remote machines

  • Learn about variables in Ansible

    • different types of variables in Ansible

    • using register to manage return values

    • static vs dynamic variables

    • include_vars vs vars_files

  • Ansible Vault

    Link to Course repository on gitlab:

Meet Your Teacher

Teacher Profile Image

Vikas Yadav


Hi Everyone, 

I have been an IT engineer for over 11 years now, during this time i have worked in a many fields like networking , systems engineering, virtualization , unified communications and more recently cyber security. I lover tweaking around with systems , deploying and configuring enterprise infrastructure and applications. 

On a personal level, i love reading about historical events and characters and have been trying to learn how to surf (to no avail ;)). 



See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
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.


1. Welcome: Hey, guys, welcome to my course unanswerable. I'm delighted that you gave me this opportunity to guide you on your part to become an automation expert. We will start off with understanding the basics of automation, such as what is the need of automation in today's enterprises and how you can start on your automation journey. Then I will tell you the basic principles off the ropes and where does sensible fertility. Then I will give you a bird's eye overview answerable without going into too many details, after which we will set up our lab, which we will use for the duration of this course. Next, we will start writing our first playbooks. Use various models to accomplish complex tasks very easily and understand how you can get privileged access on the remote systems. Then we will understand how you can set up your own event handling system in danceable using handlers. We will finish off this section by doing a little project. After this, we will take a deep dive in inventing management. We will talk about group and host variables and how you can mobilize your inventory. We will talk about how you can organize your playbooks using import, include and rolls. Next, we will talk about various variable types and answerable and how you can use them using techniques like register. After that, I will show you how you can gather information about remote systems and use it in conditions. We will finish off by understanding danceable wort, which is a technique to safeguard your sensitive information in answer now, what about myself? My name is Vikas and I have been in I t Engineering for over 12 years now. Or this time I evolved in various technologies like networking system management develops more recently cybersecurity and big data. In the end, a small note from my side. Please, please, please leave your feedback at the end of this course as it helps me improve the quality of our content and keeps me motivated. But this will come to the end of this section. I will see you in the next by 2. Basics of Automation: Hey, guys. Into this world, I t operation teams manage ever changing complex I T architectures built on multiple platforms and complicated technology stacks. Some of the issues that organizations face in today's ever evolving landscape are unconnected management does, making it hard to manage your applications and data complex. Scaling procedures that make it difficult to scale up or down based on demand and inconsistent policies and processes could also add to the overall complexity. Now, idea automation helps you resolve some of these issues. I the automation is the act off automating a manual process. For example, you might need to do a monthly restart off some of your servers in their traditional world . This would require a human to log in and perform the restart based on the number of servers . This could take a lot of time. For example, I once had to patch and restart 60 servers. I had to log into each one off them on the update command, wait for it to finish and then removed the server. All this would take me roughly fire to sound minutes on a single server, and if you multiply that by 60 by the end of five hours and looked like this banging my head against the table this time could be brought down considerably if you automate the tasks now, what are the benefits off or commission? You can improve the overall infrastructure performance and compliance by maintaining a consistent configuration off your applications by detecting and maintaining appropriate patch levels, thereby increasing the security off your system. You can also increase the efficiency and consistency off your operations and processes by automating manual tasks and minimizing human errors. You can also again and understanding into your workloads by understanding the dependencies between various systems and processes, and also by anticipating capacity requirements which eventually help you to auto scale seamlessly based on the man. And therefore you can increase the overall performance and availability off your system with the help of automation. Now all this is well and good, but how can you start without permission? Well, it's very easy. All you have to do is identify a single manual process in your organization that is very easy to automate. Once you've identified that single manual process, for example, Lexie restarting servers, you then automate that single process by using automation tools like answerable now, once you've successfully automated that single manual process, you can then rinse and repeat the same process so you can pick a second process. Let's say patching or to make that and then go on to pick the third process. Now, I hope you've understood why we need automation in current I d world. With this, we've come to the end of this lecture. I will see you in the next one by 3. Overview of Devops: Hey, guys, before we start off, I want to introduce a few concepts so you can start on a sure footing. They're start with develops. In the earlier days, you had different teams. For developers and system administrators, a developers mindset was more focused towards developing the product and pushing the cord out to production as fast as possible. Now this would sometimes be in conflict with the mind set off a system administrator because system administrators were more focused towards running the operations as smoothly as possible. And maintaining system up time now develops is a methodology relies on increased collaboration between the developers and the operations stuff. Does the devil in Develops is for developers, and the UPS is for system administrators. It achieves this collaboration by automating as much as possible. Now there are three primary areas in develops infrastructure automation where you create your system always conflicts and APP deployments as Gord continuous delivery where you build test and deploy, or perhaps in a fast and automated mela and side reliability engineering. Very operating systems monitor and orchestrate them and also designed them for operability in the first place. Now, if you are interested to know more about the drops. I would recommend you to go on the Internet and research about develops and age. I'll methodologies with this. We've come to the end of this lecture. I hope you liked it. And I will see you in the next one by 4. Basics of Configuration management: Hey, guys. Another topic I want to tell you about is configuration management. It is simply an automated method off maintaining the state off her computer systems and suffers. There are several components in a configuration management system, which include servers. Storage is networking and software. The goal off a configuration management tool is to maintain these systems in known determined states. Another aspect of configuration management system is that you can describe the desired state off your system, and the third aspect is the use of automation. Software. Tools toe ensure that target systems are maintained in the desired state. The primary benefit off configuration management is that your systems and suffers are always consistent with configuration management. You can ensure that your configuration is correct because the configuration management system ensures that it is correct. It also allows you to scale your interest sector and software system quite easily based on demand. Now, some common configuration management tools are that had sensible chef puppet, etcetera. Now, if you're already working in I t, you might have heard a similar term. Change management configuration management and change management are too closely related, but different times configuration management deals with the state off any given infrastructure or suffer system at any given time. Change management deals with how you make changes to those configurations. Think of it this way. Configuration management is the configuration at any given time. For example, the various settings often application and change management is the process for proposing, reviewing, implementing or potentially rolling back changes to those application settings or configurations. But this will come to the end of this lecture. Thank you for watching by. 5. Pull based vs push based configuration management architecture: Hey, guys. Configuration management tools follow two different architectures toe. Achieve their objectives. Pull based verses. Bush. Based in a full based architecture. You have a master server, which stores all the configuration information, and then you install agents on each of the server for which you want to manage the configuration. In this architecture, the agent will regularly pull the master server to check if there are any changes. Tools like Puppet and Chef used full based architecture. It is called full based because an agent pulls the configuration information from the master server not compared to pull. Based in a push based architecture, a central server pushes the configuration changes onto the target systems. Answerable is pushed based in a full based system. Clients contact the server independently off each other. Therefore, the system as a whole is more scalable than a Bush system. How it would the downside is that you need to install and manage an agent on each of the target systems. Now, in a push based system, it is very easy to do the initial configuration as you do not need to manager or installing agent. However, once you start scaling your infrastructure, things start to get complicated and you start seeing performance issues unless you do stuff like hyper training, etcetera. Now there's one more entity I want to talk about. It's called a version control system. For example, get this version control system helps you version control your cord and makes it easy for you to roll back your changes. Now in development environments, all the court and configuration will be stored in this version control system, and the master servers, whether it is pushed based or pull based, will continuously pulled the version control system for any changes. Therefore, the information or court gets stored in the version control system, gets version control. And then the master servers pulled a version control system for changes in the court. And then, once they receive any changes based on the architecture, the agents will either pull from the Masters over or the Masters ever will push those changes onto the target systems. But this we've come to the end of this lecture. Thank you for watching. I will see you in the next one by 6. Ansible: A birds-eye view: Hey, guys, let's talk about answerable in this video. Answerable is an idea automation, configuration management and provisioning tools. It helps you describe a night, the application infrastructure in something called playbooks. It provides you with a simple automation language to write the playbooks, and it also provides you with an underlying automation engine to run those playbooks. Some of the features off answerable are it is agent lists, so you do not need to install an agent on the server, and you do not need to also manage an agent. It uses ssh to establish secure connection. It follows Bush based architecture. It is built on top off fightin, so it has a lot off functionalities of fightin in bed. Now let's have a look at the basic architecture of Sensible. Now we have a master server which stores all your configuration instant information and can also run answerable playbooks. On this master server. We have an inventory file, and this file contains a list off all the servers against which you want to perform some tasks. For example, Batam deeps no. These tusks are grouped together in what is called a play, so play is nothing but related tasks that you need to perform on. A server display is stored on what is called a playbook. So again, a playbook has a play and the play is separated into multiple tasks. For example, you might want to perform a patch update on your servers and then reboot your servers. These are two different tasks. So task one in your play will update the server and task to win your play will reboot the server. These two tasks together will be called the play, and the play will be stored in a playbook. Now, lastly, we have the servers very want to run these plays against answerable Master server will assess it into these servers and then execute the task. These playbooks are returning Yemen, which is an acronym for Yemen and markup language. We'll talk about family in an upcoming lecture. With this, we've come to the end of this lecture. I will see you in the next one by 7. Overview of YAML: Hey, guys, let's talk about some basics off family. In this lecture, Yemen is basically a human readable, structured data former, which means it is a former to store structured data. Now, what is a structure? Data structure? Data is some data that has a structure around it. For example, all the books in your library can be structured with the book's title number of pages. The book has the price of the book and water, and structured data helps us recall that data quickly with the use of the structure that we put around their data. Now there are some rules around Yemen that we should know Yemen files and in dot Why am L? Families get sensitive and Yemen does not allow the use of tabs. It uses spaces instant as tabs are not universally supported. Now let's have a look at some of the data types in Yemen. Yemen excels at working with map ing's, which are nothing but hashes or dictionaries sequences, which are nothing but lists and scale er's, which are nothing but strings or numbers. So this is a typical Yemen file. It ends with dark by a MLS extension, and then we've got three dashes that they want to start off a Yemen file. You can put a comment insider. Yemen filed by typing hash symbol and then anything after that hash symbol is a comment. Now this is an example of a scale off different types, or title is a scaler off type string. But what is a scaler? Scaler is nothing but a variable so it can hold multiple values. You know what is a variable? It is a placeholder that stores some information. So a court title that stores history pages, their stores and, indeed, er price their stores of float and for sale that source of bullion value. No, you can also have sequences in Yemen, and the sequence is nothing but a list. So, for example, here I've got a sequence which has oy an animal at single level. Now you can also Lester sequences now in nested lists or sequences. How unis them is by using a space before the value. So I've got a value off toy here were important by typing in a dash and then space and then the value to create the next level. What I've done is I've used a space and then dash and then space and then a value after that. So with the use of this space here, I've created a nested sequence. No, A mapping is nothing but a key value pair. So it has a key, and that key has a value. So, for example, drink is a key, and the value for that key is called drink or golden school drink. No. In map ings, you can also include sequences. So in this example, core drink or cold underscore, drinks will be a key and the value would be a sequence. So we have three values inside that sequence. Now, this could also be a nested sequence, so I can even go and put Pepsi Max here. So to do that, I've been little type and at the same level. I need to type in a space first and then dash and then a space to create the next value and then type in, Let's say Pepsi Max, and this will create a nested sequence. Now, next is a flow collection and flow collection is nothing but Akiva Loop here where we have multiple values for a single key. So we have fruit as the key and it has square brackets to start a flu collection and then multiple values for fruit separated by a comma and then to dinner the end off Yemen file. I got three dots. So this is a structure off Yamil file. This is not a Yemen course. So I would encourage you to go online and study animal, if you like. With this, have come to the end of this lecture. Thank you for watching by. 8. Lab Setup: Hey guys, if you made it this far, I congratulate you on your progress. We're done with the initial theory and can get our hands dirty. Now, here on the slide, I have the architecture of the lab that will set up on our computers. We will use virtual box as our virtualization engine. I will set up three virtual machines. One of them will be the masters. Over there, we will install in danceable. We will also have to climb machines where the server will push the configuration changes. I was specified one of the client machines in production environment and the other in development environment. This will similar to the real world scenario where you will have to deal with multiple environments and your changes will need to be pushed to lure environments first, such as a development environment before they can be pushed to production environment. This is to keep the production environment at a freak. Now each of these virtual machines will also have to network adaptors attached to them. First will be a breeze. The doctor that will be used to communicate with the Internet, download updates and any other software. This adapter will have a DCP assigned I p address. The second adapter will be used for inter virtual machine communications. So, for example, when answerable masters ever wants to assess it into any of the client machines and run any automation scripts, it will utilize the host only adapter. The host, only our doctor. We'll have a statically aside, i p address in the range of 1 90 to 1 68 56 cortex. In the next few lectures, I will show you how to install virtual box on windows and then create your first virtual machine and install open toe Lennox on it. After that, I will show you how to colonia virtual machine. What I want you to do is to create one word your machine install open toe and then cloned the other torture machines in the center. But this we have come to the end of this lecture. Thank you. Watching I will see you in the next one by 9. Virtual Box on Windows 10: welcome. In this lecture, you will download and install virtual box on the Windows 10 host operating system. So to start, you need to go toe history, GPS, virtual box dot or that should take you to this page. Once here, you can click on download Virtual Box, and that should take you to the Dollar Lords page. On the downward speech. You will see a list off packages for different host operating systems because we're installing it on the Windows host. I'll click on Windows hosts, but if you're doing it on linens or Mac or Solaris into Zoe's, that should automatically start the dollar. But it gets a lot off it because I've already downloaded virtual box. Once you've done the download, then you need to go to your local file system where you don't order this, um, package. I've done it right here and then double flick on the package that should start the installer and you can click next year. Just next. Next year is very You can click yes, and then install. That's your start insulation number. Sassing me do provide my admin user name and password self like yes, here, and that should start the insulation right away. This is a pretty quick installation, so we'll just wait for it to complete. I think it's almost done. You can also dollar other things for virtual box if you like. Like it s stick is so extension pecs. Meanwhile, the installation's finished south Click on finish. I'll take this first because I don't want Marshall box to start right after my insulation. But if you want, you can keep it. Click and start the application right away. A click finish here on I can see that the virtual box icon is here. So this is it for this lecture. Thank you for watching. 10. Create your first virtual machine and install Ubuntu Linux on it: all right time to create your first virtual machine. You can do this, my first going to a virtual box manager, which is the application you'll use to install and manage a virtual machines. You can create a new virtual machine in three ways. We can click new here. You can go to machine and then take new Oregon type in control and from your Windows machine. So take new here. I need to give it a name and specify what operating system will install on this virtual machine so I can type in Windows and it will ultimately tape the type and version information. Or I can type in going toe and it should change the type inversion toe. So we'll be installing open to for this demo and I'll click on next. I was giving me the editor because I already haven't, so I just call it Dash One, and I can click on next here. I need to give it some memory so I can do that by either moving this later. Or I can install memory by typing in here so I can say, Who's it? Afford it and it's gonna give it two gigabytes self time. No. A small note you should never locate. More than 75% off total resource is available for your host to all the virtual machines running simultaneously on your host. For example, if I ever laptop, which has eight gigabytes of memory, then I should not allocate more than six gigabytes toe all the virtual machines that will be run simultaneously on my laptop. If I do that, I could experience blueness system crashes or some of the letters. But I've got a naked machine and I'm just allocating it to zero for it and be or two kilobytes, so I should be fine. So click next. Now if it is asking if I already have a virtual disk. If I want to create a new one, I need a new virtual disk. So to create no sassing me. Tell it the file type I want to use. There are three options. Greedy I ve H D v M D K v D. I is the native file format for Virtual Box Bhd is supported by Microsoft and G M D. K is supported by the empire. No, if you want to go for VH DRV Enrique, you might experience that. Some features are either not supported, are not available on virtual box, so I will leave it as video. From now on, I'll click on next. No, I need to specify the stories type. There are two stories. Types, dynamically located and fixed type. Dynamically allocated will only use the space as it consumes. So even if I have left, they located 32 gigabytes to my virtual machine. But I'm only consuming, which means I only have files worth 10 gigabytes on that virtual machine. It will consume 10 gigabytes on the host machine, whereas in fixed size, if I specify to do gigabytes, it will always consume 32 gigabytes. It takes a bit of time to set up a fixed size hard disk, but once it's set up in some scenarios, it is faster to use for the purpose of this demonstration. I'll keep it as dynamically located, and I'll click on next. Now I can specify where I want to store my hardness. It is generally store under your using it virtual box Williams and then UVM name. That's the default file pot for virtual box to store their virtual machines. But if I want to change it from the D four, but I can specify it. So let's say if I will not save it into my one drive, I can go one drive and save it and there, But I don't want to do it, so I cancel out of this yet I can specify the storage space located to this virtual machine . I'm gonna give it to Giggs and I wanna click Create. Now it has created my new working machine, and what I can do now is I can go settings again. Three ways I can right click in click settings or use the settings I called up at the top, but I could have corn machine and then cities so machine and then sent takes. Yes, I need to go to storage and then I need to click on this empty See the icon, which will take me to the optical drive. I need to click on this little city here and then Jews were still optical drive and can then need to specify the eso. Now this is akin to putting your operating system CD in the optical drive off your physical machine. No, I can click OK now and I can click. Start to start the installation off into now. For those of you who do not have an operating system image ready, what you can do is you can go toe to doctor slash downloads slash the stock are you could go toe open toe, doctor, and you can download a copy of gone toe from here. So you've got very assumptions cyclical ableto desktop which we will be installing in this temer weaken dentally download. Here it is a free, open source software, so it is good for your lab systems and some cases production systems as well. Now our virtual machine is booting up. One thing to note here is that this little piece of information this little piece of information, this is called the host key. No, What normally happens is if you have an operating system that does not suppose most pointed integration and you're doing something in the host up in the guest operating system and your Moses captured by the guest operating system. Now, to get the most back onto host operating system, I need to click on this host key. So if this was an operating system that would not support most pointed integration, and I mean here in early to click on that control to get out. So, for example, you doing something here, right? You're typing something on the browser, you're clicking something. Are you just playing, playing a YouTube videos and just going through the playlist? Now you want to come out off that machine and shut down because you've completed your work , you'll have to click their control and you'll get control on the host operating system. So from here back into the insulation, we need to choose the language. We live English. Before then, we can recall install one, and that's just started in solution. Now we need to choose the keyboard Leo. We leave it as default begin to continue. Now. We can either do a normal insulation, so it's gonna install some Web browsers, utility office software, games, media players of those things. But I can just do a minimal insulation, which is faster, but it's gonna get installs less number of items on my machine, but I can always download Install these later if I want. Don't know, updates will download some updates while it's installing, so I don't have to update my system after in solution. I could also installed some third party Softwares for graphics and high WiFi. But I leave it in Maidment in solution and then antique that I can't take on continue. Let's ask me if it wants to erase disk and insulted 12 because it's a new disk. We can click that. If you wanted to partition the this, we could have called something else, and we could have partitioned the disc. But I just want to use this now. So remember, this is not the host operating system. This this is the virtual hard disk re allocated for this working machine. So it's going off. Use the free space on my host operating system anyway, so multiple continue, and that's my time zone correctly. So no problem. I need to specify a name here and possible. I have the capsule. No passwords are really important for the machines that will be connected to Internet, so make sure you got a secure bus would, if I click on Logan automatically his call log and log me in automatically every time. If I say required my passport, this is more secure. Safe your machine is connecting to Internet. Just make sure you require password every time. Logan. It's a bit of an hassle, but it's more safe and secure My starting the insulation. What I'll do now is I'm gonna pause the video, and I will resume once it's finished. Insulation. All right, welcome back. So abundance is installed on my virtual machine on. What I can do now is I can safely shut down the washing machine or I can either keep using it. So that's it for this lecture. Thanks a lot, and I will see you in the next one by. 11. How to create a full clone of your virtual machine: All right. Welcome. In the previous lectures we installed virtual box. We created our first virtual machine installed goingto stop on it, and we talked about snapshots. The next feature I will talk about his clones clone is a duplicate copy off your virtual machine. There are two types of clothes full clone and a link to run. A full clone is an independent copy off a virtual machine that shares nothing with the parent virtual machine. Ongoing operations are completely separate, but the disadvantage is that there it could take some time to create a full blown. The second type is a link groom. A Link Lon is a copy of a virtual machine that shares the virtual disk with its parent in an ongoing manner. This conserves the space and allows multiple virtual machines to use the same software installation. In this more, a new difference ING image is created where the parent disk image is the source image. If you selected the current state off the source virtual machine as a clone point, a new snapshot will be created implicitly all files available on the parent at the moment off. That snapshot creation will continue to remain available toe the link clone. But ongoing changes to the virtual disk off the parent do not affect the link loan, and changes to the disk off the link long do not affect the parent. Some benefits are that it conserves space, and it created a lot quicker than a full from. But you cannot power link loan if you do not have the parent PM. Also, performance may degrade over time. So enough with the theory, Let's see hurts them. It's very easy. All you have to do is you need to open up rectal virtual box. Select the virtual machine for which you want to do a full clone, or Lincoln like Click can do control. Oh, or you can select one. From here, you can name your clone. You can read Initialize the Methodists, which will assign a numeric address. Do you network cards click next, you can choose a full or Lincoln and click next again. Choose what the clone so current machine said. Well, clone everything except the snapshots created on the what you're under apparent virtual machine. Everything will include the sections as well. So for now, we'll just to current virtual machine conflict alone that should start the whole operation . Pause the video now because it is going to take about 5% minutes for it to finish, so that's out full blown down. And as you can see, even though our parents virtual machine had snapshots because we chose the current state, our clone does not have any snapshots now to create a lynx thrown a similar and procedure. So, for example, that's my linked base. That's my parent or two machine from my, which I created Lincoln, and this is my Lincoln. But I could just remove this link loan, and I can use this. We conclude what I can choose any other virtual machine like this one. Click on Clone Name it initialize the Mac address. Call it a Lincoln and I can click on a link and you can see that creating linked alone is actually very fast. Great. The link thrown straight of it because our new link loan is sharing the disk. With this, we can create another link through, and that would also be first. Okay, we just have to change the name Surgical Good. Three. Initialize make address and click on next linked clone and see that link clone is really fast. Because not these two working machines are sharing the heart best with the parent virtual machine. So that's fit for this re lecture. Thanks a lot. Bye. 12. Establish connectivity between your virtual machines: Hey guys, I hope you have created three virtual machines and named them, If not, go back and cleared those virtual machines. Now, in this video, I will show you how to establish connectivity between your Williams. We will use to network adaptors one bridge and one host only established collectivity. We will use the bridge adapter to communicate with the internet and the host only adaptor will be used for inter virtual machine communication. Now let's go back to the virtual box manager now in the virtual box Manager first, I want you to goto Global Tools and host network manager here, I want you to double check the configuration settings for your host only. Notebook under virtual box host only tonight. Adapter. I want you to go configure it manually and then under I p v four address, I want you to type in 1 90 to 1 68 56 to 1. This is because if you go back to the slide, we're going to use 1 90 to 1 68 56 start X notebook. So we need the host only adapter Toby in this I p range. Now, the network mask is 2 55 to 55 to $55.0. The next thing I wanted to do is go toe recipe, sever and make sure that this is disabled. Once you've done those two things we can hit, apply to apply those changes. After that, you can take on machine, does to go back to the virtual machines and directly called any of the virgin machines and click on settings under general and basic. You can rename the Watcher machine, do what I've got on the screen so Master brought in there and then under a caused. If you want to enable bi directional dragon drop and she had cleared, you can choose those settings. This is so you can copy and paste from your host machine into the guest machine, and you can dragon drop files into your guest machine as well. Once you start to those two settings, you can go into notebooks and you can make sure that there are two adapters attached to this virtual machine, so the enabled network adapter box should be take for both of these. The first dapper should be abridged adapter and the second adapter should be a host on the adapter. Once you've verified those two settings we can hit, okay? And then we can start on that fortune machine. Now, after the virtual machine is up, you can go in tow the terminal for that virtual machine. And the first thing we need to do is we need to set the host name off that virtual machine . Now what happens is when you clone working machines, the new clone takes all the settings from the original machine, which means the host name will be similar to the original machines host name. Therefore, we need to set it. And to set the host name, we need to type in pseudo Nano or any other text editor do you want to use? And then we're going to edit this file slash abc slash post names host named Fighting and it enter and then type in the password for pseudo. And here you can change the host name to whatever you want. So, for example, this is the process, so I'm going to call it broad dot test left dot com. Let's double check from this life. So the process server is actually proud or test lab. Go. Now we can save the file. Let's just stop projector digestion. Taken those changes? Yep. Now, the next thing I want you to do is we need to set the static I p address for this machine. So and m d u I This command will open a network connection editor So an empty you Why? And hit Enter. And once the noodle a box opened up, I need you to click on editor collection and hit Enter. And then we're going toe added the wired connection to so select that and hit. Enter now under wired connection toe, I want you to go in tow PV for configuration and select the automatic next to it and hit Enter. This will open up a drop down box and from the drop down box, we're going to choose manual and we're going to go right and click on show. From here you can type in the address for these machines And because this is the proud box the I P address for prod boxes. 1 90 to 1 68 56 or 10 sailors go ahead on. I've got him 90. So when Syria hit enter so we can type in 1 91 60 years. Start with a basic start. 10 and the gateway would be 1 92.1 68 docked 56.1. And we can go all the way down and hit OK and back. No arrogantly collected data connection goto wired connection to any enter ones. They should deactivate network adapter. And then if we go there again, you can see that it says Activate. Now we can hit. Enter one more time to activate this and this should have taken the new I P address. Now we can hit Quit now, If you do an i p a DDR show, they should actually tell us the new I, Peters says. You can see it has taken the I P address for 91 68 56 to 10. Now for this machine to take the new host name, we can reboot the machine. So let's type in my book the book and let's head back to the second machine. We're going to go to Prague at me, minimize this. Let's look into the part machine on the Prod machine. We need to repeat those same steps, So let's open up the dominant on the terminal window force. We need to set the host name, so so slash Dizzy slash Muslim in the past would I changed the name to muster Dark best left dot com two lives saying Save it and then we need to type in. What I will do is really said the I be addressed here through G y. So you know, Harper said, the I P address, would you guys Well, so you click here next to the battery icon and then three concept ings, and they should open up the settings box once the setting box opens up, you can go all the way down and click on that book and this in Open up the network getting to on the Network editor You can click on the settings next to the second vibrant after and there we need to choose. I pity for and select my little here and then we can type in the details. So, under addresses, we need to type in the address for the master box. So well, 92 in 16 56 start. Let me cross checked with this life place it start 100. So going back 56 start 100 and then the network mask is 2 55 to 55 55 0 and then the gateway is willing to do your point. 60 years, 56 start one Now we can hit, apply on Then we can tell it on and again we can goto our terminal window and type in I p led our show for it to show the new I P address says you can check it has taken the i p address Solar City moved this machine as well on Let's head back to the debt machine. Now we're going to repeat those steps on the death system as well. So sued off nano slash btc slash his name and then the password. And then we need to go changed the first name. So this is death's death's door. I just love garcon control legs. Yes. Now the next thing is an empty you are added a collection wired connection do and then automatic to manual mentally unsure. And then you need my pin the i P address. So for $92.1 68 not $56.1 on the gateway would be relented to go 1 60 years the basics. My bad. No. One in 60 years, not $56.1. And we can go all the way down, okay? And then go back, activate a connection call. It wants to deactivate it, and then click on it a second time to activate it and then go back and quit. And then a book. It's normal for this machine to boot up and we contest connectivity. So after all the machines have booted up, I want you to go into the masses ever and open, dominant and once in the terminal, one second close. Now what we can do here is we can ping the other, but your machines just connectivity. So from the slide from here, we can Ping 56 top talent 56 start 20. So let's go back to the Masters over the 92.1 68 not 56. Start 10. And we should expect a reply. Yes, and then we can thing for $92 1 60 years 0.56. Start 20. Then we should have a reply from here as well. Looks like this. Some problems with the current visitors have a look back to Deb server step in the possible and he alerts typing. I p led our show. It looks like the I P addresses wrong. So an empty you are added a connection wired collection too. Yet the I P address on this machine is wrong. So change it to 56 start 20 Everything else stays the same. And okay, go back, do it. Deactivate this on reactivated the collection and then quit Double check the I P address one more time The correct I P address this time. So let's go back to the master several. And let's try to think this again. Yep, the court response. So this is how you can troubleshoot as well not from Dev Server lets tramping the master when 60 year daughter of Basic Start 20 which is itself in the master is 100. So he called the response from the Masters ever. That's tramping the broad servers. Well, gorgeous 10 So 56 start 10 court response from 56 start tennis. Well, now let's go to the private server and trying thing both master and from here so being 1 92.1 60 years Dr to six start 100 which is the master and 20 which is the depth settler. So as you can see, the kidnapping eat seven from the address over. But this way we have established connectivity with bean all our virtual machines through the host only notebook. This will come to the end of this lecture. Thank you for watching. I will see you in the next one by 13. Setup Local name resolutionn: Hey, guys, In this lecture, we will set up local name resolution in our love name. Resolution is a way of mapping and I p address to a friendly name. You do this on your mobile. When you start a contact, you can recall that contact by their name. You do not have to remember. It's full number. Imagine how hard would it be if you had to remember all the phone numbers for all your friends? Similarly, it is very hard to remember all the I P addresses in a network environment. Therefore, we used name resolution to map friendly names toe I P addresses. Now, local name resolution is a technique where you configure the host file on your system to map names to I p addresses. So let's head back to the sensible masses over to do this now in the mass is over, we can open up determinant. And once inside the terminal, what I wanted to do is type in pseudo nano slash btc slash hosts. Now, if you do not have nano in story, you can type in pseudo deputy install nano and this will install and on your system you can use any other text editor like V I or them etcetera. It's really up to you, so pseudo nano slash btc slash hosts and hit Enter and type in the password for uses User. Now in the host file under I P for setting first list changed the local host do master dot test left dot com, and then we need to type in each of the I P addresses for the remote machines Disick, Stockton and then type in the names. So 56 start then is the prob seven. So your stepdad in broad dirt I just loved or con and then type in the next I peters for dead on. That should be. You can now hit control X and save Save the fight. Another strain being the other servers through their friendly names rather than their I p addresses. So our I don't just blabber come and we've got a response. Let's try dev dot com as well, and as you can see this way, we can set up local name resolution on our version machines. With this, we've come to the end of this lecture. Think of watching I will see you in the next one by 14. Installing software in our lab: Welcome back, guys. In this lecture, let's installed required software unanswerable masters over on the remote machines. As you can see on the slide, we need to do the following on The answer. Will mass is over. We need to update the system and install answerable on the remote machines we need to install open ssh server to enable us A. Such we also need to allow for 22 which is the port used for such communication. And finally, we need to install bite on on the remote machine. Now what I have done is I have created two scripts to do these activities for us, and I have added a link to my get lab page with this lecture. So once you click on the link, it should take you to my get like page and on the get Lepage, you will see that dinner, two scripts and civil mastered or message and remote machine message. The uncivil master daughter said script should be run on. The answer will masters over and the remote machine does. A set script should be done on their more questions. Let's have a look at both of these groups, so on interval mastered or a set script. All I do is I add a repository on the system for answerable, and then I update the system. And then I install danceable. And lastly, I checked for the answer version that was in start. We're going back to the second script. The first thing I do is I installed openess. I said Silver and months. The openness is it's our what in store. I allow as such communication through the firewall on the system. And lastly, we install Piketon. So again, answer. Master Datasets script will need to be downloaded and run on the Answerable Master Summer and the remote machine dot I said script for lead to be down, ordered and run under more machines underscored to the masses of her first. What I have done is I've downloaded the script in my Downloads folder, and if you don't know how to download the script or leave, gotta do it. Once you got the script open, you need to click on this cloud button to download the file a little start. Don't look so going back to the Masters ever by doing a lesson number down rooms again. See, of course, descript already and I have execute permissions on this group. But if you do not have execute permissions on your script, you can. I have been seeing each morning you bless X and then the script name. And this will give execute permissions for you, for your user on this particular script and now to run the script, all we need to do is type in pseudo dot slash and then the slip, name and hit Enter now we need to hit Enter one more time and as you can see, it has started downloading files later toe answerable on the system. So let's go back to the remote machine. Let's open up our Dev environment first. Now on the Dev environment If you go to our downloads folder Relentless again just to double check, we've got execute permissions begin depends ch more do plus X and then this group name and then we need to type in pseudo dot slash script named to run the script and they should start the install on this machine as well. Now we just need to wait for the insult to finish. Now it looks like the script finished installing the required software and as we've added a skeptic toe check answerable version. You can see that danceable version 2.76 was installed on the master server. Now let's head back to the debt machine to check the status and the machine. It looks like it's still setting up item, so we'll have to wait for a few more seconds. Looks like it finished of installing python as well on this. So what we can do is to check the status off openess assets or what we can try typing in system CDL. Start this. Open a such sever and check the status of the this is it service on. Looks like the SSR resist running for fight on in type in Brighton on. We can see that fight on Virgin 2.7 15 was installed on the machine. Now you can duplicate these steps on broad Machine to install this required suffer on the prod machine as well. With this, you have come to the end of this lecture. Thank you for watching. I will see you in the next one by 15. Setup passwordless ssh: Hey, guys, In the last lecture, we've set up answerable on the central server, and we've set up open assisted server on the remote machines Development assistance, communication weaken, type in a message and then use the never for user on the remote machine. And, as you can see, it has requested us for the password of the user. This is all well and good if a human isn't directing with the remote machine. But in our case, we want answerable. A software application to interact with the remote machine now using a password is not visible when the application is in directing with the remote machine. Therefore, we need to set up what is called a password Lissa. Such access in the past. Wordless message. We utilize public private key encryption or asymmetric encryption technology in asymmetric encryption. There are cookies, a private and a public. A private key is kept safe on the server, and a public is shared with the remote machines. Now these keys are generated using ssh Cajun utility, and you can transfer the public e onto the remote motions using Ssh, copy I D. Come on. So your score to the master severed. Let's try this. So let's first look clear now to generate the keys. Weaken, type in a message. Cajun hit. Enter and we can use all the force and this village and great for us Dukies using such a proof of physics encryption. Now these keys are stored under your profile in dark. Ssh! Directly. If you doing less here, you can see there are three fights were interested in these two. I didn't. The score, you say, is your private key and I didn't ask or arrested or pub. Is your public No. The next step is to transfer the public e onto the remote machines. To do that, we need to type in a message. Bash copy, Dash I. D. And the user name on the remote machine where real world the store are keys, so I won't restore them in Labatt's Labatt Act. Best left not good, and it ended. And then it should ask me for the possible of labor says it has added some keys. It is actually just one key. The other four are from my party. Previous attempts. So now we contest this access weaken type in a sausage Labatt ad test. You have got come. And as you can see, didn't ask us for a possible distance exit out of this and we could do the same thing for say yes, type in the password has added those keys. So there's a succession to death now. And as you can see, we've set up password less says it access between answer master on the remote machines. With this, we've come to the end of this lecture. Thank of watching. I will see you in the next one by 16. Ansible Terminology: Hey, guys, let's soak aboard the terminology used in answerable in this lecture control lord, is any machine with danceable installed on it. You can don't commands and playbooks from any control. You can also have multiple control lords in an environment. However, you cannot use a Windows machine as a control. A man is no is simply a machine that you managed danceable. It could be a network device or a server. Managed jobs are sometimes also called US hosts. We do not in Seoul, answerable on vantage nodes and in men. Tree is a list off managed loans, and then mentally file is also sometimes called is a host file. Your inventory can specify information like I P addresses for each manage. No, and inventory can also organize marriage lobes. You can create a nest groups for easier scaling. A module is a unit off court that danceable executes. Each module has a particular use case. It could be administrating users on a specific type of database, or it could be managing villain interfaces on a particular network device. You can invoke a single module for the task or invoke several different modules in a playbook. No, a task is a unit off action Invincible? You can execute a single task once with an ad hoc common A playbook is nothing but an ordered list of tasks. You save a playbooks. You can run those task in that order repeatedly. Playbooks can also include variables as villas, tasks, the's playbooks, our return in Yemen and not easy to read, write, share and understand. With this, we've come to the end of this lecture. Thank you for watching by. 17. Running your first ansible command: Hey guys, let's talk about the configuration files in answerable and let's also run some commands against remote machines using answerable in this lecture. Now unanswerable. The configuration files are located under slash 80 c slash Sensible and if I do, unless here there are two files answerable dot CFT contains all the configurations for your sensible installation and host file is your local invent Refile and contains a list of all your marriage norms will talk about roles in a later section next to a cat on Unstable Door CFT. Let's go all the way up Now. This file contains all the configuration values So, for example, it contains the location off your host file. Your attempt directories what user it will use when it tries to become super the polling interval. It also contains information like the path for your log file, but for euros, fine. You can also learn enough logging in this fight. So this is the part for your log file. Her says logging is off by default, so if you want long to be enabled, you need to turn it on. Also has the values for assistance Thailand etcetera. No, the next. While I want to show you is the host file. So let's Lana on. The host finds a pseudo Lana slash so pseudo hosts not This file contains a list off all you managed hosts. You can group the list off hosts using a group name inside square brackets. So here, Web servers is the name of the group and all these values beneath observers at the list of manage notes that are part of the Web servers groups. Now we've got two groups in our environment, a group and a product group. Now it's also a good idea to have a group called All in case you need to run any commands against all the servers in your inventory. So on the death, we need to type and death dot this lab dot com and then in the broad you can type in code, got best left dot com and then under all driving both the names so their daughters lab and product test left. This way they can store the list of manage hosts in our inventory file. No, let's try and bring all these hosts using answerable through that, we need to run the at our command, so I type in answerable minus m. And then the commander will use this pain. And I would have been all the servers, so type in an intimate minus amping called. It looks like we've got success in bringing their servers. No, next week in tramping. Let's try and run a command on those servers so we can type in answerable minus him. Let's use the shell model. And when I say let's give the command free minus him and this will tell us the free memory and I won't let it against. Let's first round against all the servers. Now, as you can see, what it did was it used the shell model for answerable. And then it logged into eat server Fran three minus, um, and it gave us our reserves here to run it against a particular group. We just need to change from all that group's name. So does it is done the list off servers from that group and because we just had one it give us results from only one server. We can also run it against a single server like this Sir David or test left dot com, and in this way and civil will log in tow. David or Tesler. Broadcom Run three minutes. Um, and give us the results on our stream. So these are the reserves in this way? You can don't are not commands using the console, but this. We've come to the end of this lecture. Thank you for watching. I will see you in the next one by 18. Navigating ansible documentation and writing your first playbook: Hey, guys, In this lecture, I will show you how you can look up answerable documentation online. And also, we will write our first playbook. No answer for documentation is available to us in history. GPS, Doc, start answer for dot com. When you get to that page, you'll get to see all the sections available for you. I suggest you start getting started now. Getting started bait has some good stuff, like how you condone your first commands. So, for example, how you can edit the host file and how you condone combined, such as being come on on the left. Inside you have all the sections and subsections available for you. For example, you have a section for working with more jewels. How you can work with playbooks. What are variables, how you can use adult tools. You can also search for anything. So, for example, if I want to search for Shell more deal, I can type in Shelley Moore do on a bender, and then I can look for Shelmerdine from among the certain reserves. So briskly come shell and the former off the documentation is pretty simple. So you cordon index for the page here Then you have a synopsis of that particular model. Then the parameters you need to pass or you can pass to that model. For example, if you want to create a file using shell model you used creates and then some examples of that particular more do. And lastly, what return values you can get from that model. Now let's head back to the Master Silver to create our first playbook. I'm going to use visual Studio Court as my i d. For this course, you can go toe to suffer. Search for visuals will be accord and then install this suffer. No, I have a folder answerable inside more documents where I'm going to store all my scripts so I can select danceable. I can click on the file. I can name the file Basic Yemen. And once it opens up the file for me because this is the animal file, I can start it with three dashes and then I can hit enter, then the first thing I need to specify for this camel playbook is what hosts I'm going to run this playbook against so can do that by diving in dash and then space and then hosts. Then I need to specify the horse. I'm going to run this against all host. What this all means is the group inside my host file. So if I go to my dominant and if I look at on the host file the three groups that brought all we need to specify one of these so I can eat the specified Dev or Prada roll on wayto I run this playbook against on which is why I specified I could easily have said Dev are proud here, but I won't diss against all. No spaces are very important in Yemen. Such a speed. Mindful of death, the next thing I wanna do is I wonder start the list of the task that I want to intrude in this Yemen. So when I type in tasks and then under tasks, I'm going to give the name of the first task that I want to run in typing name for that. So I don't like this is a basic connectivity test and the dust protest connectivity is being then I can and Miami with three dots. So all I need to boost saved this Fiallo. So first I've entered the name of the most group that ever built under playbook against I Want to Run It against All. And then I've started my list of tasks. Given the name of my first dusk and the task, I'm going to run this being. No, get some documentation about things. We can go into the answer for documentation and weaken type in and from the Surges. Er's begin to camping and there's an abscess is that it is a tribute test for you and will always return punk on successful contact. The only parameter dresses data says data, return for the ping return value and some examples. So this is how we utilized being We're heading back to the lab system. Run this command or rather, this playbook. I need to go back to our terminal, Another terminal need to type in the command sensible playbook and then the location of the playbook. I have served the playbook inside my documents folder, several type of documents and then inside sensible folder. Then the name of the playbook is basic dot Yemen and I can just hit enter, and if I put in this index correctly, it should start turning the playbook. So play hole. This is the group I specified in the host file here. And then it started running the dusk. And this is the name of the task. Begin. Had This is a reserved off their dusk. Now, this is how you can write your playbooks on. You can run them the next thing I want to show you how you can add comments in your playbooks. It's very simple. You can just I've been a hash and anything that follows the hashes. A comment like this comments will not be executed when the playbook is run. But this have come to the end of this lecture. Thank you for watching. I will see you in the next one by 19. Use Git to clone course repository: Hey, guys. Russian control systems are a category of suffer tools that help us offer team manage changes to soar scored over time. If a mistake is made, developers can done back the clock and compare earlier versions off the court to help fix the mistake while minimizing disruption. Toe all team members. By far the most widely used more than version control system in the world today is get I have uploaded all the playbooks and other files used during the scores in a public repository on Get Lab, the U Release Gettler perform slash Labidi slash danceable. And I've also attached this, um, with this lecture. So in this lecture, I will show you how you can download all these files using it. Now the first thing we need to do is we need to go to our terminal and first install git. So to insult git, you need to dive in pseudo deputy in stock and then get and minus Phi to just accept all the props. And they should start in Seoul procedure No, what's get it installed? We can go back to the page. Forget left on, go up and here on the clone button the nuclear corner. You will see there are two options. Clone with sausage and one with history GPS. We're going to use the history Bs matter, so just get click on this copy. You are clipboard icon and let's go back to our company. Now we will be cloning these inside the Documents folder on my Lennix machine so I will go into the doctrines for the first on can click on a lesson they see there's no nothing there now to close. The repository is very easy. You can just type in, get clone and then basically you are that we got from the clone button on the page and then you can just hit Enter and they should start. The clothes was pretty good, so let's do it. Unless here. So you see, there's a director in Invincible here, so I can just go inside the directly on doing unless again, so good to read me file and other scripts. Let's go into simple playbooks, and then you can see all the playbooks here. In this manner, you can download all the course playbooks and scripts using get, I would suggest that you go online and read more about it, because when you're working in danceable, there's a very high chance that you'll also be working with. Get with. This will come to the end of this lecture thinking, watching I will see you in the next one by. 20. Inventory management explained: Hey, guys, let's have a look at how you can manager inventory unanswerable in a bit more detail in this section, if you remember from previous sections of discourse and inventory, is a list of hosts that you manage using answerable. The Default elementary file is located and slash D C slash sensible slur sent back to the answer Master system alerts type in pseudo No, no slash udc slash fanciful slash hosts Open up the host fight Not this file has some nice explanation on how you can configure your gentrified. You can also go to the link I have provided with this lecture and this link will take you to the official answer for documentation. Now, if you remember, we added our host in three groups Dave brought alone. So if he had more than one silver in each group and those servers had a pattern in their host names. So that said, the seven names like this Devlin have to There are three, therefore etcetera. So the pattern here is 1234 We could use this pattern and add a range instead of adding each server as a separate entity so we could typing depth and then square brackets and then went before to specify all the four servers in the group. No, this pattern also takes alphabets, and you could also use Colon to specify the pattern. These are all valid entries. No, let's say, if you have a particular host where you want to run the answer scripts as a norm. Default you user. So let's say, by default, you're running answerable as user A on each remote machine. But for a particular host that say all the parts ever you want to run danceable as they're saying John Doe not to do that, you can just go to the host where you want to specify user diaper space and then, after the space type in, answerable on the school user is equal to, and then they use the name. So let's say John Doe is using him. No. Next, your company might be running a sausage over a non default poor, which means any port other than poor 22. In that scenario, to specify a norm default port for answerable will go to the post very want to specify the norm before I've been a cooler, and then type in the Newport. And this way you can specify normally for port for such communication. No next, let's say you have a scenario where on, let's say, on the death box you have answered Master running on the death server. And also there's another application installed on the death server, which you want to manage to answer now. In this scenario, answerable will need to connect to the local host on the server in order to render automation scripts so you can utilize answerable collection parameter in order to achieve there. So we can type in answerable connection after the host name and then is equal to and then local to specify that answerable will need to be done locally on this machine. No, the other value. You can give the connection vocalist a sausage. Now next. You can also assign some host variables, each forced in the invent verified. Now, an example of why you would want to use host variables will be to set up things like application port numbers for a particular. Now let's see you have a body planning on Port 80 on one host and running one Port 80 80 on the other host. So let's say on the day environment you have court apart in anyone Port 80 and in the process server. A party's anyone a deity. We can specify variable. So let's call the valuable Sgtp in the score port, and we can give it a value 80 for death, and you can specify the same variable for the product or test lord dot com server as well. And for this ever, let's specify the value 80 80. So this way you can assign host variables to each host in the 25 Now you might have a scenario where you want to assign variables to a group in sort of a specific host. In order to be there, you can go to a new line, type in squared records and then in sites where records first, you need to specify the group name and then colon and then verse. And this little answerable that these are the variable start need to be assigned to a particular group, and in our case, this group is, and you can assign the variable after this. So let's say you want to assign a proxy server for the Dev environment So proxy on that score seven isn't gonna do of death? Proxy just left dot com. We can do the same thing for depart. Environment is very So where's now? This way you're gonna sign group tables Next. Let's talk about super groups. Super groups contain multiple groups. So let's say you have Dev environment, a test environment, a product and a staging environment. So, Deb, best staging and prod and the sovereign test environment is just wonder just left at home. In this staging environment, the seven name is staging Dark Test Lab. No, let's see. You want to create two super groups one super look but Devon Test and one supergroup but staging important, so clear to create those super groups which have multiple groups in them, you can type in square brackets and then the supergroup name. So let's call them Lord Environment and Colon. And then we need to specify the subjects Children. And then we need to specify the Children of the lower Environment Super Bowl and the Children are dead and best. Now, let's specify the second supergroup. Let's call this apart environment. Andi need to specify Children suffix and apart environments are staging in Prague. No, the main benefit off using super groups is we can assign variables to the super groups. So let's see. Book Devon Test, which are the lower environments have, uh, common FTP server, and the apparent environments have a common FTP server. So because we have super groups, we can assign the FTP server to the super group and discipline Don't assigned them to each group and then each host in those groups. So let's do that. So to ascend variables to a supergroup, we can first specify the super poop name inside square brackets, so lower envy and then begin. Specify cooler and then verse. And here begin specify the variable. So have peopIe in discourse ever, and then is equal to Let's give it the FTP seven Men i P address and then for the upper environment. The inspector variables as well, so have to be underscored. So in this way you can create super groups and assign variables to those super groups. No, by default there to groups that are always there in an elementary. Five. These are the group or and another group called Uncle No, you don't need to assign any host to these groups because the assignments are implicit and all contains every host in your invented fire. And one group contains all hosts that don't have any other group assigned aside from all. So you might have a situation where you will all go. And here was ever my seller Dark just left or come, and this over is not assigned to any of the group apart from home. So this server implicitly would be assigned toe uncle. Every host will always belong to at least two groups. Therefore, because of this, my cell door test left dot com will be assigned to all and good. No, next. You do not need to store your inventory in the default location, which is slash d c slash sensible selects him out off our host file and let me show you how you can run your playbooks with the inventory file from a normally for location. But before that, let me show you how you will run your playbook when you have ah, default in 25. In that case, you will just type in danceable playbook and then you just type in the location of the inventory file, so percent documents and then answerable and then simple playbooks and I think I put a label called Base of Dirty Animal in here. Fight on deck. This will use the default inventory file to start the playbook. And, as you can see, started this playbook Basic door preamble with the default in 25 salutes. Condone. See, there's clear this now. Let's then copy. I didn't mentally file into a different folder, so copy slash udc slash sensible slash post Let's copy too slash downloads. Now, that's going to downloads. So you got the host file here, which is a 94 location. Now, in order to run our force file from a non before location, we need to type in answers playbook, then minus I to specify the location off inventory file, and then we can type in down lords, slash post, and then we can specify the location of our playbook. Cindy biggest tomorrow. Let's just type in this I specialists, And this will start the playbook from invented file in a normally for location. So this way you can use a 94 location for your invented fire. With this, we've come to the end of this long lecture. Thank you for watching. I will see you in the next one by 21. Working with host variables: Hey guys, in this lecture, let's understand how you can specify the host variables in separate files. This is the recommended method to store those variables unanswerable. You need to create a directory structure like this so you'll have a top level directory. And then inside that top level directory, you'll have your hosts tortilla my file. And then you also have our subdirectory called hosting the Score Bears and inside the host on discovers Subdirectory, you'll have a single file for each of the host that you want to store valuables. For now, let's head back to the lab system. Here. Inside my documents folder, there's a directory called Sensible. If I do in the less here. What I've done is I've created two subdirectories, a subdirectory called commentary on a subdirectory called Simple Play Boots. Invent three will contain all my invented related files and subdirectories. So the hosts document file. The host underscores Where's subdirectory and simple playbook will contain my playbooks. Now, if I open, my teachers should be called. If I opened the inventory folder, you can see that inside. Inventively, I have host document file and this file has a list off all my hosts and inside the subdirectory hosting to score bears. I've got the two files for two coasts that I have in my environment and David or test left or condor TML. I have two variables and in product test lab conduct Yemen according to variables. Now in simple playbooks, I have a playbook command module, which will utilise command module to create a file inside one of the remote machines, and it utilises variables. So let's go through this playbook. First we assign host and we're telling it that will be assigning Dev environment for this playbook. So this playbook will be done against the Devon. Then we specify dust. Then we named the task and then undock. Tomorrow we give it the command, the commodities touch to create a flight. And then you specified the variable destined to score five. Now, if he called her death or test left or conduct Yemen, you see that there's a variable called test in the school file and the value for that very belief. Read me underscored dot Txt. So this is the name of the file that will be created on the remote machine going back to the command Morgan next we provide some arguments, we say before you create this file or your in this tomorrow. Change directly to test underscored that and destined to score about a video. But hey, specified in hosting the score bars slash dubbed or test left or come argument and the value for test underscored better. Is this the Documents folder on the remote machine? And then the creates give. It specifies that if the file already exists, the Northern Discover. So let's run this. So let's go toe and terminal and type in answerable playbooks and then specify the inventory file. And they invented finally, is under documents slash answerable in my country. And then the name is host of Yemen. And then we can specify the playbook, file downloads and civil simple playbooks de project Name off the directory So simple and escort label hopes I started off in the wrong spot. So document simple score playbooks And the name of the file is Come on, more deal. Yemen. Come on, more dealer tm and we can run this tomorrow. Looks like the Syntex was correct and it just started a new playbook and looks like it has finished running our playbook you can see that the playbook was run okay and changed one file. So let's head to the death system and inductive system. If we have a look at I remember. So they should be read me in this court that file in documents for centers, quarter documents and then within a list. And as you can see, there's a file called Read Me and discord are dirty 60. But this will come to the end of this lecture. Thank you for watching. I will see you in the next one by 22. Working with group variables: Hey, guys, let's talk about group variables in this lecture. Growth variables are used when you want to set variables at group level. You will need to create a directory called Group Underscore Bears at the same level as your host file. Basically, you have a structure like the one I have on my screen. We'll have a top level directory, and then your hosts door pmm file inside that top level directory and then a subdirectory called Group Underscore wears at the same level as hosts Underscore Yemen and then three files inside Group Underscore wears to specify the three groups that we have in the host file. Now let's head back to the master system. So here inside my documents folder, I have a directory called Danceable Inside Danceable. I have a direct subdirectory called inventory and simple playbooks in the inventor sub. Directly, I have all my mental related files and directories, so there's a host dot Yemen file, and at the same level, I have another subdirectory called Group of the Score bears. If I go inside group of the score bears, we're doing a list. I have 35 older GMO deaf, dirty animal and product. No, inside definite Yemen. I have a variable test and disorder. Rachel first through the downloads folder on the remote machine in floor I have a variable called test order test underscored that Peter refers to the documents border sort of depth there first to don't notes and broad refers to documents and all your family has a variable court test underscore file, which contains the name of the file. Now again, I'll be running the same playbook tomorrow. Dirty Air Command, more deals or Yemen. And what it does is it creates a file, which has the name that comes from variable testing the score file, and it changes directly first, So it goes into test and discord are so what should happen is on the death system. It should actually go toe down Nords folder and then create a file treat me dot txt And then it should go to the doctors folded on the court system. And there it should create a file called Read meter Tasty. So escorted the dominant and don't the same. Come on. But I forgot one thing 1st 1st just for the sake off not having any conference. Let's first corporate de host file and then comment out the variable values because I don't want any conflicts that are running the Kamar. And we've got similar variable names because we haven't changed anything in the in the playbook. So this way there are no variables assigned in the host file. Underscored host. I was trying to score bears on the host file that I know very well society. So 100% the playbook should take the group of the score vs Variables, and we'll be learning the playbook against the variables in that group. So let's go. The answer. Unplayable command that we use so control are, and we can search for the same commercial and the file still the same file on the playbook . Still the same. So we can just simply done this. It looks like the Syntex was correct, and you can see that the playbook was run successfully. So let's head back to the deaf system. Verify that the file read Meter Tasty was created. Now First, let's go to the master system on on visual studio and check What was the directory on there ? Sit down towards So let's go toe the dollars for the first well, unless and as you can see, that read me dirty, extreme frustrated on the downloads folder inside the death system, which means going back to the master system our playbook utilized best underscored the variable from definite Yemen File Inside, Group on the score bears separately, and it used test underscore filed variable from old or TME inside group on the score verse . So this way you can utilize group Grable's inside your playbooks. With this, we've come to the end of this lecture. Thank you for watching by. 23. Things to know when working with variables: Hey, guys. In the last few lectures, we spoke about hosting group variables by default. Variables are merger flattened to the specific coast before a place room. This keeps answer bill focused on the host and dust so groups don't really survive outside off inventory and host matching answerable overwrites variables, including the ones defied for a group or a host. Dissecting is controlled by hash underscored behavior Inside Your Answer Builder Conflict Study for Value for hashing the score behavior setting is replace, which means whenever it forms an overlap. It replaces the values based on an order of presidents you can also set this march. Now the order of presidents that answerable uses is first is all group. So if all group has a variable that has an overlap with a variable parent group, the variable from all group or vent and its value will replace the value of variable from parenthood. Similarly, variable from parent look will win over variable from childhood, and a variable from child will win over available from host group No. Another scenario is, can you have two groups that are at a similar level, so going back to our master system and in the host file, you can see I have two groups that wanted upto at the same level that's going to Denver under Yemen, which is the group variable file, there's a variable cord destined disorder, which is a value off slash BTC and on their dirty animal. Oh, so there's a variable called test on disk order with the value of a dollar lose No. In this scenario, if there gets loaded last, then the variable of death to that matches devil. In our case, destined to score better, we'll overwrite the variable of so test in this order for them to will override the value of pent test on disk order for devil, which means then we use test underscored during our playbooks. It'll utilized don't loads as the value. Now you can control this behavior Starting version 2.4 by using answerable under school group Underscore priority, but this you can define a priority. Vit each variable or a group. The default priority is one. So if you don't set any priorities or devil, but you said the priority to toe end, you will make sure that the the rebels off depth to will always win in case of an overnight No, this is how Answerable Hander's overlap off variables. This is pretty important information. So always keep this in mind when you're setting up your variables. But this we've come to the end of this lecture. Thank you for watching. And I will see you in the next one by 24. Inventory Parameters: Hey, cars in this lecture, I want to show you various parameters that can be used to control how sensible interacts with marriage norms. I have attached a link to the answer for documentation, which has a completely stuff and Bentley parameters. First answer. Belinda School Collection specifies connection type to the host. This can be the name off any off answer bells collection plug ins. It says that particular types are smart as a search for chemical. The default this part and Bamako is the fight on implementation off Ssh protocol. There are some tell you parameters as well. Answerable in the school host allows you to specify the name of the host to collect answerable in the score. Port allows you to specify alarm before as a such poor anti but into school user allows you to specify, they use the name off the user that he won't run the and civil scripts as if you do not want to use the default using it. Some of the ssh parameters are answerable Underscore s underscore pass, which allows you to specify the ssh password answerable essa. Such private key file allows you to provide a private key file Now there are some privilege escalation methods as well. Privilege escalation is a method used to get extra privileges on the remote system and civil in discourse. Become is equivalent off pseudo or S U, and allows for force. Privilege. Escalation answerable. Become method allows you to specify the become method that will be used. Answerable. Become user. Will allow you to set the user. You want to become a privilege escalation Answer Will become bus allows you to specify the privilege escalation password Now, as stated in the previous sections, Answerable executes Playbook's over. Ssh, but it is not limited to disconnection type, so you can specify connection types like local, and this collector can be used to deploy the playbook on the answerable control machine itself. You can also specify Doctor and Dr Director can deploy playbooks directly into docker containers using local doctor climbs. You can specify it containers. The parameters, like sensible in the score host user become and some extra arguments by typing in answerable through the score Doctor and the score extra arcs that this would come to the end of this lecture. I will recommend you to go through the link provided with this lecture and go through the list off elementary parameters. Thank you for watching. I will see you in the next one by 25. Working with playbooks: Hey, guys. Playbooks. Our answer. Bills, configuration, deployment and orchestration language. At a basic level, playbooks can be used to manage configurations off and deployments to remote machines. Play books are written in Yemen and consists off one or more place. The goal of foreplay is to map a group off hosts to some very defined rules, which are represented by tasks. Now these tasks are nothing but a call to unanswerable. More do answerable uses more jewels to accomplish most of his tasks. A model can do things like installing so affairs, copying files, etcetera, etcetera. Now look set back to our lab system. Now, in this lecture, we will write our playbook and we will utilize a model called Shell Here on the screen. I have the help page for Shell more now, As you can see, the shell more do takes a command, followed by a list of space limited arguments, and it executes those commands on the shell on remote machines for Windows targets. You will need to utilize win and the score shell model, so this shall model works on Lenox machines. Now here some parameters that we can utilize when we're using the shell more do C h d a r gingers into the directory before running Kamar. So, for example, if you want to create a file in a particular directory, you utilize C h d i r. To go into that directory first before you're in the command, Could he x the only then the command if the fire does not exist If the file already exists on the remote system, they stepped. Lord Byron executable allows you to change the shell used to execute the command. So, for example, your running your script in been bash. But for some reason you want to run a particular task In another shell, you will utilize execute herbal removes will not run the step if the file does not exist, sits opposite to creates Now STD I, in our standard in will set the standard input off the command directly to the specified value and warning will allow you to choose whether to enable task level or news or not. If we go for them down on the help page, you will see some notes related to the model and then you will see some examples. For example, this is how you will utilize shell more. This is how you utilize shell more deal with some arguments. This is the use off CHD ir and creates. This is how you can run Expecto wait for a successful, flexible and this is how you can disable warnings. So let's sit under. Let's create our force playbook using Shelmerdine. No, I would like to go into my Answer Bill folder and then create a file. I want to call this file Shell more do Example. Why am And those are type in. Why am in? It doesn't matter. Once I created the file, I will start with three dashes and then after the three dishes, I will hit, enter and then the first thing I need to specify is the hosts that this playbook will against So Post and then specify the host group. I want to run this again. No, at the same level is hosts. I need to specify tasks to tell the playbook that I'm going to write some tasks under task at the next level. So space and then dash and then a space well type in name on the name of Olympic Avis. I could hear toe simple file using shame or do now at the same level as name I want to call Shelmerdine. And then I need to specify the command that shell model will run. So there's to touch my test fired up. Txt. No, What we want to do is we want to create this file under a specific directory, sellers to bottoms to specify some parameters now at the next level from arcs, which means after typing in space, I would type in ch dia slash home slash use it so elaborate and then down Lords under the user and could years and every little creates on Why does find 60. So, basically, what our playbook will do is it will create a file called My text my test filed or txt indirectly home Lebert downloads. And it will run the check before it tries to run the command that if the file my test find out the extra exists on the remote machine or not, if the file already exists, it will not create the file again. We can finish it up by typing in T dorks. Now let's save the playbook. Let's try and run it so pencil playbook and then I need to specify the part of my people documents danceable and then the name of the global. So shell more your example dot Yemen. I can hit, enter murder, started toe run the playbook, Which means our playbook does not have any syntax errors. One thing you might want to know when you're writing your playbooks is thes spaces. You have to be very accurate with these spaces. If we move a space here or there and the line is not at the correct level it where it should be, you will have another. No, we've got some outward sellers create the dominant size. So we tend to come on to run our particular playbook. No played deaf is telling us which set off coast the place running against. I'll tell you about gathering facts later in this lecture rather in this course, and then says OK, and then it gives us the host name against which it is going to run. So there s like Broadcom, then dusk. And this is the name we give to the task. Create a simple file using shell more do, and then it gives us some bargaining that you should not use touch. We should actually use something is, but it's OK and then changed. David or Tesler dot com means that our playbook was successfully run and as a result the remote machine was changed. And there it gives us a place the cap that the play was run against this particular host There are two okays It changed something there. No, under vegetables, No faves. No. If you go to our remote machine and if we're doing a less here, you can see that we have a file called martyrs for under 60 here. No, because we used creates in a dusk If I was to run this playbook again, My expectation is that this task will not be done because the file already exists. So if I had enough pedal and hit enter, let's see what happens. No. In this one we have play and then death set off hosts. Then the task create a simple file using shell more deal and in the lady cap we have changed is equal to zero. So here we had changed is equal to one, which means it created the file. My test file here when we done it the second time, we have changed is equal to zero. And that is because it did not create the fire this time. Skip the task. But this have come to the end of this lecture. I hope you've enjoyed it. I will see you in the next one by 26. Idempotency: Hey, guys, in this lecture, I want to tell you about a town called Item Potency. ID. Impotency is the property of certain operations that can be applied multiple times without changing the result beyond the initial application. In answer for terms, it means if you run a playbook multiple times, you will always achieve the same state state. He would not have two different states by running the same playbook. This is necessary to ensure you have a consistent state in your environment. There's another term called configuration drift, where servers in an infrastructure become more and more different as the time goes on. Now we need to come back configuration drift, and this is why we used tools like answerable so we can run playbooks for right playbooks. Which vendor multiple times will achieve the same state. Always. No more dues should be Item portent that is, running a modern multiple times in sequence should have the same effect as running it just once. One way to achieve item potency is to have a morbid check whether it's desired. Final state has already been achieved or not, and if that state has been achieved, exit without performing any actions? No. In the last lecture, when we use that creates flag, they were actually making this playbook and the more do I didn't put it because since we used creates flat, even though we're in the same place twice, we actually did not change the state off the system. The second time relented because we'd already achieved the final state in the first run off the table. So whenever you writing playbooks, just make sure that you have the principle of art important see in mine so that your the more systems are always in the desired state and you minimise configuration. But this have come to the end of this short lecture. Thank you for watching Ever see you in the next one by 27. Privilege escalation: Hey, guys. Some tasks require higher privileges for execution, such as installing saw first on the remote machine. The starting services etcetera answerable allows you to become another user, which is different from the user that is loved into the remote machine. Using existing privilege escalation techniques such as pseudo S, you etcetera you can use, become and set this flag as yes to activate privilege escalation if you just use become yes , you can execute playbook on the remote machine As root user. Become a desk or user allows you to execute playbook as a particular user. For example, let's say you got a user set up on the rim or machine, which is the desert privileges that you need to use to execute your playbooks. You can use becoming disco user. Set yourself as that particular user on the remote machine before you execute your placement become underscored method, which can be second player task level overwrites. The default method that you've set in the sensible configuration file, such as pseudo s you etcetera, etcetera, becoming discord. Flag permits, the use of specific flags for the task or room common uses to change the user to nobody when the shell is said no longer no. Let's head back to our lab system. On the lab system, there's trying create a playbook that installs Apache on the remote machine. No, we need to go into Aranzabal folder, click on the new file icon and named the label Install. Underscore Apache. Why am in inside the playbook? There started playbook by using three dashes and then a single dash and space to specify the hosts as you should be going to run against them. Then, at the same level, we will specify become space Yes, to allow us to use privilege escalation and then begin specified tasks. And then a space to go to the next level from tasks and name and under name will simply say this will install party on. I need to add a space between dash and name now at the same level. His name. I need to specify the Morgan I'm going to use since I remote is one. Begin specify a pretty because that is the package manager for and no next level from a P D . We need to specify some parameters. God help page for a bundle here If you go on the way up. It says a pretty manages a pretty packages for Debian and want to. There are some requirements and parameters. We're going to use the parameter name to specify a list of package names that we're going to install. In our case, it will be about you do begin, specify a name like this, as in just the name off the package. Or like this, as in the name and the version of the package you need to install. Begin is also use wild cards like this. No next. We also going to use state and the choices for states absent to make sure that particular package is absent from the remote machine. Very depth will ensure the package. Dependencies are installed as well. Latest will ensure the latest and greatest version off. The package is installed on remote machine. President works with name, so if you specify present and specify, a version in the name parameter answerable will ensure that that particular version is present on the remote machine. If that version is already in start, this task will not be done, but if it's not in store what it is at a lower level or a higher level. It will either bring the version up or down, but the particular version you specified using the name of dedication we'll perform the equivalent of a pretty good update on the remote machine upgrade is used to upgrade the remote machine. And the options are best, which performs a pretty get distribution of grain. Full, which performs a pretty full of great yes, are safe. It performs a safe upgrade. No, let's back to our playbook. And here the first thing we need. Do you always specify a name? So name of the package. What you do underscored occasion, his and state you won't latest. Now, before we run this playbook have saved this before. We don't display book on the remote machine. We need to change some configurations on the remote Machinist. This is a one time only configuration tasks. You can automate this task as well, but it's probably a bit complicated at the state. However, I can promise you that during this course towards the end, we show you how you can automate this task as well so we can go into death and in the depth system, there's first. He wants to go minus I switch in the group and he Ellerson nano slash xy slash doors open This door is five. Now, this file configures the behavior of soup doors on the system. No, he had a few C and they use a privilege specification. You got what do you use it as? All. Or What we need to do here is that we need to specify sudo, which means allow members off group pseudo to exit Veronica Mars under here. What we need to do is, after all, you need to specify no password. Allow us to be able to run, so welcome arms without password. So we need to go here and then Boston PD space. Let's do the same thing for look as well. And then a Rolex. No, but I would do is on a backup this file first. See, it's going to keep me is always a good idea. And now I can go and do doors and under rule and the same thing on vessel goes Well, no. Begin, save this. Now let's head back to the remote system for our interview controller and here type in danceable playbook. And now Anderson, this mobile. So now, if you can see we've got task, which says the name that we've specified and says it changed the remote machine. You can see Okay, sickle to do and change. It is equal to one, which means we were able to successfully installed a party to package from the remote machine. If you go to the death system and if you do CD slash bar slash www slash estimate, we can see that the director exists and there's a default index traded a stimulant. This directory, which means a party was actually installed on this machine. You can also do a cat on it shows the default a party index file. Now that this has come to the end of this lecture. Thank you for watching. I will say you in the next one by 28. Handlers: Hey, guys, welcome back. Handlers provide a basic even system that can be used to respond to changes made by your playbook. Notify actions can be triggered at the end of each block off task in the play and will be triggered only once if it is triggered by multiple tasks. For example, they say you are playbook changes the ssh conflict on a remote machine. Now you will use notify and handling mechanism and have two tasks in your playbook. The first task will change the Ssh conflict and notify the second dusk and the second dusk will. Then we start. This is it service. What would happen is the second task will only be called if the first task succeeds, and if you have multiple tasks, the handler will only be called once. So, for example, you have and Apache server, and you're changing can fix to multiple tasks so changing, Let's say, four different files and you have four different tasks for those. And each task calls a single handler toe restart the Apache service that even though it's being called by four different tasks, the service will only be restarted once. Let's head back to the lab system on the master system. First, I'm gonna show you that we have our asses such file in Pepsi slash message. Now here, let's change the ssh conflict file. And in this file, in the top, I will say this has bean addicted using. Hence a bit. Let's save this, Fiallo. No, we've got a custom message file. No, if you do it, could it? So we can say this is a custom ssh file with our changes. Now what we're going to use is we're going to use the template Modern. I copied this template as a such file onto the remote machine. And then we will restart the assess its service using notify mechanism, no, under and civil. Let's create a new playbook. And let's call it handler. Example. Dirty Emily. No. Here, start the playbook using three dashes and then hosts and you want to run this playbook against the Dave involvement. Next thing we need to do is we need to se become yes, then tusks name. And this is our first task which we will utilize to change the ssh conflict. So we will say deploy custom. It's a city one fate under more now at the same level. His name, we would say temperate, which is the name of the model. No, Let's head to the help section for tempered more. Do no In the help file, you can see that template is used. Toe template a file out to the remote server and employers are processed by Syngenta template in language and here the parameters Active years will be used to specify the attributes of the file or directory. Begin use backup. Yes, to create a backup to file best will be the location to render the template, which is the location there will like to copy or file force. Yes will replace the remote file when the contents are different than the source. You can also specify more, so this would be equipment off ch more. We can have a new land sequence are putting, according Begin. Also specify an owner of the file. Some S E configurations. SRC will be the location off the template on the enseval controller validate is the valuation command that we like to run and if you want to specify some variables now, this is an example of how we can use the template more do so. Template SRC will specify. The source desks will specify the destination on the remote machine owner will be specified . The owner of the fire on the remote machine group will specify the group off the file and more will specify the mood. Our permissions off that file in the remote machine centers do there. No, as you can see that the ssh conflict is in slash etc. Slash s a set on the file neighbors As a such underscore country in the temperate modern under parameters, we will specify SRC to specify the source and now we have to give the part of the source so slash xy slash s message slash esa such underscored conflict. No, we need to specify a destination. And in our case, both source and destination are saying so we'll just copy and paste. Just remember, source is the source of the file on answerable controller and destination is the location where you want place the file on their more machine Now, after this, what we need to do is because we've changed the ssh conflict. We won't go. He started the assisted service so we will specify Notify and under notify given notification to restart a sausage. Now, this notification will be 100 by a handler. So you say handers to specify our handlers and the handlers at the same level as the tusks on the handlers at the next level, we will specify name and then the name of the handling. This has to be similar. What we notified. So we start a sausage? No. Next we need to specify the service more do and name off the service that we need to restart that case. It's a sausage and state. Could be he started. No, we can learn this playbook and save it to run this playbook. I just need to specify playbook name I started. So it looks like there's a syntax error. No others who look no, the reason we have a better he's that notify because notifies part of the template task. It has to be at the same level as Templar and not name sorry at the same level as the task . Not before that. So we had it like this, which means it was at a different level and therefore we had that issue. You will see these sort of problems a lot when you using Enseval that you have to be very careful around space is that you give in your tasks to save the file and left. Started again on looks like it's running this time, which is good. Looks like this is finished and we can see changed physical toe because we have two tasks. One for deploying the new ssh conflict and the other as a handler, which Waas ran here for restarting message. Now let's head back to the deaf system to check if the new file was deployed in the depth system. Let's first clear out of here alerts, toe cap on slash etc. Slash issa such And there's a such conflict. Uh, your school. And as you can see, this is the file that were deployed from our handsome controller. So this is how you can use handlers toe configure event system in your playbooks. With this, we've come to the end of this lecture. Thank you for watching. I will see you in the next one by 29. Facts: Hey guys. Answerable allows you to discover some information about the remote systems when it communicates with the remote system. This information is called facts. An example of this would be the I P address off the remote system or the host name off the remote system for the type off always installed on the remote system. Now let's head back to the answer. Will controller to gather some facts about the remote system we can type in answerable and then the host or the group name for which we want together some facts and then minus him and we can type in sector. And once we had entered, it will give us a list off facts about the remote system. No, you can see that it has given us some information. So let's go all the way up on this. Information we got contains all the very four addresses associated with the remote system. All I P V six addresses associated with the remote system as well. Architecture, bios, information and some of the pieces of information as well. So let's say we want to check the distribution off the remote system, begin to a crap, and this will give us the details about the distribution off limits and start on the remote system. So we have information like the distribution name major version, the release off the distribution, said Trump. No, As you can see, this is a lot of information. One day to use this information is to add conditions in your tasks. For example, if you want to run a particular task on a particular list Lennox distribution and version, you can use facts that you've gathered about the remote system and create a condition in your task. No. In the previous lecture, we set up a rule to install a party on the remote system. Now in the installed at Yemen file, we've created a task and utilized a pretty modern. But if you're not clinics, you would know that a pretty only works on open toe NDB and distributions. It does not work on red hat, so this would be a perfect use case to put a condition so after name, we can type in then to specify the condition. And we can just copy this stuff from here for the van condition. It's a paste, so here we need to type in court records. So when Enseval distribution is a quarto than this task would be done. And then we can just copy this. She copy the whole thing on entered here unless just say, then answer for distribution is Let's send us or did have taking a header is better. So protect Lileks when this could not be the exact distribution that might come up on other clinic system, but it serves as an example, and service under hair system is actually called yesterday. Beauty. So this is a We can have two tasks in our installed HTML file. The first task will be done. Then the answerable distribution is photo and the second task, but only below where the answer for distribution is bad athletics. And in the first US we've used the deputy model, which is the model our package used by going toe and then the 2nd 1 we've used Young, which is the package manager for it, and had distributions. So that's saved this one. No, and let's strand on this. It's directive file path. Perhaps It okay, we got a letter. I think I know why. This is because the variable is actually specified like this on this one. So save and done this again looks better this time. No. As you can see, the first task to install a party server was run successfully because it matched distribution for organ. The second dusk was not mashed, and it was kept to the second dusk. This one was not mast, and it was skipped. Said This way, you can set up conditions to be used in conjunction with gathering facts. No, I want to show you one more thing by default and civil gathers thes facts. But they might be scenarios where you do not want the facts to be gathered. In that case, what we'll do is we'll go to our master playbook, install apart using rules and just minutes hosts. You can type in, get that from the school effects, and you can say no did not together in effects. So this would then disabled gathering facts. So if I try and on this playbook, let's see what happens. No, we got an editor and the elegant message waas that the conditional check and civil distribution is about was failed because we disabled the gathering effects. So, in this way, you can manage if you want together in effects about your distributions or anything else about the system in your playbook. With this, we've come to the end of this lecture. Thank you for watching. Haven't seen you in the next one by 30. Type of Variables in Ansible: Hey guys. Answerable has three different very every types available to you when you gather facts about remote systems or when you want to specify variables in your playbooks. The first type is dictionary and a dictionary contains multiple key value pairs. The second type is a list. It has multiple values for a single key, and then it is sensible, unsafe text, which is a single key value pair. No, if I look at the output off answerable minus m set up answerable all I P before addresses has a single key but multiple values. So this is the type list. Answerable uparmored has multiple key value pairs, so this is the type. Additionally, answerable architecture is a single key value pair, so this is of the type and simple and safe text. If I go for the below answerable, come online or and civil in discourse. CMD line has multiple key value spares. So, for example, this one this one and this one. So it is of the type dexterity. No, we can also get answerable to tell us the different types of variables. So let's say if you have a variable that is defined in the system or gather to the information that we gather from the remote system. We can get answerable to tell us the type off that variable by using the type Underscore D . But come on. No lives. Create a playbook that allows us Buddhist. Click on the answer folder left, click on you Fight, and the new file will be called Find. We're able sample white and and it started with three dashes and then pose dead. And then I want together facts. Popes just copy everything and then tasks, and here, whatever do is ever lose. Deep up debug allows you to output some information on the screen. So under dust, will addict ask to be bug and this will allow us to put some information on screen, and the perimeter for the bug that we will use is MSG. What a message. And this is used to output a message on the screen and here. The first thing we need to do is we need to copy the variable that we need to form the type for. So, for example, let's copy and civil in discourse. IAM do and then actively corpse based of a loop is off, and then we're going to call the variable and then we draft the information or pipe the information of the variable into type on this court. Debug. So what this will do is it will call the variable uncivil discourse cmd and then pipe it into type deeper and time. Debug will tell us that type of the variable. Let's copy the whole thing and hit, Enter and paste it once, then pasted choice. And now let's copy and civil architecture because this is off type, sensible and safe text and paste it here on paste it here is one. Now let's go up and copy. He appeared dresses uncivil all and scored high PV for this is paste it here pastry here is what on then what we do is we can close the playbook by typing in three dogs on click on foil and see. So this playbook we gather facts about the remote machine and then it will use debug and then the message parameter to send a message. And the message is a string danceable. Whatever the variable name is is off type and then we call in the variable using double parenthesis and the variable name and Then the Piper Intertype of the score debug, and this will tell us the type of the variable. So let's go to our terminal, clear everything and left it on this. So since we had already been answered, well, we can just removed of name. And I've been fine and and hit Enter an expert for the reserves. So first Jack was this in text tech? That's a good. And now we run our first task. And Cordy Buck and you can see put in some messages. And as you can see that as I said, answerable seemly line is off, Dick, because it had multiple key value pairs and civil architecture is off my principles. Unsafe text because it had a single cable here. Unanswerable, all likely before addresses is a type of list. So this is how you can get the type off the variable from answerable using type of the score debug comer. But this will come to the end of this lecture. Thank you for watching. I will see you in the next one by 31. register: Hey guys. And several models normally return a data structure that can be registered into a variable . Or it can be seen directly when output by the answer program. There are some common values returned by all programs that I have put on slide, and then each more deal can have its own optional return values as well. So let's have a look at some of the common pretend value types back up on this court file is for those models that have a backup is equal to know yes, functionality, and it returns about. But the back of file that was created changed indicates that the US had made a change. So going back to the internal controller, I never been in a playbook. We see the changed value here that's that done called Similarly Failed, tells a safer task, has failed and reachable, tells us if the remote system was unreachable. Message is a string with the general message relate to the user, and we use this in our playbook, where we found the variable type off. Some facts now going back to this life standard better is used by the more deuce that execute command starkly for example, Scheller. Come on, more do, and this field contains the put off these utilities. Likewise, standard output contains the normal or put for the Kamar Joshi Amadou's No, let's go back to our answer controller and see how we can utilize thes return values in a playbook. So going back to the uncivil folder, let's create a new playbook called register example. I am in scared the older one. It's important $3 and then Post's death become yes, dusts and under dusts to specify name. And what we're going to do in this playbook is we're going to check the Java version and then register the tire aversion value in tow. Variable. And then we're going toe output using the message and debug commercials. So name is Jack for travel version and register. It's value, and they're going to utilize the Camara Madou and the Commander. Going to run on the remote system is Java version, and we're going to register attack inside a variable called Job over and as to a debug and in debug. Let's do a message that says to have a space version. Java were guard STD here, so very but not standard at other done with you. So let's save this. But before we run this, there's first Jack. If job was installed on the remote system or not, the deaf system export one of the terminal. And here they're stipend, Java minus version. Basically the command that we were going to run on it. So it's not even started. So it's still there right away. So let's install the D forgery. So copy this paste. Let's on this. Yes, we want terms for job, so it looks like double was in store tonight. Feed and Java version. Come on and hit. Enter. You can see that record the version of Java installed on the system. So now we can head back to the answer the controller. And now we can run this playbook. So that's his trunk. So far, so good. We're past this index check. Okay. Looks like Did you know? You know what this one is? But probably from my last month. So let me try and save this again, and this No, this one was better. So we've got changed for our task to check the job, overturning the district's value and from the D book task record the version of Java, the standard later on our machine. So this is how you can utilize, register, do registered the values off. Very bus in answer. But this will come to the end of this lecture. Thank you for watching. I will see you in the next one. 32. variable files: Hey, guys, we're spoken about different type of variables. They're parameters and where you can place them now. They might be times when you want to make some information in your playbooks. Private. This could be user accounts, passwords, etcetera. Defining playbook. Rebels in a separate file is very helpful in the scenarios. Next, see how we can do that first at answerable level, Lex created directory core bears. We will store all our variable files inside this directly. And now let's create a new file called Fares Dark. Why I am in and inside this variable file. Let's store are variables. So first variable of the stories Source that and the value for this is slash hole slash leopard slash commutes. Backup underscored. There the value is slash home and back up the score. I'm just going name and the value is back to school. Fight no and anti level. Let's create a file card that he was. That's good example dot I am in and let's put into dogs in this playbook. What we're going to do is we're going to archive our Home Lebert Documents folder in the slash home folder, and we will use variables in order to achieve that. The first thing they do is meter diving hosts specified the name of the environment and then become because we'll be writing stuff into slash room. And then I need to specify the variables file. But I will wait for that dusts and name off the tusk, which is to archive documents for you. And then they used the archive more. You need to specify a part, and the path would be so some just for bed. And then we need to specify a destination on the destination would be a pack up on the school. Oops, I don't know what I don't there back up from the score death and then the filing, which is back up on disqualified school name and then the former. It would be easy. No, they declared some variables, and the values of these variables is inside guards and tortilla my file. So we need to tell our playbook where to get the values for these variables. No new deck, because the values in a file we need to specify. There's underscore files, and now we can specify the part that very well find No, because the where's a directory is at the same level as answerable. I'm going to specify single dot and then slash. That's slash But I started by Yemen. So the single dot means start from the current directory off the playbook and search for wears and sent of playbook and various A recreated the same level, which means they're both inside and simple, then going toe vast directory and find a file name their start. By am, we can save this. Actually going to save all? No, But I've been answerable playbook and then variable example by Yemen and intended so, so far so good. Big pastors Index chick. No, this is finished. Another step back to the deaf system. Projective. The pack of five was treated a lot. Now, here on the death system, we can go into city slash home, And then unless, And as you can see, we've got a file card back up in this court file that was created for us. But this comes at the end of this lecture. Thank you for watching. I will see you in the next one by 33. Dynamic variables: Hey, guys. In the previous lecture, we learn how we can use words. Underscore files directive to call variables in the file. This is good if you want to call variable statically and have them ready before you run the playbook. An example of this would be configuration variables. Now there will be scenarios where you will need to call variables dynamically play you can use, including the score bears to do this. So the use cases for imprudent school bears are that you can create variable files and improved them in play dynamically. You can have multiple variable files, and you can choose which variable file be used based on some conditions. Also, including the score, bears has a higher priority than where's underscore files so it can be used to override the default configuration. Now let's head back to danceable master. No, I have ah, sample playbook here called including the Score Bears Underscore examples. So what I've done is I've created a folder all inside the worst subdirectory in the all folder. I have ah file called Wonder Yemen, and it has a variable called Sample one, and then we have a file called DOT Yemen, which is a variable called sample and Escort to and Third, we caught a file called Trader Jason, which, as a vessel variable, and we also have the old various underscored Yemen file that we used in the previous lecture, which had some variables as well. Now in the including score, bars and discos example. The first thing is we've standard defined our group of horse to run this against, and then we've used, including the score bears to call some variables dynamically. We've specified a file name and we've said, Okay, start from the current working directory, which is answerable. Look for a folder name bears and then inside that folder look for a file name. But I start human. No, What it does next is it stores all the variables that are in various tortilla mole file. Inside the dexterity type variable called Wears one. Next, I've given an example of how you can include all files in a directory in include wears, so we've specified rather than file specified de ir leave said start from the current Working directory, which is sensible. Look for a folder name, verse and then inside where's look for a full name? All include all the files inside, all directory with extension and we have specified extensions. Why am I And why am l? Which means we're not including read or diesel in our playbook. And I've also specified ignore unknown extensions as yes, because I want to ignore any variables and the file leader Jason completely and store all the variables that are there in the files inside all subdirectory in a dictionary type called sample. Now the next thing I've done is I've used a debug and message. Come on, toe, bring the values off these variables. So this is how you called the value off her dictionary type. So first, the name of the dictionary type variable and then the particular value inside that dictionary type that you want to use. Solar. Settle this now the labour grand successfully. So let's have a look at the output. No, In debug, you can see the first message, Prince, all the variables inside verse one. So if you look at the the work messaging, the 1st 1 was verse one. So this prince, all the variables that are stored inside bars one next we call in verse one dot source there therefore we caught the values off source. They're printed here. Next. We called the value for back up there, so we called the values and it is printed here. Then we did the same thing for samples where we printed all the values which got printed here. And then the individual values for sample violent to which here. So this is how you can add variables dynamically into a playbook. But this we've come to the end of this picture. Thank you for watching every see you in the next one by 34. Resuable Playbooks Import: Hey, guys. Playbooks can get very lengthy and complicated, so it's a good idea to create reusable files and organized him unanswerable. There are three ways to do this. Import include and rose in groups and imports. Allow users to break up large playbooks into smaller files, which can then be used across multiple parent playbooks or even multiple times within the same playbook. Rules allow more than that. They allow tasked to be packaged together and can include variables, handlers or even more deals. Another plug ins I like improves and imports Rules can also be uploaded and shared. The answerable Galaxy Galaxy is a free site for farming, downloading and sharing community developed roles, and it is a great way to jump start your automation projects. We talk about galaxy when we talk about rules now. Answerable had two more off operation for reusable content, starting more and dynamic, more in static, more answerable pre processes. All started imports during playbook. Parsing time Indiana. It more improves that processed during runtime at the point in which that task is encountered. So in started, everything is pre processed in downing more whenever it encounters Theo include statement. It improves that particular does at that particular time. No respect. Go back to the answer controller to see how we can create reusable playbooks and then our interval for dinner. It's creating folder called Musical and the School Examples. And inside this folder, let's clear tea for US Backup Dark Yemen deploy changes in Yemen and Mustard or Kim. So what we're trying to do here is our master. Our family will be our master playbook, from which we will import to other playbooks. Backup Gargamel and Deploy Changes Start family and what we will do in deploy changes and backup is first, we will back up some configuration. In our case, we will back up the that www slash html folder, where we deplored in Dexter Estimate File. When we did our lamp stack project and then using the Deploy Changes playbook, we will deploy a new index dot html file into that folder. So this is similar to a scenario where you're upgrading a website toe answerable and you want to take a back up off your where development of blue slash estimate folder before you deploy the files for the new website. So first we need to copy everything from this file and then at answerable folder level. Let's create new file. Let's followed index. Underscore. I know about estimate. Skopje, This one. Yep. Now let's go back toe backed up dark Yemen here. We need to add the task to back up their fight. So we wanted to be a complete playbook because we can then use this playbook and some other master playbook as well, apart from this one we're creating, So we'll make it a complete pay playbook. So we'll have hosts death become Yes, dust name on the name would be back up slash slash www says it's demon and then for backup , we'll actually use hard time or do on the parameters for our time. Are you, uh but which is the part to our camps? Over first estimate the destination where you want to store the new backup Well distorted under slash war. And I want you name it back up that do you see and the former off this backup is Jeezy and I can no stole this playbook. So file save. That's one playbook done. Next we go toe deploy changes and in Detroit changes the take the existing new index as estimate file this one and we deployed onto the remote machine. So here, three dishes and posts dead become Yes, Dust name deploy new index. Start each demon and we will use copy Model. Source is slash home slash Lebert slash documents slash danceable slash index from the score New estimate on our destination, we're goingto type in their everyday new estimator slash index start its team. So take this file copping to the remote server as index start estimate. So now we have two playbooks back up back to Yemen and deploy changes. Dark Yemen back up will back up the current path where the Buddha good of you slash estimate and deployable deploy the new file. No, we need to call these into the master document file. The way we need to do this is next check stash and then post. Yeah, actually, Do you come? Yes. Now, to import the file, you can type in import underscore playbook. Back up your gamma alerts. Just copy this and let's called deploying the score changes Dirty Amell as well on we can now save this. And now the only thing we need to do is we need to run Master of Yemen. Usable examples and then plasterwork. Yemen. Let's run this. Okay. Looks like you got a syntax error in mustard or Yemen. Okay, I know what it is. So that's what this again on savers. And hopefully this will work now. Yep. Looks like it's work. So import playbook has to be at the same level as the level you define the host at. So it's gone toe deploying new index file. So it's already done the backup. And now, as you can see, because chances accord to prove which means it took a backup on it. Deplored the new index file stars have to the deaf system where we have the previous local host all our browser. Seriously, freshness. And as you can see, you've got the new text, which means the final successfully deployed. Well, this is how you can use import statements, toe create reusable playbooks, unanswerable. But this will come to the end of this lecture. I will see you in the next one by 35. Resuable playbooks import tasks: Hey, guys. In the last lecture, we created two playbooks back up, Dirty Animal and deployed RTM. And these were complete playbooks, which means it had a host section. It had a become section. It had some tasks and same with back up as well. And then we imported them into the master playbook. No, what if we only want tasks and not complete playbooks thinking you do that as well. So let's try this in this lecture. Under reusable examples, let creates another file called common underscored tasks. But Yemen and what we will do is it will create our common tasks. For example, backup the directory veritable definitively estimate and deploying you the upside files into that directory after the backup is done. And then we will call this common task start Yemen into our master file. So let's first right the common test RTM. If I Now the first thing you need to do is we need to do a backup. So let's go to our backup, Brock Yemen. Copy the configuration lines from name before me on both common tasks. Three dishes on. We can paste it here, and then there's going toe deploy changes that Yemen. Same thing. So copy everything on basic here as well. And then we can finish this by typing in three dogs. So this is our task. Fiallo. It has two tusks. We will not be able to run this past fall alone. We will have to call this from another playbook. So let's go to Master Key. Emily has comment out the previous lines, and here there's addict dust section. So at this level, dusts and under tusks the next level. What we can then do is begin calling an important task, and we can give it the name of our tests file. That's it. Now we can save our fires. So what we have done in this lecture is we've created a common task. Tortilla. My file. We do tusks. And then we're going to the Master Document file, and I didn't import underscore tasks parameter and give it the name off our past five. And now let's try and run this. But first, let's addict the index nude arrestable file. Let's say using dust and there's do us a one. No, no, it's on the master play tortilla, my playbook. Hopefully, there's no syntax errors, so we have to go back to common tasks. And this is what happens when you copy and paste, right? You're for making stops working properly. So we have to just for matter dust. No, no, Save it. And let's try and run the playbook again. Now it looks like the syntax error board resort on. Be running the playbook now. Now it is backed up our home directly Practice deliberate of New Edge demon. Now it's declined to file, which it did before changed too. So you can now go to the deaf system. And now, if on the fire folks of the local host page, if we just hit refresh, you can see that it deplored the new conduct sort of chamber. So in this way you can import tasks rather than complete playbooks. With this will come to the end of this lecture. Thank you for watching. I will see you in the next one 36. Vault: Hey, guys. Answer Award is a feature of answerable that allows you to keep sensitive data such as passwords or keys in an encrypted file. These bold files can then be distributed, are placed in source control. Answer. Billboard can encrypt any Structure Datafile used by answer on the screen here. A guarded list off all the type of files that can be encrypted using answer. Billboard. No, you're sent back to the answer Well controlled. Here, begin typing Answer. Dashboard minus age to get to the menu for instable work. So the usages and civil board and then we can use clear toe, create a new port and separate file the crypto decrypt. If I did edit an existing and corporate file and grip encrypt an existing non interpret file and Cripps String freak you to change the password and you to view and existing files and then the name of the file and then we've got some options, such as asked for password, specify some board I DS minus B forward bows and Georgian etcetera. So let's land 385 So answer. Billboard. Could you? I want to create a file called Test I am in now it asked me for a new word password for money were fighting. And he had asked me to type in. No, I can access information. Okay, lets go. So we use that underscored name is best political user on use. It underscored bus. He's they're stopping password. And now we can save this file. Okay, so this has created our first and complete file to view this file. Begin typing, Have you passport, divorce, password And now we can view the fire. If you try and get this file, we'll just get some encrypted gibberish. Now, to edit this file, you need to type in hence, a billboard. I did. I start Yemen, and we need to type in a password forward. And here you said you want to change the password. Good. I don't know something like last of you. And now changed the possible on this file. Begin type in freaky. And it will ask for the current world password. And it will then ask for a new world class work. And if everything is called, it will say Reekie successfully. Now we can also encrypt an existing five. For example, I'm in my vest directory. If I was to go into all and let's say I want to encrypt to document so I can use the enter the reward, Cameron thinking type in and and I could say we're going to improve up Yemen. We need to set up a new world. Possible says Encryption was successful. Knife. I plan you don't Yemen. I will just get the encrypted gibberish now. The next thing I want to talk to you about is the best practice that answerable, say's we should use. So let's head back to answer for documents now under the Answer Best Practices Guide. If you go all the way down, you will see there's a section called Variables Anvils. There's click on deck so it stays. The best practice is to have a sub directly and then create two files named wears on board Inside that subdirectory inside the first file, we should define all the variables that we need, including any sensitive ones. Next copy all the sensitive rivers over to the world file and perfect thes files with aboard Underscore prefix. And then we should just adjust the variables and verifies to point to the matching world in the school. Variable Internet informer and ensure that the full file is working. Centers do this. So let's go to our visual studio called Now here we've got a directory. Carvers were record a file called Person to score Yemen. Next, we had some sensitive information in this verse. Underscore Yemen and let's say record this like use an underscore the name, my name. Rather use them school name and then he was in a school bus. So record these two variables. One variable has the using it and the other variable has a user password. Now we will not. And there are some other variables in this file is well, we will not store the values off. These variables inside were sortie. And what we will do is we will go into verse directly, create a file inside there's court work, Doc Yemen now involved or Gamble Copy Do is two favors of it. Give it a suffix board underscore for both and here we will specify it. They use the name rather this so this now devoid file has actually using him and the password now under vaster Campbell, we will now need to reference these two variables so we will go here. Copy this. And likewise, we need to specify so like this on just two. A stable. Now what we can do is we can not go and encrypt our world RTM So let's go to wears sto unless we caught a vessel or dutiable file. It's big and type in answers port and then encrypt to encrypt an existing file and given the name. So Ward got by chairman. And this will encrypt the files for us now, specify a strong password. And as you can see, the encryption was successful. Life somebody was trying to use yes, or Yemen opened up four dot Yemen, they're not be able to do it. So if I do what cap? Well, just get some random numbers. So this way you can encrypt your user names and passport or any of the sensitive information in your playbook and do use these. We just need to actually use user in the school name and usurping the score past in our playbook. And then we run the playbook. We might have to supply the world password, but this we've come to the end of this lecture. Thank you for watching. I will see you in the next one by 37. Roles: Hey, guys, A better way of organizing your playbooks is to use rules. Rules are away off automatically loading certain variable files tasks and handlers based on a loan file structure. Grouping content by rules also allows easy sharing off rolls with the other users. So, for example, if we were to install our lamp stack using rules, we will create wonderful for a party wonderful for my sequel server and one rule for PHP. This allows us to reuse thes rules. So in case where we only want to install a part share a set of servers, we can only call a party. And in the case where we want to install all three, we can call all three laws No, next head over to our answer will controller system. You know, the first thing we need to do is I want you guys to check if you've got three commanding story, it allows you to see the direct. Please enter subject, please, in a tree like structure. If I was to show you my documents, this is the view that tree command will give you in surgery is very easy. You just need to type in pseudo a pretty installed. Three and it enter and medic drums. You need to type in your password now. Since I had three already in store, it didn't up there. Now with Dreams Store, we can now go ahead and start creating the roads. Roles are created using the interval galaxy Kamarck. It's for typing. Answerable galaxy Note. Minus H To open up the help menu for answerable galaxy, you can first see the usage of interval Galaxy, so we need to type in an interval galaxy and then one of these options. So delete import and four initialize in stone. Let's log and remove such set up. Then help, which is, if you need help and then some options and the options are minus C to ignore certificates minus s to set up a P I server destination and minus V for verbose and minus minus. Morrison we will use in it. Initialize Our room cellar's clear this. First we need to make sure within the answer for directory. Now inside answerable directory. We got all our playbooks. Whatever I do is, I was create a new directly called rules, and then side roles will create our first role. So you're typing Antipolo Galaxy in it. And then because we will install a party using these rules, my friend will. Unless inside rolls you can see I gotta directly called Apache. That's worth three under directory. As you can see, it has created a directly structure with some subdirectories and some files within those subdirectories now going back to the slide. First, we have the de force subdirectory, which holds all the default variables for this particular room. Then you have the files subdirectory, which will contain the files which can be deployed. Be at this room, for example, the indexed or estimate file for an Apache server. Handlers will contain handlers, which may be used by this role, or even anywhere outside this role as well. Metta contains some meta information for this role. For example, author name platforms which are supported etcetera. Tasks contained the main list of tasks to be executed by this role. Then we have templates which will contain templates continue to former, which can be deployed to this role. And lastly, we have the worst subdirectory, which contains other variables for this room. The variables defined here takes presidents over the variables that you define in the Defour's folder. So whenever you're setting up a role, just be careful where you're defining our variables. If you got a variable that has the same name, and it's present in de force and verse, the one investment take presidents going back to the answer controller. So in this lecture, I'm going to show you how to create a role for a party server. No, the tasks for installation of Apache server can be broken down into three steps. The first step is to install the Apache server. The second step is to configure the Apache server Now. For this step, we will send a custom a party to the conflict file over to the A party sever. We will also copy an index start estimate file over to the remote machine as well has part of distinct Third, we need to start the party's over no next get started. So first we need to go into the tasks subdirectory because going back to this light that Tasks Directory contains the mainly start tasks to be executed by this role. So in the tests of directory, the release vigils would be a court rather than Tom Miller to do this. So I just minimize my dominant with this much. And then I will hit the fresh here, do the fresh my workspace. Now you can see I've got rules and I've got a party inside. Rose, the insert tusks. I've got a main not Yemen. Now, because we had broken down the insulation steps into three distinct steps, we're going to create three fires. The first file is installed at Yemen. Or rather we will use fireman. It doesn't really matter in linen, but since intros, we've got the extension viable just for keeping everything same. I'm going to name the extension Miami while using rules the next fall I'm going to create is configured out vitamins. And the last file is services dark. Why, Emily? No, on the installer. Wyoming, We will. Right? The task native to install a party, sever solar, start with Ed rush bashes. And then the name of this dusk. His dog party server. No, he it I'm going to called a pretty model and then name off the service or the package you need to install the package will be called a party to In the state of the package would be latest, and that's it for this one. No wonder Configured or Yemen, I'm going to write to tusks. One would be to configure the Web server, which means we will be sending over a custom a party conflict file onto the Web server. And second, we will deploy our index or estimate so. Three dashes minus name. Deploy Custom party, too File, and we will use the copy Modern and we were typing SRC Equus, the name of our customer Apache filed. I have actually attached this file with this lecture and have done ordered this file on my system as well. In my Downloads folder. Looks like a Hector downloaded again. So here's the file in my Downloads folder. I can just copy this file into my answerable folder and then rose, then a party inside the Files foreigner. And we'll also need to copy the index, not as Timon file now. Once this is done, let's head back to our visuals from the record, unless to refresh. Now you can see that are filed. A party to dot com is there, and I put a line at the top saying Filed was customized by me for demonstration purposes. on. This is our indexing your daughter estimate on rather than using dusts, I would just say using roads on Let's say everything. So going back to configure your family. So our source is Apache 2.1. It should be present inside the files subdirectory under our rule. Apache. So they established that the file is there. Now. We need to specify a destination for this violence. Where now this family used to go and slash btc slash I want you to slash Apache two door gun. So sources Apache 2.1 inside my file subdirectory. And the destination is slash at se slash party to on the remote machine. And once this is done, I'm going to notify. They started, Buddy. No. Let's add the next dusk on it. Deploy index, start estimate hand here. I'm also going to use the copy. More do and source this time would be slash where slash www slash his team l slash in days dot No, by that, the source would be our new index. Fine. Which is inside the file subdirectory. So this well right here and the destination would be the distension part on remote machine . So where did you get rid of you? Esteem in slash index. Start each demon. Let's just save it. It's space. Yeah, on. Make sure that name and copy at the same level in the name here. Is that the same level is the name dear. So we don't end up with a syntax error. Okay, Now let's save it again. Now, the next one is the services dot Yemen. In this file, we are going to add a task toe. Start the services so minus name starting Bacci service. Yes, a few empty lines. And here we go to use service and named for their service is But you do State is started on this Said this one. Now in configured our family, we had a notify statement to restart Apache. So inside handlers in the main North Yemen. We have to specify a handler to handle this. So in the handlers may not Yemen. You're going on type in name space. He started. But you and service name is going to do about you. Do state is restarted darts to finish this. No orders to a save on. Now. In the end, we can also go into meta and then main dark Yemen and here begin typing out on days. So I'm going to say I'm the autumn prescription. I would say Instructor on the company name is optional, but I could see now here I could specify things like main instable version, the platforms that are supported, the tax for this roll and some dependencies, the nurse to a saver. So so far they configure it, asked to install a party set apart us to configure the new party server. And we've got two tasks in the Configured Auriemma file. Want to deploy the customer party to call file and the other deployed index start estimate file? Both these files are present inside the file subdirectory. Then we have our task to start the party services on the services or vitamins now in the past section that's going to remain in Yemen because obviously we will need to call these tests as well. And here we will use include statement So space in two in started vitamin include configured I am it include services dark. I am it, and that should be it. So there's do us a lot. Let's try and run this one not done this role What we need to do is we need to just bend there playbook to run this room. I go. What? We haven't actually creative that playbook here. So we've got a rule. They caught some tasks remained viable inside that road. And some handers and some of them us. But we do not have any playbook yet which caused this particular room. So you do that. You need to go out the answer level and create that people that calls the room. Now we ago hold this. Installed a party using those dark I am. And now in this playbook, we will specify first the set of hosts that you goto this clever con. Then we will specify the dusts. So actually, we do not need to specify tasks. I need to specify the rule so and under those we need to specify the burdock stuff. Rose slash Buddy. Now what does this double not mean is go to levels up so fired? Who would show you that restructure from anti? This is important for you to understand. So you gotta answerable here. Answer. Please. Here. And we have playbook installed apart using rules here. So two doors. Are you taking to answer and then in crows. And then we look for a gold party. No, began Just close this like this Andi might also have become Yes, donors save everything. Let's get on this. So inside. Answer Now we can type in answers. Playbook install starts to capitalize. I will use that Bharti using rules start Yemen. Alexis, enter. So far, so good. It has started the execution of this playbook. Which means we do not have any syntax errors. No, Here with this task, it has actually gone toe. Find the room called a party. I found it and installed the party Sever. Then it is going in and deplored the customer party to conflict files from our conflict Yemen. And then it has deplored the new index file. Then it has started the A party service. And then because we called for a restart. If we change the body to the conflict file, it does use the handler to restart their party service as well and no recording. Okay, Sickle to six and change physical to three. So if you have us to go back to the their machine No, If I just hit the fresh now you can see that the new index start estimate was deployed. So this is how you can use Rose. I just do a quick to be kept because this was a big lecture. No, let me clear this. First, let me do what? Three. The first CD and what? Three on danceable. So what we did in this lecture was we first created a role called a party inside a directory called Rooms. Normally in production environments, you will see our directory called Rules and all the rules would be defined into this directory. So we had a rule scored Apache. Then, under the tasks subdirectory of that rule, we had a file called Mender Vitamin that called three files Install, configure and services so mean dark vitamin because install I can't figure in services installed was used to install a party. Configure was used to deploy a party to dot com, an index start estimate file onto the remote machine, and then services was used to start the party services on the remote machine. Then the had a notification using a notify method inside the configured or via mail file restarted party and the inside our handlers We addict tasks toe handle that notify and the task force to restart a party using the service more. Then we also edited the main file inside meta sub directly Axum Major. So this rule, for example, the water name company name etcetera. After we've done all this event one step up and we created a playbook that caused the store inside this playbook which was inside the answerable directory. We give it a set off hosts to run the playbook against. We gave it privileges and then we call the rule and we said rules and called the role a party. The 1st 2 dots and then a slash will tell the system to go toe the level off, answerable and from there, look for a directory named Rose and it inside the directing improves. Go and look for a party. So go to the level of answerable inside danceable look for rules and then inside rolls Look for Apache. With this will come to the end of this long lecture. I hope you've understood, Rose. If not, just ask any questions and I will be happy to answer your questions. I hope you enjoy this lecture. I will see you in the next one by 38. Project: Playbook to replace Sudoers file using Ansible: Hey, guys in the lecture will be installed. Apache. We had to go manually into the remote system and configure the suit was filed. Now, as I mentioned in that lecture, if you could also automate that task, no, to do that, What we need to do is we need to create a playbook. So let's do a new file and let's call it set. Souder, Carter, Yemen. Now he had Let's start the playbook by typing in three dishes. Let's to host Let's also on this against them and under tasks we will use line in file. This is the modern, and then we need to specify some parameters for this model. Let's open up the help file for this model now, As you can see, it manages lines in text fights and synopsis. You can see this model insures a particular line, is in a file or replace an existing line using back reference regular expressions. No, the parameter saw active groups, which is the attribute. The resulting filer directly should have back a differences to specify some back references back up if we want to create a backup off that file a lot, because if you remember from that lecture, we created a backup off our sued or file 30 years, which will again check of the file over already exist. No, what we need to do is we need to use part which will specify the file that needs to be modified. The full part of that file in our case, it will be slash etc. Slash two doors. We will utilized state, but specified that the line should be there. We will also specify rejects to specify the regular expression, so it should be here somewhere here. Digex the regular expression to look for in every line of the fight for state president. The pattern to the place if found now the next is really, really utilize line to specify which line to the place. So here the line to insert replace into the file and lastly, we need to use, validate and validate. Is the commander run before copping in place or the part of the file to validate? We also have some examples. So, for example, in the assembly next conflict file, you can specify the regular expression and then you can specify. Assailant X is equal to enforcing, and this will change I see clinics enforcing. Similarly, you can also go into your default Apache conflict, and you can start listening on Port 80 80 using this particular more do. So there's head back to the visual Severe court. We use a line in five he had at the next level from line and file. I will use path to specify the pot on the passes slash etc. Slash two doors. Next, I need to specify a state and the state would be present next. I need to specify definite expression and the regular expression. I'm going to use his get it percent age pseudo and then line. And the line we need to use is if we go to our death system. Rather, this is some sort of sea file as well. So Lex used dominant on this machine. So again, pseudo minus, I type in the password and then no, no slash C slash doors on. This is the line you need to replace for pseudo a copy on the line. We can specify paste. Now What we need to do is because we need to replace this line. We can go one space like this and the nobility we can say the ice pseudo going to see if percentages No, What's happening? Here it is. We've used the line in five more to modify our so doors file. The state is president that this line should be present. The regular expression is person Tate pseudo. So if we goingto the file at the line, we need to replace starts with person date solo. So that's the regular especially potent. And the new line should be percent. A pseudo alone, no passport, all and under valid. It used V I pseudo command. No, we can the three door to you. I'm going to fight and save. No, we can run this using answerable playbook on Give it the buff, which is documents danceable search. So doors. No, we need to run this playbook as the root user because obviously no other user will be able tow added disco Doris five. And since we're changing the pseudo or file itself, we can't use become yes, like we did in the installing Apache lecture. So walk around this that we will specify the use off, become password or the route user password in the answerable playbook. Come on, we will use minus B space minus K flags. So let me show you the flags that I'm going to use first. So answer playbook in this age to specify the help front. Now, in the help file, you can see if I use minus B. I'm telling, answerable to run the operation with become. And if I do a minus capital gay, it will ask for the become user process. So if why On my playbook with minus B and minus capital K flag, I'm telling, answerable through an ad hoc Amar to learn this playbook as the root user and prompt me to enter the password of the root user and I can hit mine escape, and now it will ask me for the pseudo password. So here I can specify the sooner password on the remote machine, and this will start running the playbook as a user on the remote machine. No, as you can see, we've got changed is equal to one, which means it has gone on to the remote machine and copy they're fine. Or rather, change the line in the file to specify Setsuo doors as password. There's going to the remote machine now on the remote machine. Once you're logged in as root, you can type in yeah, slash etc. Slash two doors and you can see that the pseudo line was a place to no passport, but this have come to the end of this lecture. This is how you can set all your remote machines to allow answer. Break to run privileged command. Thank you for watching. I will see you in the next lecture by