docker_*: always use client.fail() over module.fail_json(), allow to always return data on failure (#51999)

* Always use client.fail() instead of module.fail_json().

* Allow to pass on results on module failure.

* Linting.
This commit is contained in:
Felix Fontein 2019-02-13 20:10:23 +01:00 committed by ansibot
commit d7fd4d0550
12 changed files with 64 additions and 60 deletions

View file

@ -180,7 +180,7 @@ class DockerSwarmManager(DockerBaseClass):
try:
return self.client.inspect_swarm()
except APIError as exc:
self.client.fail_json(msg="Error inspecting docker swarm: %s" % to_native(exc))
self.client.fail("Error inspecting docker swarm: %s" % to_native(exc))
def get_docker_items_list(self, docker_object=None, filters=None):
items = None
@ -194,8 +194,8 @@ class DockerSwarmManager(DockerBaseClass):
elif docker_object == 'services':
items = self.client.services(filters=filters)
except APIError as exc:
self.client.fail_json(msg="Error inspecting docker swarm for object '%s': %s" %
(docker_object, to_native(exc)))
self.client.fail("Error inspecting docker swarm for object '%s': %s" %
(docker_object, to_native(exc)))
if self.verbose_output:
return items