diff --git a/lib/ansible/plugins/action/include_vars.py b/lib/ansible/plugins/action/include_vars.py index c7283d14f7..9eecf94dd9 100644 --- a/lib/ansible/plugins/action/include_vars.py +++ b/lib/ansible/plugins/action/include_vars.py @@ -26,13 +26,19 @@ class ActionModule(ActionBase): TRANSFERS_FILES = False def run(self, tmp=None, task_vars=None): + + varname = self._task.args.get('name') + source = self._task.args.get('file') + if not source: + source = self._task.args.get('_raw_params') + if task_vars is None: task_vars = dict() result = super(ActionModule, self).run(tmp, task_vars) try: - source = self._find_needle('vars', self._task.args.get('_raw_params')) + source = self._find_needle('vars', source) except AnsibleError as e: result['failed'] = True result['message'] = to_str(e) @@ -46,6 +52,10 @@ class ActionModule(ActionBase): result['failed'] = True result['message'] = "%s must be stored as a dictionary/hash" % source else: + if varname: + scope = {} + scope[varname] = data + data = scope result['ansible_facts'] = data result['_ansible_no_log'] = not show_content