diff options
author | James Cammarata <jimi@sngx.net> | 2018-01-05 20:51:44 -0600 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2018-01-05 21:51:44 -0500 |
commit | ebf971f931290a113f738f658d7a6e095994e120 (patch) | |
tree | d3856d13017f25d5560ea99456a4df76aaba8bc2 /lib/ansible/playbook/base.py | |
parent | ab5dbca47e5b3f481fe7578468da9136bcd347d8 (diff) | |
download | ansible-ebf971f931290a113f738f658d7a6e095994e120.tar.gz |
Don't use getattr in _get_parent_attribute to avoid recursion issues (#33595)
* Don't use getattr in _get_parent_attribute to avoid recursion issues
Fixes #23609
* Move extend/prepend to field attribute
Also removes _get_attr* methods that were basically just calling
_get_parent_attribute because it needed to set those params.
Also modifies _get_parent_attribute() to pull those values from the
FieldAttributes instead of using the ones passed into the function.
* Better fixes for _get_parent_attribute
Diffstat (limited to 'lib/ansible/playbook/base.py')
-rw-r--r-- | lib/ansible/playbook/base.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py index 878db4820b..d949a53331 100644 --- a/lib/ansible/playbook/base.py +++ b/lib/ansible/playbook/base.py @@ -48,12 +48,13 @@ def _generic_g_method(prop_name, self): def _generic_g_parent(prop_name, self): try: - value = self._attributes[prop_name] - if value is None and not self._squashed and not self._finalized: + if self._squashed or self._finalized: + value = self._attributes[prop_name] + else: try: value = self._get_parent_attribute(prop_name) except AttributeError: - pass + value = self._attributes[prop_name] except KeyError: raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, prop_name)) @@ -152,7 +153,7 @@ class Base(with_metaclass(BaseMeta, object)): _vars = FieldAttribute(isa='dict', priority=100, inherit=False) # flags and misc. settings - _environment = FieldAttribute(isa='list') + _environment = FieldAttribute(isa='list', extend=True, prepend=True) _no_log = FieldAttribute(isa='bool') _always_run = FieldAttribute(isa='bool') _run_once = FieldAttribute(isa='bool') |