Hello,
I think I don’t understand perfectly what is meant by :
“In Ansible 1.3 and later, however, vars/ directories are guaranteed to be scoped to the current role, just like roles parameters.”
I have the following test project :
├── all.yml
├── roles
│ ├── role1
│ │ ├── tasks
│ │ │ └── main.yml
│ │ └── vars
│ │ └── main.yml
│ └── role2
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ └── main.yml
└── test
where :
role1/vars/main.yml sets the variable var to role1
role2/vars/main.yml sets the variable var to role2
and all.yml is
- hosts: all
roles:- role1
- role2
I am using the variable var in role1/tasks/main.yml and in role1/tasks/main.yml and in both cases its value is role2. Is it what I should have expected?
Real case scenario :
I have a few steps that I want to reuse for different roles. They have been extracted to a playbook that I can include and I’m using a var to configure the behavior. In production the roles might be split between different servers but in test they are configured on the same server… But the var has always the same value every time the extracted playbook is played.
Thanks a lot