summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins/strategy
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2020-06-03 12:46:40 -0400
committerGitHub <noreply@github.com>2020-06-03 12:46:40 -0400
commit22da903e9c4adc9ef2e99c794c5f7abeafa014bd (patch)
tree04cc1211f9d61e49ffd20755640112653d3766c0 /lib/ansible/plugins/strategy
parent2d394382cf136dc1094913aa641f23f992f96864 (diff)
downloadansible-22da903e9c4adc9ef2e99c794c5f7abeafa014bd.tar.gz
return changed for group_by (#32057)
* return changed for group_by * added tests and fixed 'early registeration'
Diffstat (limited to 'lib/ansible/plugins/strategy')
-rw-r--r--lib/ansible/plugins/strategy/__init__.py37
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):
'''