Adding Ubuntu support by conditionally including vars

Gourav Shah
A free video tutorial from Gourav Shah
Premium Instructor| 35k+ students| Devops Trainer and Author
4.1 instructor rating • 14 courses • 41,356 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] The previous lesson you started writing to conditioner's. Now we're going to use the conditional of this name to add support for another platform that is. And we have north corner of that tree clinic to three using as such. The website that I teach it needs a password not unlike the previous notes. This one needs a password and password here is given to you that's called pieces foughten how it might change the future. So what we need to do is first. I know in the in one piece and this time we have to do it slightly differently because we have to not only are the norm but also how to connect to that. The connection information including the username and password and user name is only been defined in Biloxi and that is devolves However the password needs to be added and we'll go to the Red Tree documentation at this time How-To. Doc Passmore available so as we've spoken earlier and people in red do support these variables including audible since its users of an audience of a user and that simple as it's possible have been to are those properties who it to tree along with the host name. That is the theory here. Right. So we are going to add that ansible user and that is one password. And the simple password the password is the one which is given to you. Right now it is called spaces. Again that might change in future. So make sure you follow that up in addition Penticton. And once you have added that and Tibullus such password you could validate by connecting to that door and running that it's just using Bing. So that's the password I just showed you. And then you can once you're done with that you can just do simple and the host Pakhtun that's let's say up to minus and make sure it goes through and that goes to your node is ready to be Vonage it's I need to then went to and it's because it will be able to connect to that. So it is ready to manage. Now let's start making changes so if you look at the Pasha's Dasmunsi say already on the U.S. that package name here says the DPD as it should be a shade too far. So based on the platform we'll have to select the Properties select the boots or define debatable rather and use it here so we not only have to define the variables based on the platform but also you change this to use the values inside the tasks. And the way to do that. To add these variables that see we're using yum here will have to change that package as well. So we change for installation we change the modeling from Jambu package that's jeopardy. And then we do find the name of the package based on the platform family. So let's start using the medievals here some you lose a lot see a posse dog package and we have to define it. Somebody will learn vector define it in a minute and then we'll do the same for the service. So far service again the name of the service would be Aposhian Dutch service name because we'll have to you know I also want to define the service Tiede using a BT so that I can stop the service just based on my changing on a DVD bosome some and along with that we'll also have to change the handler obviously right. The service also comes on because you have to restart the restart. This is some very odd state we don't change for the handler because states will always be able to restock the service when it comes to the handlers. And now we'll go Gudel vires. So this is Bateson's say the rule is when we have platform specific fight and let's have a look at the platforms. So if you just run direct danceable all set up come on with a name like Louis family. You'll see that most of our notes are read in that say app 1 in blue or red hat pushes up to use Debian. So we'll have to create a Debian Tamil and that had become and then we'll selectively into that we learn about that in a minute. So and this is very defined Aposhian package service name and Steve. And then based on the platform family this is for attacks of use the DPD and state discarnate for anyways and then copy that. And Jean Cho in for the it will be a part of it too. So we just change the name for the service and package to apply. Q From the DPD Now if you run into step for the PMO you would see you know this. This is less tag's actually. You see all the facts right now that you can also use skip tags and then you don't want to let's say conflict. For example you can skip the time cards on fake. So all the cost related configurations will be skipped here and then you can also limit the cushion to a specific post using Hypponen limit options with limiting vision only. And let's see what happens. It's one up and we executed it. And that's because it was not able to find the variable. That's because we have not started in deluding that the evil in sight are made but and we have to do that. It's also important to get up before you actually start doing the installation steps. For a let's see on Debian being not the machine. So I just run that one off. Come on using one up. Come on. That's both boots and the editor was related to the patents are positive because we saw that using update update. Now this time it's the error. But the you know the video's not being defined or not being called and we love to do that we are using the. Are available. We're not including anything in the vice Tudyk upload does not get automatically included. We have to include it explicitly from here and that's through the server going to use conditional. We can conditionally do that using OBD BT boats. So when you say import and Videsh and based on the family view or even that this was family and then yammers so that it will automatically pick the variable for the interval was family. Let's say that had gone to Yemen or had been Tamil based on which system it is running on you make sure you save the file execute that same come on again and this time it is never too late to Port St.. Mean it should actually be in the BT booths today. Not to put it up to change that today. That's that's their documentation that's where we would see here. So instantly what virus was Sibylla's family and this should now go through. So now we have support for Debian our systems of both and we're just running your app tree right now. But we can just execute that dropped him and configure both. It had to be systems as well as we do these systems. So there you see the packages being installed and so is being started. So the right side of me. And if you go to the browser and go to app to that is 2:52 should see that beach photoplay it is a passion for Ubuntu saying this lesson we learned how to add support for another platform by using the fact specific viruses whole virus as well as include virus conditionally ruling that based on the fact.