role dependencies

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

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

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.

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ł:

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 :wink:

Mark