# role dependencies

**URL:** <https://forum.ansible.com/t/role-dependencies/14549>\
**Category:** Ansible Project\
**Tags:** windows, ubuntu\
**Created:** [February 12, 2014, 9:54am UTC](https://forum.ansible.com/t/role-dependencies/14549 "2014-02-12T09:54:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [February 12, 2014, 9:54am UTC](https://forum.ansible.com/t/role-dependencies/14549/1 "2014-02-12T09:54:38Z")

</div>

Hi List,

In a role that installs a mcafee antivirus scanner on linux (Don’t ask why; short answer: corporate policy made up by windows people) I have defined a role dependency like so:

> ## mmaas@xmgtansible:~/playbooks$ cat roles/mcafee/meta/main.yml
> 
> dependencies:
> 
> - { role: all\_common }

The contents of the rest of this role:  
[http://pastebin.com/xPVfZCUR](http://pastebin.com/xPVfZCUR)

But it simply will not run the “all\_common” role. It’s as if it’s ignoring the dependency as a whole:

> mmaas@xmgtansible:~/playbooks$ ansible-playbook site.yml -l xmonopssla00 --tags=mcafee  
> sudo password:  
> PLAY [ubuntu\_hosts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> ok: [xmonopssla00]  
> xmonopssla00: importing /home/mmaas/playbooks/vars/Ubuntu.yml  
> TASK: [mcafee | Installeer eerste deb file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> changed: [xmonopssla00]  
> TASK: [mcafee | Installeer tweede deb file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> changed: [xmonopssla00]  
> PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> xmonopssla00 : ok=3 changed=2 unreachable=0 failed=0

Could this be a bug in 1.4.4 or am I doing the dependency thing incorrectly perhaps?

Thanks for looking!  
Mark

---

<div class="post-metadata">

**Author:** ![Christian\_Thiemann](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@Christian\_Thiemann](https://forum.ansible.com/u/Christian_Thiemann)\
**Post date:** [February 12, 2014, 10:30am UTC](https://forum.ansible.com/t/role-dependencies/14549/2 "2014-02-12T10:30:48Z")

</div>

You invoke ansible-playbook with the tags argument, incidentally selecting only the tasks in the mcafee role. Invoke without tags and it should run the all\_common tasks as well.

---

<div class="post-metadata">

**Author:** ![Tomasz\_Lesniewski](https://avatars.discourse-cdn.com/v4/letter/t/7ab992/32.png) [@Tomasz\_Lesniewski](https://forum.ansible.com/u/Tomasz_Lesniewski)\
**Post date:** [February 12, 2014, 11:09am UTC](https://forum.ansible.com/t/role-dependencies/14549/3 "2014-02-12T11:09:19Z")

</div>

Role all\_common is evaluated, but contains no tasks with tag mcafee, so nothing from this role is running. You should add tag to role dependency:

dependencies:

- { role: all\_common, tags [mcafee] }

W dniu środa, 12 lutego 2014 10:54:38 UTC+1 użytkownik Mark Maas napisał:

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [February 13, 2014, 6:31am UTC](https://forum.ansible.com/t/role-dependencies/14549/4 "2014-02-13T06:31:17Z")

</div>

Almost there I think!

I changed it into:

> * * *
> 
> dependencies:
> 
> - { role: all\_common, tags: [“mcafee”] }

which resulted in:

> mmaas@xmgtansible:~/playbooks$ ansible-playbook site.yml -l xmonopssla00 --tags=mcafee  
> sudo password:  
> Traceback (most recent call last):  
> File “/usr/local/bin/ansible-playbook”, line 269, in   
> sys.exit(main(sys.argv[1:]))  
> File “/usr/local/bin/ansible-playbook”, line 209, in main  
> pb.run()  
> File “/usr/local/lib/python2.7/dist-packages/ansible/playbook/ **init**.py”, line 229, in run  
> play = Play(self, play\_ds, play\_basedir)  
> File “/usr/local/lib/python2.7/dist-packages/ansible/playbook/play.py”, line 83, in **init**  
> ds = self.\_load\_roles(self.roles, ds)  
> File “/usr/local/lib/python2.7/dist-packages/ansible/playbook/play.py”, line 327, in \_load\_roles  
> roles = self.\_build\_role\_dependencies(roles, , self.vars)  
> File “/usr/local/lib/python2.7/dist-packages/ansible/playbook/play.py”, line 276, in \_build\_role\_dependencies  
> self.\_build\_role\_dependencies([dep], dep\_stack, passed\_vars=dep\_vars, level=level+1)  
> File “/usr/local/lib/python2.7/dist-packages/ansible/playbook/play.py”, line 223, in \_build\_role\_dependencies  
> included\_dep\_vars[“tags”] = passed\_vars[“tags”].copy()  
> AttributeError: ‘list’ object has no attribute ‘copy’

Does not look right to me 😉

Mark
