# duplicated role execution..

**URL:** <https://forum.ansible.com/t/duplicated-role-execution/14122>\
**Category:** Ansible Project\
**Created:** [December 11, 2013, 5:20am UTC](https://forum.ansible.com/t/duplicated-role-execution/14122 "2013-12-11T05:20:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xu\_Chen](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@Xu\_Chen](https://forum.ansible.com/u/Xu_Chen)\
**Post date:** [December 11, 2013, 5:20am UTC](https://forum.ansible.com/t/duplicated-role-execution/14122/1 "2013-12-11T05:20:00Z")

</div>

I have defined three roles: A, B and C.

Using meta/main.yml, I have B depending on A, and C depending on A as well.

If I have the following:

- hosts: group\_test  
roles:
- B
- C

What happens is that the tasks associated to role A is executed twice. Is there any dedup mechanism to execute them only once?

Thanks…

---

<div class="post-metadata">

**Author:** ![John\_Dewey](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@John\_Dewey](https://forum.ansible.com/u/John_Dewey)\
**Post date:** [December 11, 2013, 7:03am UTC](https://forum.ansible.com/t/duplicated-role-execution/14122/2 "2013-12-11T07:03:57Z")

</div>

Hi Xu -

Not that I have seen. I believe you will have duplicate tasks run.

John

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [December 11, 2013, 8:01am UTC](https://forum.ansible.com/t/duplicated-role-execution/14122/3 "2013-12-11T08:01:57Z")

</div>

Have a look at [http://www.ansibleworks.com/docs/playbooks\_roles.html#role-dependencies](http://www.ansibleworks.com/docs/playbooks_roles.html#role-dependencies)

There’s a meta variable to allow for duplicates, but AFAIK, that only works within one role dependency tree, while your case has two (B and C).  
Maybe you can make that work with a role D which depends on B and C, not sure.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [December 11, 2013, 1:07pm UTC](https://forum.ansible.com/t/duplicated-role-execution/14122/4 "2013-12-11T13:07:19Z")

</div>

It’s possible that our duplicates filter needs a little tweaking, I’ll let James Cammarata reply here, though I will point out that it’s designed that roles with different parameters (i.e. dependencies with different parameters) do need to get re-evaluated.

---

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [December 11, 2013, 6:30pm UTC](https://forum.ansible.com/t/duplicated-role-execution/14122/5 "2013-12-11T18:30:54Z")

</div>

You may want to have a look here: [https://groups.google.com/d/msg/ansible-project/nd4wMLsb0Jw/7-svzpNpTIQJ](https://groups.google.com/d/msg/ansible-project/nd4wMLsb0Jw/7-svzpNpTIQJ)

Nathan Howell has demonstrated a very nice approach which works very nice for me.
