Hi!

Whenever I include a role using the meta dependencies tag I ended up with 
the scope of the included role in the current role, even though I 
set private_role_vars = yes

As an example, consider a project like this
├── ansible.cfg
├── roles
│   ├── some_other_role
│   │   └── vars
│   │       └── main.yml
│   └── some_role
│       ├── defaults
│       │   └── main.yml
│       ├── meta
│       │   └── main.yml
│       └── tasks
│           └── main.yml
└── test.yml


the playbook test.yml simply includes 'some_role'

- hosts: all
  tasks:
    - include_role:
        name: some_role

 
In some_role meta definition I include a dependency 
(some_role/meta/main.yml)

---
dependencies:
  - { role: some_other_role }


And also set a variable a default value (some_role/defaults/main.yml)

some_variable: SOME_VARIABLE

The main task for this role is simply showing the value of the var 
(some_role/tasks/main.yml)

---
- debug: var=some_variable


some_other_role simply defines a variable that happens to have the same 
name as a variable some_role (some_other_role/vars/main.yml)

some_variable: SOME_VARIABLE_WITH_VALUE_FROM_OUTSIDE

I have the private_role_vars = yes in my ansible.cfg

When I run the playbook...
ansible-playbook test.yml -c local

PLAY [all] 
***********************************************************************************************************************************************************************

TASK [Gathering Facts] 
***********************************************************************************************************************************************************
ok: [127.0.0.1]

TASK [some_role : debug] 
*********************************************************************************************************************************************************
ok: [127.0.0.1] => {
    "changed": false,
    "some_variable": "SOME_VARIABLE_WITH_VALUE_FROM_OUTSIDE"
}

PLAY RECAP 
***********************************************************************************************************************************************************************
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0 
  


BOOM!

Seems that even though I set the private_role_vars = yes, some_role scope 
gets poluted with the scope of some_other_role. If I change the definition 
to the vars instead of the defaults of the some_other_role it works but not 
because I dont get the scope, but because vars have precedence over a 
previously defined var.

Is this a bug? is this the desired behavior? How can overcome this?

Thanks in advance, Jose Fernandez

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e2f4e42c-170a-4d23-a9a6-e2e24fc4e09f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to