# Role dependencies not being fulfilled

**URL:** <https://forum.ansible.com/t/role-dependencies-not-being-fulfilled/3437>\
**Category:** Get Help\
**Created:** [January 22, 2024, 9:05pm UTC](https://forum.ansible.com/t/role-dependencies-not-being-fulfilled/3437 "2024-01-22T21:05:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![erempel](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@erempel](https://forum.ansible.com/u/erempel)\
**Post date:** [January 22, 2024, 9:05pm UTC](https://forum.ansible.com/t/role-dependencies-not-being-fulfilled/3437/1 "2024-01-22T21:05:24Z")

</div>

Recently upgrade to ansible-core 2.15 and some of my roles are no longer included even though they are in the meta dependencies list.

To demonstrate this, I have 3 role  
role1  
role2  
role3

all three roles have a single task

- name: Now in {{ role\_name }}  
debug:  
msg: “running tasks in {{ role\_name }}”

role1 has meta/main.yml contents

dependencies:  
- role: role2  
when: doit|default(True)  
- role: role3

role2 has meta/main.yml contents  
dependencies:  
- role: role3

running a playbook that includes role1 I get the following

playbook.yml -e ‘{ doit: True }’  
TASK [role3 : Now in role3] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [myhost] =\> {  
“msg”: “running tasks in role3”  
}  
TASK [role2 : Now in role2] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [myhost] =\> {  
“msg”: “running tasks in role2”  
}  
TASK [role1 : Now in role1] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [myhost] =\> {  
“msg”: “running tasks in role1”  
}

I think this occurs for the following logic

1. role1 is invoked due to role1 being specified in the playbook.yml
2. role1 dependencies are invoked prior to role1 tasks
3. role2 is invoked because doit is True
4. role2 dependencies are invoked prior to role2 tasks
5. role3 is invoked
6. role3 tasks are run (first task)
7. role2 tasks are run (second task)
8. role3 would be invoked from the role1 dependencies, but since it has already been invoked from the role2 dependecies, it is ignored
9. role1 tasks are run (third task)

This is what I would expect, and is what happened before I upgraded to ansible-core 2.15  
The issue is that if doit is False, role3 is never invoked.

playbook.yml -e ‘{ doit: False }’

TASK [role3 : Now in role3] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [myhost]  
TASK [role2 : Now in role2] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [myhost]  
TASK [role1 : Now in role1] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [myhost] =\> {  
“msg”: “running tasks in role1”  
}

It seems that the dependencies in role1 where role3 is included is masked by role2 being skipped. what used to happen is

playbook.yml -e ‘{ doit: False }’

TASK [role3 : Now in role3] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [myhost]  
TASK [role2 : Now in role2] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [myhost]  
TASK [role3 : Now in role3] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [myhost] =\> {  
“msg”: “running tasks in role3”  
}  
TASK [role1 : Now in role1] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [myhost] =\> {  
“msg”: “running tasks in role1”  
}

The dependency of role3 from the meta/main.yml of role1 has no when clause, and since it has not been invoked yet, it gets invoked and its dependencies AND tasks are run.

Is this a bug?  
If it is not a bug, how do I get role3 to be invoked when somewhere in the dependencies of role2 there was a skipped role3?

Thanks.

---

<div class="post-metadata">

**Author:** ![shertel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shertel/32/1241_2.png) [@shertel](https://forum.ansible.com/u/shertel)\
**Post date:** [January 24, 2024, 12:56pm UTC](https://forum.ansible.com/t/role-dependencies-not-being-fulfilled/3437/2 "2024-01-24T12:56:16Z")

</div>

Are you using 2.15.5 or later? This looks like the issue I fixed in [[2.15] Only mark a role as complete once a task in it executes by s-hertel · Pull Request #81668 · ansible/ansible · GitHub](https://github.com/ansible/ansible/pull/81668).

---

<div class="post-metadata">

**Author:** ![erempel](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@erempel](https://forum.ansible.com/u/erempel)\
**Post date:** [January 24, 2024, 2:09pm UTC](https://forum.ansible.com/t/role-dependencies-not-being-fulfilled/3437/3 "2024-01-24T14:09:14Z")

</div>

Thanks. That looks like the fix. I am running 2.15.3  
I will get this updated.
