Role dependencies gets skipped in ansible 2

407 views
Skip to first unread message

deep....@gmail.com

unread,
Mar 8, 2016, 8:54:59 AM3/8/16
to Ansible Project
Hi,

I was trying to upgrade from ansible 1.8.4 to ansible 2, and noticed that some of my roles with meta dependencies stopped working.

I have these roles

role-main1/meta/main.yml
---
dependencies:
  - { role: role-dependency }


role-main2/meta/main.yml
---
dependencies:
  - { role: role-dependency }
role-dependency/meta/main.yml
---
allow_duplicates: yes

Now, I have a playbook which calls the roles role-main1 and role-main2 based on some condition
- { role: role-main1, when: (z1|bool) }
- { role: role-main2, when: (z2|bool) }

Everything works fine if both the conditions are met and both roles get called

if z1=true z2=true

1. role-dependency => executed
2. role-main1 => executed
3. role-dependency => executed
4. role-main2 => executed

But if the first condition fails then the dependency fails to execute even for the second role

If z1=false z2=true

1. role-dependency => skipped
2. role-main1 =>  skipped
3. role-dependency => skipped   (We were expecting this to be executed)
4. role-main2 => executed

This was working in my earlier version of ansible (1.8.4), I even tested it in 1.9 version and it worked fine. It seems to be broken in ansible 2 series.

Can someone help here.

Thanks
Deep

Grim76

unread,
Jun 1, 2016, 2:48:57 PM6/1/16
to Ansible Project
I am having the same issue. Have you been able to find a fix to this?

am...@wepay.com

unread,
Jun 16, 2016, 7:36:48 PM6/16/16
to Ansible Project
Hi,

I am also having slightly related problem.

My roles structure are as follows
     
    role-main1/meta/main.yml
  ---
   dependencies:
      - { role: common }


    role-main2/meta/main.yml
  ---
   dependencies:
      - { role: common }

Now I have a top level playbook which calls both these roles one after the another.
   main.yml
   ---
    - role: role-main1
    - role: role-main2
The problem is ansible is skipping common dependency in first role and installing in second role. Skip reason is "Conditional check failed". But I don't have any condition defined for this dependency. And same dependency gets executed in the second role.

The document says that ansible run in for the first role and skip it for second one. which is exactly what I want and this was working in 1.8.
Is anything changed in ansible 2.0? or it is possible some global condition is getting applied to this task? So far I am unable to find any global condition which will cause this.

Martin Studer

unread,
Jul 25, 2016, 4:09:02 PM7/25/16
to Ansible Project
Hi,

I'm experiencing exactly the same issue. I found there is a property "allow_duplicates" (see http://docs.ansible.com/ansible/playbooks_roles.html) but that doesn't seem to work for dependent roles ...

Best regards,
Martin
Reply all
Reply to author
Forward
0 new messages