From fb4d065654063c0f29778cb96507285afc2268bf Mon Sep 17 00:00:00 2001 From: Artem Bolshakov Date: Tue, 25 Jul 2017 17:20:29 +0300 Subject: [PATCH] Fix running docker container with not readable logging driver. Fixes #27278 --- lib/ansible/modules/cloud/docker/docker_container.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index a7538d2bf6..18acb6dce8 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -1957,7 +1957,14 @@ class ContainerManager(DockerBaseClass): if not self.parameters.detach: status = self.client.wait(container_id) - output = self.client.logs(container_id, stdout=True, stderr=True, stream=False, timestamps=False) + config = self.client.inspect_container(container_id) + logging_driver = config['HostConfig']['LogConfig']['Type'] + + if logging_driver == 'json-file' or logging_driver == 'journald': + output = self.client.logs(container_id, stdout=True, stderr=True, stream=False, timestamps=False) + else: + output = "Result logged using `%s` driver" % logging_driver + if status != 0: self.fail(output, status=status) if self.parameters.cleanup: