mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix lookup of parent attribute when parent doesn't have the attr
Fixes #14100
This commit is contained in:
parent
66104191d1
commit
07a9a54b0e
2 changed files with 9 additions and 18 deletions
|
@ -298,18 +298,18 @@ class Block(Base, Become, Conditional, Taggable):
|
|||
value = self._extend_value(value, parent_value)
|
||||
else:
|
||||
value = parent_value
|
||||
if self._role and (value is None or extend):
|
||||
parent_value = getattr(self._role, attr)
|
||||
if self._role and (value is None or extend) and hasattr(self._role, attr):
|
||||
parent_value = getattr(self._role, attr, None)
|
||||
if extend:
|
||||
value = self._extend_value(value, parent_value)
|
||||
else:
|
||||
value = parent_value
|
||||
|
||||
if len(self._dep_chain) and (not value or extend):
|
||||
if len(self._dep_chain) and (value is None or extend):
|
||||
reverse_dep_chain = self._dep_chain[:]
|
||||
reverse_dep_chain.reverse()
|
||||
for dep in reverse_dep_chain:
|
||||
dep_value = getattr(dep, attr)
|
||||
dep_value = getattr(dep, attr, None)
|
||||
if extend:
|
||||
value = self._extend_value(value, dep_value)
|
||||
else:
|
||||
|
@ -317,14 +317,13 @@ class Block(Base, Become, Conditional, Taggable):
|
|||
|
||||
if value is not None and not extend:
|
||||
break
|
||||
|
||||
if self._play and (value is None or extend):
|
||||
parent_value = getattr(self._play, attr)
|
||||
if self._play and (value is None or extend) and hasattr(self._play, attr):
|
||||
parent_value = getattr(self._play, attr, None)
|
||||
if extend:
|
||||
value = self._extend_value(value, parent_value)
|
||||
else:
|
||||
value = parent_value
|
||||
except KeyError:
|
||||
except KeyError as e:
|
||||
pass
|
||||
|
||||
return value
|
||||
|
@ -344,11 +343,7 @@ class Block(Base, Become, Conditional, Taggable):
|
|||
'''
|
||||
Override for the 'tags' getattr fetcher, used from Base.
|
||||
'''
|
||||
any_errors_fatal = self._attributes['any_errors_fatal']
|
||||
if hasattr(self, '_get_parent_attribute'):
|
||||
if self._get_parent_attribute('any_errors_fatal'):
|
||||
any_errors_fatal = True
|
||||
return any_errors_fatal
|
||||
return self._get_parent_attribute('any_errors_fatal')
|
||||
|
||||
def filter_tagged_tasks(self, play_context, all_vars):
|
||||
'''
|
||||
|
|
|
@ -419,9 +419,5 @@ class Task(Base, Conditional, Taggable, Become):
|
|||
'''
|
||||
Override for the 'tags' getattr fetcher, used from Base.
|
||||
'''
|
||||
any_errors_fatal = self._attributes['any_errors_fatal']
|
||||
if hasattr(self, '_get_parent_attribute'):
|
||||
if self._get_parent_attribute('any_errors_fatal'):
|
||||
any_errors_fatal = True
|
||||
return any_errors_fatal
|
||||
return self._get_parent_attribute('any_errors_fatal')
|
||||
|
||||
|
|
Loading…
Reference in a new issue