1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix parent attribute lookup

Using 'value is None' instead of 'not value', in order to account
for boolean values which may be false

Fixes #11232
This commit is contained in:
James Cammarata 2015-06-22 01:17:09 -04:00
parent 256a323de5
commit 332ca927d9
2 changed files with 8 additions and 7 deletions

View file

@ -260,19 +260,19 @@ class Block(Base, Become, Conditional, Taggable):
''' '''
value = self._attributes[attr] value = self._attributes[attr]
if self._parent_block and (not value or extend): if self._parent_block and (value is None or extend):
parent_value = getattr(self._parent_block, attr) parent_value = getattr(self._parent_block, 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
if self._task_include and (not value or extend): if self._task_include and (value is None or extend):
parent_value = getattr(self._task_include, attr) parent_value = getattr(self._task_include, 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
if self._role and (not value or extend): if self._role and (value is None or extend):
parent_value = getattr(self._role, attr) parent_value = getattr(self._role, attr)
if extend: if extend:
value = self._extend_value(value, parent_value) value = self._extend_value(value, parent_value)
@ -289,9 +289,10 @@ class Block(Base, Become, Conditional, Taggable):
else: else:
value = dep_value value = dep_value
if value and not extend: if value is not None and not extend:
break break
if self._play and (not value or extend):
if self._play and (value is None or extend):
parent_value = getattr(self._play, attr) parent_value = getattr(self._play, attr)
if extend: if extend:
value = self._extend_value(value, parent_value) value = self._extend_value(value, parent_value)

View file

@ -297,13 +297,13 @@ class Task(Base, Conditional, Taggable, Become):
Generic logic to get the attribute or parent attribute for a task value. Generic logic to get the attribute or parent attribute for a task value.
''' '''
value = self._attributes[attr] value = self._attributes[attr]
if self._block and (not value or extend): if self._block and (value is None or extend):
parent_value = getattr(self._block, attr) parent_value = getattr(self._block, 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
if self._task_include and (not value or extend): if self._task_include and (value is None or extend):
parent_value = getattr(self._task_include, attr) parent_value = getattr(self._task_include, attr)
if extend: if extend:
value = self._extend_value(value, parent_value) value = self._extend_value(value, parent_value)