Fix unit tests and handle versions of Ansible returning non-bool ignore_errors
This is a squashed commit in order to make all tests pass. - Fix fake task result unit test returning a skipped tuple It's meant to be a boolean, not a tuple. Stray comma made it a tuple. - Handler older versions of Ansible returning a non-bool ignore_errors Older versions of Ansible could sometimes return a non-boolean value for ignore_errors. Work around the issue in the callback plugin. Change-Id: If82ec57d8218c704dcd80de39bafb36e611be52c
This commit is contained in:
parent
ea8d54e5be
commit
9b962c5dcb
@ -158,6 +158,13 @@ class CallbackModule(CallbackBase):
|
||||
else:
|
||||
results = jsonutils.loads(self._dump_results(result._result))
|
||||
|
||||
# Ignore errors can be "yes" instead of a proper boolean in <2.3
|
||||
# for some reason
|
||||
ignore_errors = kwargs.get('ignore_errors', False)
|
||||
if LooseVersion(ansible_version) < LooseVersion('2.3.0'):
|
||||
if not isinstance(ignore_errors, bool):
|
||||
ignore_errors = True if ignore_errors == "yes" else False
|
||||
|
||||
self.taskresult = models.TaskResult(
|
||||
task=self.task,
|
||||
host=host,
|
||||
@ -169,7 +176,7 @@ class CallbackModule(CallbackBase):
|
||||
failed=result._result.get('failed', False),
|
||||
skipped=result._result.get('skipped', False),
|
||||
unreachable=result._result.get('unreachable', False),
|
||||
ignore_errors=kwargs.get('ignore_errors', False),
|
||||
ignore_errors=ignore_errors,
|
||||
)
|
||||
|
||||
db.session.add(self.taskresult)
|
||||
|
@ -139,6 +139,7 @@ def ansible_run(complete=True, failed=False, gather_facts=True,
|
||||
host=host,
|
||||
status='ok',
|
||||
changed=True,
|
||||
skipped=skipped,
|
||||
result=msg).model
|
||||
|
||||
data = fakes.Data(playbook=playbook).model
|
||||
@ -151,7 +152,7 @@ def ansible_run(complete=True, failed=False, gather_facts=True,
|
||||
host=host,
|
||||
status='skipped',
|
||||
changed=False,
|
||||
skipped=True,
|
||||
skipped=skipped,
|
||||
result=msg).model
|
||||
task_results.append(record_result)
|
||||
|
||||
@ -176,7 +177,7 @@ def ansible_run(complete=True, failed=False, gather_facts=True,
|
||||
host=host,
|
||||
status='skipped',
|
||||
changed=False,
|
||||
skipped=True,
|
||||
skipped=skipped,
|
||||
result=msg).model
|
||||
task_results.append(failed_result)
|
||||
|
||||
|
@ -212,7 +212,7 @@ class TaskResult(object):
|
||||
self.ignore_errors = ignore_errors
|
||||
self.changed = changed
|
||||
self.failed = failed
|
||||
self.skipped = skipped,
|
||||
self.skipped = skipped
|
||||
self.unreachable = unreachable
|
||||
self.result = result
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user