-
Bug
-
Resolution: Obsolete
-
Undefined
-
None
-
rhel-8.9.0
-
None
-
None
-
Important
-
rhel-sst-ansible
-
None
-
False
-
-
None
-
Red Hat Enterprise Linux
-
None
-
None
-
None
-
x86_64
-
None
ansible-core 2.15.3
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] =>
TASK [role2 : Now in role2] ****************
ok: [myhost] =>
TASK [role1 : Now in role1] ****************
ok: [myhost] =>
I think this occurs for the following logic
- role1 is invoked due to role1 being specified in the playbook.yml
- role1 dependencies are invoked prior to role1 tasks
- role2 is invoked because doit is True
- role2 dependencies are invoked prior to role2 tasks
- role3 is invoked
- role3 tasks are run (first task)
- role2 tasks are run (second task)
- role3 would be invoked from the role1 dependencies, but since it has already been invoked from the role2 dependecies, it is ignored
- 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] =>
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] =>
TASK [role1 : Now in role1] ****************
ok: [myhost] =>
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.
Up stream fix in 2.15.5
Community forum
https://forum.ansible.com/t/role-dependencies-not-being-fulfilled/3437
git pull request
https://github.com/ansible/ansible/pull/81668