Ansible keeps adding more fields to _result. Let's just use inclusion rather than exclusion

Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
This commit is contained in:
Patrick Uiterwijk 2017-10-27 23:09:31 +00:00
parent cd56887767
commit 13cc604141

View file

@ -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']))