Revert "Compile role with parents in the task's dependency chain (#75165)" (#75779)

This reverts commit 440cf15aeb.
pull/75783/head
Sloane Hertel 3 years ago committed by GitHub
parent 6a5d6896fd
commit 845935f74f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +0,0 @@
bugfixes:
- include_role - Only inherit from role parents in the current task dependency chain (https://github.com/ansible/ansible/issues/39543).
- include_role - Inherit from role parents beyond a depth of 3 (https://github.com/ansible/ansible/issues/47023).
- include_role - Inherit from role parents in the order of the task dependency chain.

@ -100,7 +100,11 @@ class IncludeRole(TaskInclude):
# compile role with parent roles as dependencies to ensure they inherit
# variables
dep_chain = self.get_dep_chain() or []
if not self._parent_role:
dep_chain = []
else:
dep_chain = list(self._parent_role._parents)
dep_chain.append(self._parent_role)
p_block = self.build_parent_block()

@ -1,7 +0,0 @@
---
- hosts: all
gather_facts: no
roles:
- 39543_role1
- role: 39543_role3
when: false

@ -1,5 +0,0 @@
---
- hosts: all
gather_facts: no
tasks:
- include_role: name=47023_role1

@ -1,5 +0,0 @@
- debug:
msg: 'role1'
- include_role:
name: 39543_role2

@ -1,5 +0,0 @@
- debug:
msg: "Var is {{ my_var | default('undefined') }}"
- debug:
msg: "Default is {{ my_default | default('undefined') }}"

@ -17,14 +17,3 @@ set -eux
# ensure role data is merged correctly
ansible-playbook data_integrity.yml -i ../../inventory "$@"
# ensure role vars are inherited correctly
ANSIBLE_PRIVATE_ROLE_VARS=True ansible-playbook 39543.yml -i ../../inventory "$@" | tee out.txt
test "$(grep '"msg": "role1"' -c out.txt)" = "1"
test "$(grep '"msg": "role2"' -c out.txt)" = "1"
test "$(grep '"msg": "role3"' -c out.txt)" = "0"
# test nested includes get parent roles greater than a depth of 3
[ "$(ansible-playbook 47023.yml -i ../../inventory "$@" | grep '\<\(Default\|Var\)\>' | grep -c 'is defined')" = "2" ]

Loading…
Cancel
Save