From the course: Ansible Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Using variables in roles

Using variables in roles - Ansible Tutorial

From the course: Ansible Essential Training

Using variables in roles

- [Instructor] For many Ansible experts, it makes great sense for them to create reusable files for variable definitions that are commonly required in their playbooks. Well, this concept of re-usability is in perfect stride with Ansible roles. Let's go to this system and let's take a look at that Ansible role that we were manipulating. So we're going to go to our Ansible roles directory. And if we do a list here, we remember that there is this test role one. So let's change into that directory. And we are reminded of the directories inside of our Ansible role. And notice one of those is the defaults area. So let's change into the defaults area and do our listing. And there's the main.yml in defaults. Let's take a look at what I did to this file. So let's take a look at the main.yml there, and you can see that the defaults file I've modified it and I've identified a variable named my var and I've set it equal to this is the…

Contents