What is Ansible Part VI: Idempotence and State Management

Gourav Shah
A free video tutorial from Gourav Shah
Premium Instructor| 35k+ students| Devops Trainer and Author
4.1 instructor rating • 14 courses • 41,295 students

Learn more from the full course

Ultimate Ansible Bootcamp by School of Devops®

Unofficial Guide to EX407 Redhat Certified Specialist in Ansible Automation

07:32:45 of on-demand video • Updated July 2020

  • What is ansible, why its needed and how it works
  • How to configure ansible and setup static/dynamic inventories
  • Ad hoc server management, running jobs in parallel
  • Managing systems entities using ansible Modules
  • Writing Playbooks to define the state of infrastructure as a code
  • Creating modular, reusable code with Roles
  • Creating dynmic code with vars and templates
  • Using Ansible Galaxy
  • Encrypting sensitive data with Vault
  • Service Discovery and managing Multiple Environments
  • Application Deployment Strategies, Rolling Updates
English [Auto] In the previous lesson I talked about animals called versus data separation property and why it is important in this lesson. I'm going to talk about another one which is very very important called as I add importance. Now what is this item Borden's and what is this formula all about. Let's talk about it now if you want to understand I'd importance by definition this is what it really means. So item Borden's is the property of certain operations. In mathematics it is a mathematical property and computer science that can be applied multiple times without changing that it's beyond initial application and it can be represented by this formula. Now I'm just pulling your leg because the first time I learned right about this my reaction was just this. Now it is not as complex as you think it is because I'm going to explain to you using a simple example or an analogy let's have a look at that. Now let's say we have like three or four friends whose destination is Goa. We all want to go and party at Goa. Now different friends start from different origin places of origin. One is built based in Bangalore. Another one who is in Chennai. And then there is one more friend who is in Mumbai. Now the friend in Bangalore takes the overnight bus to reach to go up because that is they know it's pretty close by and you can reach by bus from there versus of the second person who is in Chennai. He has to take a train to Bangalore and then from there he takes a bus to go up right. So he takes a different route. The third person or the third friend is in Mumbai which is a little far away. So instead of travelling by road he decides to take a flight which is you know which is faster now the point here is by the way all of these are destinations or locations in India and GOI is a very popular beach place. If you want a party next you can definitely try that out. Now the point that I wanted to mention here was the road that you take depends on the difference between your source of origin and the destination. And based on that you're going to decide which road to take and how you're going to travel to your destination. Right now how is it relevant to answer both is because of this reason right. So you're gonna run and as an automation tool very right or define your infrastructure as a code right. Does the amateur playbooks and rules and so on and you will keep on applying and there is a possibility that let's say what to do in all our configuration management patching and so on. You might want to keep applying the same code over and over again a bit danceable. Now every time it runs though the proper defensible is that it compares its current state and desired state just like our previous example. The round of the action to take depends on your current state and the desired state and the difference between the two. So similarly and Sibal looks at the desired state looks at the current state compared thereto and takes an action only if there is a drift. Again why this is important. Let's have a look. We have talked about the desired state configuration Yamin called earlier and let us assume that this is my desired state. I want a user whose name with name x y z whose UI is should be 5000 won the password should we be who you are now the State of the entity on the systems may differ from system to system really right. So let's take one example. For system doesn't have the user in which case the user needs to be created using a command such as user add let's zoom on the second system. The user is there but the UI is different in which case you're not going to create a user. You're going to run a different command that is user more on the third system that uses the user is fine. The password is different. Again in this case you're not gonna use any of the earlier commands. You could use a command such as password on a Linux system or on a Windows system. You may have a different procedure to follow there. And finally if if everything is in the desired state if you have the user with this you know correct username you idea and password you are not going to take any action. Now this is important and this is what makes and interesting because what we talk about or what we write is the desired state and and symbol by itself looks at the current state looks at the desired state and based on that decides whether to take an action or not. And if yes what action to take. Imagine managing all of this using a shell script. You will have to take care of each of this condition and not only that you love to do that for every operating system. Because the procedure for whatever Europe is operating system may vary watches and symbol allows us to just care about what we want. That is their desired state and it is the answer Bill which manages the actions and what to take and the procedures based on the current state and their desired state. So that intelligence is called That's I'd importance and that's how let's say a first time you might run all the tasks. Second time you might just run the task which differ. Third time you may just want to skip everything because of all your entities are in desired state and this property which makes animal intelligent is called as I'd importance.