mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 22:33:25 +00:00
Skip self._parent on dynamic, defer to grandparent for attr lookup (#38827)
* Skip self._parent on dynamic, defer to grandparent for attr lookup * Revert _inheritable * Add tests for include inheritance from static blocks Fixes #38037 #36194
This commit is contained in:
@@ -423,13 +423,20 @@ class Task(Base, Conditional, Taggable, Become):
|
||||
prepend = self._valid_attrs[attr].prepend
|
||||
try:
|
||||
value = self._attributes[attr]
|
||||
if self._parent and (value is None or extend):
|
||||
if getattr(self._parent, 'statically_loaded', True):
|
||||
# If parent is static, we can grab attrs from the parent
|
||||
# otherwise, defer to the grandparent
|
||||
if getattr(self._parent, 'statically_loaded', True):
|
||||
_parent = self._parent
|
||||
else:
|
||||
_parent = self._parent._parent
|
||||
|
||||
if _parent and (value is None or extend):
|
||||
if getattr(_parent, 'statically_loaded', True):
|
||||
# vars are always inheritable, other attributes might not be for the partent but still should be for other ancestors
|
||||
if attr != 'vars' and getattr(self._parent, '_inheritable', True) and hasattr(self._parent, '_get_parent_attribute'):
|
||||
parent_value = self._parent._get_parent_attribute(attr)
|
||||
if attr != 'vars' and hasattr(_parent, '_get_parent_attribute'):
|
||||
parent_value = _parent._get_parent_attribute(attr)
|
||||
else:
|
||||
parent_value = self._parent._attributes.get(attr, None)
|
||||
parent_value = _parent._attributes.get(attr, None)
|
||||
|
||||
if extend:
|
||||
value = self._extend_value(value, parent_value, prepend)
|
||||
|
||||
Reference in New Issue
Block a user