diff options
Diffstat (limited to 'lib/ansible/plugins/strategy')
-rw-r--r-- | lib/ansible/plugins/strategy/__init__.py | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index d10ff6f163..27d49fc26b 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -528,16 +528,6 @@ class StrategyBase: self._tqm.send_callback('v2_runner_item_on_ok', task_result) continue - if original_task.register: - host_list = self.get_task_hosts(iterator, original_host, original_task) - - clean_copy = strip_internal_keys(module_response_deepcopy(task_result._result)) - if 'invocation' in clean_copy: - del clean_copy['invocation'] - - for target_host in host_list: - self._variable_manager.set_nonpersistent_facts(target_host, {original_task.register: clean_copy}) - # all host status messages contain 2 entries: (msg, task_result) role_ran = False if task_result.is_failed(): @@ -714,6 +704,17 @@ class StrategyBase: # finally, send the ok for this task self._tqm.send_callback('v2_runner_on_ok', task_result) + # register final results + if original_task.register: + host_list = self.get_task_hosts(iterator, original_host, original_task) + + clean_copy = strip_internal_keys(module_response_deepcopy(task_result._result)) + if 'invocation' in clean_copy: + del clean_copy['invocation'] + + for target_host in host_list: + self._variable_manager.set_nonpersistent_facts(target_host, {original_task.register: clean_copy}) + if do_handlers: self._pending_handler_results -= 1 else: @@ -850,20 +851,20 @@ class StrategyBase: group = self._inventory.groups[group_name] for parent_group_name in parent_group_names: parent_group = self._inventory.groups[parent_group_name] - parent_group.add_child_group(group) + new = parent_group.add_child_group(group) + if new and not changed: + changed = True - if real_host.name not in group.get_hosts(): - group.add_host(real_host) - changed = True + if real_host not in group.get_hosts(): + changed = group.add_host(real_host) - if group_name not in host.get_groups(): - real_host.add_group(group) - changed = True + if group not in real_host.get_groups(): + changed = real_host.add_group(group) if changed: self._inventory.reconcile_inventory() - return changed + result_item['changed'] = changed def _copy_included_file(self, included_file): ''' |