1
0
Fork 0
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:
James Cammarata 2016-01-26 13:10:23 -05:00
parent 66104191d1
commit 07a9a54b0e
2 changed files with 9 additions and 18 deletions

View file

@ -298,18 +298,18 @@ class Block(Base, Become, Conditional, Taggable):
value = self._extend_value(value, parent_value) value = self._extend_value(value, parent_value)
else: else:
value = parent_value value = parent_value
if self._role and (value is None or extend): if self._role and (value is None or extend) and hasattr(self._role, attr):
parent_value = getattr(self._role, attr) parent_value = getattr(self._role, attr, None)
if extend: if extend:
value = self._extend_value(value, parent_value) value = self._extend_value(value, parent_value)
else: else:
value = parent_value 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 = self._dep_chain[:]
reverse_dep_chain.reverse() reverse_dep_chain.reverse()
for dep in reverse_dep_chain: for dep in reverse_dep_chain:
dep_value = getattr(dep, attr) dep_value = getattr(dep, attr, None)
if extend: if extend:
value = self._extend_value(value, dep_value) value = self._extend_value(value, dep_value)
else: else:
@ -317,14 +317,13 @@ class Block(Base, Become, Conditional, Taggable):
if value is not None and not extend: if value is not None and not extend:
break break
if self._play and (value is None or extend) and hasattr(self._play, attr):
if self._play and (value is None or extend): parent_value = getattr(self._play, attr, None)
parent_value = getattr(self._play, attr)
if extend: if extend:
value = self._extend_value(value, parent_value) value = self._extend_value(value, parent_value)
else: else:
value = parent_value value = parent_value
except KeyError: except KeyError as e:
pass pass
return value return value
@ -344,11 +343,7 @@ class Block(Base, Become, Conditional, Taggable):
''' '''
Override for the 'tags' getattr fetcher, used from Base. Override for the 'tags' getattr fetcher, used from Base.
''' '''
any_errors_fatal = self._attributes['any_errors_fatal'] return self._get_parent_attribute('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
def filter_tagged_tasks(self, play_context, all_vars): def filter_tagged_tasks(self, play_context, all_vars):
''' '''

View file

@ -419,9 +419,5 @@ class Task(Base, Conditional, Taggable, Become):
''' '''
Override for the 'tags' getattr fetcher, used from Base. Override for the 'tags' getattr fetcher, used from Base.
''' '''
any_errors_fatal = self._attributes['any_errors_fatal'] return self._get_parent_attribute('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