From 13cc604141a2af116c2807952005c996c00d73ec Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Fri, 27 Oct 2017 23:09:31 +0000 Subject: [PATCH] Ansible keeps adding more fields to _result. Let's just use inclusion rather than exclusion Signed-off-by: Patrick Uiterwijk --- scripts/list-vms-per-host | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/list-vms-per-host b/scripts/list-vms-per-host index 8178aa8dab..def0d9b5c8 100755 --- a/scripts/list-vms-per-host +++ b/scripts/list-vms-per-host @@ -14,6 +14,9 @@ from ansible.cli.adhoc import AdHocCLI class ResultAccumulator(CallbackBase): + CALLBACK_VERSION = 2.0 + CALLBACK_NAME = 'accumulator' + def __init__(self, *args, **kwargs): super(ResultAccumulator, self).__init__(*args, **kwargs) self.unreachable = set() @@ -23,7 +26,12 @@ class ResultAccumulator(CallbackBase): self.unreachable.add(result._host.get_name()) def v2_runner_on_ok(self, result, *args, **kwargs): - for vm in (vm for vm in result._result.keys() if vm not in ('invocation', 'changed') and not vm.startswith('_ansible')): + for vm in result._result.keys(): + if not '.fedoraproject.org' in vm: + # Seemingly, Ansible keeps adding more random keys to the + # result dict every time, so let's just kill the tailing + # once and for all. If it doesn't look like a hostname, ignore. + continue self.host_status[(result._host.get_name(), vm)] = (result._result[vm]['state'], str(result._result[vm]['autostart']))