Moving ConnectionInformation -> PlayContext

Also making PlayContext a child class of the Playbook Base class,
which gives it access to all of the FieldAttribute code to ensure
field values are correctly typed after post_validation

Fixes #11381
This commit is contained in:
James Cammarata 2015-07-21 12:12:22 -04:00
parent 919aaa5c42
commit e64989beb4
36 changed files with 477 additions and 459 deletions

View file

@ -34,6 +34,7 @@ from ansible.playbook.block import Block
from ansible.playbook.conditional import Conditional
from ansible.playbook.role import Role
from ansible.playbook.taggable import Taggable
from ansible.utils.vars import combine_vars
__all__ = ['Task']
@ -292,22 +293,38 @@ class Task(Base, Conditional, Taggable, Become):
if self._task_include:
self._task_include.set_loader(loader)
def _get_parent_attribute(self, attr, extend=False):
def _get_parent_attribute(self, attr, extend=False, combine=False):
'''
Generic logic to get the attribute or parent attribute for a task value.
'''
value = self._attributes[attr]
if self._block and (value is None or extend):
if self._block and (value is None or extend or combine):
parent_value = getattr(self._block, attr)
if extend:
value = self._extend_value(value, parent_value)
elif combine and isinstance(parent_value, dict) and isinstance(value, dict):
value = combine_vars(parent_value, value)
else:
value = parent_value
if self._task_include and (value is None or extend):
if self._task_include and (value is None or extend or combine):
parent_value = getattr(self._task_include, attr)
if extend:
value = self._extend_value(value, parent_value)
elif combine:
value = combine_vars(parent_value, value)
else:
value = parent_value
return value
def _get_attr_environment(self):
'''
Override for the 'tags' getattr fetcher, used from Base.
'''
environment = self._attributes['tags']
if environment is None:
environment = dict()
environment = self._get_parent_attribute('environment', combine=True)
return environment