mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Don't mark parent role complete for nested include_role calls
The PlayIterator was written without nested roles in mind, but since include_role can nest them we need to check to see if we've moved into a new role which is a child via nesting. Fixes #18026
This commit is contained in:
parent
7e2fc88218
commit
0d5206f90c
1 changed files with 11 additions and 1 deletions
|
@ -28,6 +28,7 @@ from ansible import constants as C
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.playbook.block import Block
|
from ansible.playbook.block import Block
|
||||||
from ansible.playbook.task import Task
|
from ansible.playbook.task import Task
|
||||||
|
from ansible.playbook.role_include import IncludeRole
|
||||||
|
|
||||||
from ansible.utils.boolean import boolean
|
from ansible.utils.boolean import boolean
|
||||||
|
|
||||||
|
@ -265,9 +266,18 @@ class PlayIterator:
|
||||||
else:
|
else:
|
||||||
return old_s.cur_dep_chain != task.get_dep_chain()
|
return old_s.cur_dep_chain != task.get_dep_chain()
|
||||||
|
|
||||||
|
def _role_is_child(r):
|
||||||
|
parent = task._parent
|
||||||
|
while parent:
|
||||||
|
if hasattr(parent, '_role') and parent._role == r and isinstance(parent, IncludeRole):
|
||||||
|
return True
|
||||||
|
parent = parent._parent
|
||||||
|
return False
|
||||||
|
|
||||||
if task and task._role:
|
if task and task._role:
|
||||||
# if we had a current role, mark that role as completed
|
# if we had a current role, mark that role as completed
|
||||||
if s.cur_role and _roles_are_different(task._role, s.cur_role) and host.name in s.cur_role._had_task_run and not peek:
|
if s.cur_role and _roles_are_different(task._role, s.cur_role) and host.name in s.cur_role._had_task_run and \
|
||||||
|
not _role_is_child(s.cur_role) and not peek:
|
||||||
s.cur_role._completed[host.name] = True
|
s.cur_role._completed[host.name] = True
|
||||||
s.cur_role = task._role
|
s.cur_role = task._role
|
||||||
s.cur_dep_chain = task.get_dep_chain()
|
s.cur_dep_chain = task.get_dep_chain()
|
||||||
|
|
Loading…
Reference in a new issue