# role dependencies, with variables as arguments, called from multiple roles

**URL:** <https://forum.ansible.com/t/role-dependencies-with-variables-as-arguments-called-from-multiple-roles/16904>\
**Category:** Ansible Project\
**Created:** [November 27, 2014, 3:32pm UTC](https://forum.ansible.com/t/role-dependencies-with-variables-as-arguments-called-from-multiple-roles/16904 "2014-11-27T15:32:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robb\_Wagoner](https://avatars.discourse-cdn.com/v4/letter/r/5e9695/32.png) [@Robb\_Wagoner](https://forum.ansible.com/u/Robb_Wagoner)\
**Post date:** [November 27, 2014, 3:32pm UTC](https://forum.ansible.com/t/role-dependencies-with-variables-as-arguments-called-from-multiple-roles/16904/1 "2014-11-27T15:32:27Z")

</div>

I’d like for roles which configure Node apps, to generate some snippets for an HAProxy config. I’d like to be able to call the same role dependency, **app\_snippet** , in a generalized way, across many apps (app1, app2, etc.). However, the dependency executes once, even though I am using the **allow\_duplicates: yes** in the **meta/main.yml** for each app.

In short, I’d like role **app\_snippet** to be completely data-driven and called as a dependency of each **app** , and executed once for each **app** , using **vars** from the calling **app** role.

Am I missing something fundamental with Variable scoping? Or is this an anti-pattern in Ansible? The **allow\_duplicates: yes** boolean seems to only be in the scope of the calling app role, not global across roles.

PLAYBOOK: apps.yml

- name: install apps  
hosts: webservers  
roles:
- { role: app1 }
- { role: app2 }

ROLES:  
roles/app1/  
roles/app2/  
roles/app\_snippet/

ROLE appN: (i.e. app1 and app2 are mostly the same, for the purposes of role dependency)

roles/appN/vars/main.yml

---

<div class="post-metadata">

**Author:** ![James\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@James\_Morgan1](https://forum.ansible.com/u/James_Morgan1)\
**Post date:** [March 10, 2015, 8:28am UTC](https://forum.ansible.com/t/role-dependencies-with-variables-as-arguments-called-from-multiple-roles/16904/2 "2015-03-10T08:28:00Z")

</div>

Hi,

I’m seeing the same problem and have a very similar use case.

allow\_duplicates = yes doesn’t seem to be working as I would expect. Unsure if its a bug or I have misunderstood how it works

James
