What is Ansible Part IV: Infrastructure as a Code

Gourav Shah
A free video tutorial from Gourav Shah
Premium Instructor| 35k+ students| Devops Trainer and Author
4.1 instructor rating • 14 courses • 41,403 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] No answer allows you to write the state of your infrastructure as a code using a declarative language such as the ammo. Now what's all this fuss about this infrastructure as a core. Let's try to understand. Talking about infrastructure as a code we're going to start comparing it with something that we already know about. That is scripts scripts is the you know the most basic form of automation that we start using and with scripts we start defining what to do and how to do something in the form of you know a scripting language using a scripting language such as Python both Shell and so on. Now infrastructure as a code takes a completely different approach here. And to understand this concept we are going to have an analogy here and compare it with something some. An example here. Right. Let's say you want to build a house. Now when you want to build a house you are going to hire a contractor and that contractor is gonna get some construction workers who are going to build that house for you. Brick by brick. Now they are the ones who know the procedure. Let's emphasize on this procedural part here. Because that's where they know how to do something. And on the other hand you also hire an architect no architect doesn't get into the procedure but architect thinks about what should be the desired state of your building how it should look like what should be the you know the. The end state of your house or so on and so forth. He envisions it with his creative abilities and then he translates his vision in to something called as a plan or a blueprint or the design of your building. Now what he focuses on is not the how part but it is the what part he answers right. And that's what is were defined in the form of that blueprint. And that's the blueprint he is going to hand over to the contractor. Contractor is gonna look at that and consider it as a desired state. And look at the current state. And based on that he is going to follow procedure and get into the how part of things. Now that's exactly what happens once we start writing our infrastructure as a cold you move away from the procedural part very think about our way we keep writing how to do things using procedural programming languages such as show our Python our pull and so on. And you become the architects of your infrastructure and start defining what you want. Using a declarative syntax such as this. Now if you look at it this is an example of a user. Let's say I want to create a user whose name is X Y Z. So I'm just going to define what I want the end state of that user with names so I am going to say I need a user whose name is X Y Z. His shell should we bash the UI should be X Y Z. Groups should be BQ R and I need this particular password now I don't care how this user is created. I don't even care what command to use in on which platform because this is what I'm going to define using and both an animal will translate it into the actual procedure or the command and that's the value that animal brings in it allows you to write or define your infrastructure as a code and then takes care of making sure are converting that into the actual infrastructure taking care of the how part of it. So you move away from being you know a contractor or a construction worker to be an architect of your infrastructure with Annabelle. That's what animal allows you to do. And what are the advantages of writing your infrastructure as a code. The first thing that you do once you start writing or defining it is you can have leverage and control your infrastructure. You're going to a new infrastructure you can have Virgin's offered you can completely evolve since you can travel and control it. You can create the complete state of your infrastructure out of a gold repository with certain compute resources of course. That's quite powerful to have. If you were to go back in time with the state of infrastructure that's also possible that the syntax such as the AML you also write self documented code so you don't have to write additional document to explain what you have written in the first place. You can also use some better editing and refactoring tools such as editors such as at Adam sublime or whatever data that you want and that's quite sophisticated a lot of those editors also come with to completion of the code which make make it even more easier to you know write that declarative code. You can also do peer reviews. You can work in groups work in in in pairs do pair programming. You can implement all of these best practices that developers have been you know working on and they've been you know they have come up with all these best practices for based on their experience over the years. And you could start implementing those practices into infrastructural activities as well. So you become essentially the developers of your infrastructure. You can also implement some best practices including test driven development and those other things which were not even possible with related to the operations and I.T. operation the infrastructure activities earlier. Now we can bring in all these practices which can make your infrastructure management easier and it can become predictable. It can become testable and it can become automated ble so those are some of the advantages of using infrastructure as a code. Are we going to continue our discussion on infrastructure as the code and start talking more templating with code words as data separation in the next lesson.