From eaacf6c8f62c48f430f463720aad2d1eaf8b1f72 Mon Sep 17 00:00:00 2001 From: Shane St Savage Date: Sun, 24 Apr 2022 12:39:59 -0700 Subject: [PATCH] Support getting container output from local logging driver (#337) The `local` [Docker logging driver](https://docs.docker.com/config/containers/logging/local/) is a new-ish, optimized local logging driver that improves upon json-file. Since logs written using `local` can still be accessed through the Docker daemon API, all that is needed here is to add to the supported list. --- .../337-container-output-from-local-logging-driver.yml | 2 ++ plugins/modules/docker_container.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/337-container-output-from-local-logging-driver.yml diff --git a/changelogs/fragments/337-container-output-from-local-logging-driver.yml b/changelogs/fragments/337-container-output-from-local-logging-driver.yml new file mode 100644 index 00000000..1757e165 --- /dev/null +++ b/changelogs/fragments/337-container-output-from-local-logging-driver.yml @@ -0,0 +1,2 @@ +minor_changes: + - "docker_container - support returning Docker container log output when using Docker's ``local`` logging driver, an optimized local logging driver introduced in Docker 18.09 (https://github.com/ansible-collections/community.docker/pull/337)." diff --git a/plugins/modules/docker_container.py b/plugins/modules/docker_container.py index 78c1d061..dc83f4ea 100644 --- a/plugins/modules/docker_container.py +++ b/plugins/modules/docker_container.py @@ -643,7 +643,7 @@ options: output_logs: description: - If set to true, output of the container command will be printed. - - Only effective when I(log_driver) is set to C(json-file) or C(journald). + - Only effective when I(log_driver) is set to C(json-file), C(journald), or C(local). type: bool default: no paused: @@ -3142,7 +3142,7 @@ class ContainerManager(DockerBaseClass): config = self.client.inspect_container(container_id) logging_driver = config['HostConfig']['LogConfig']['Type'] - if logging_driver in ('json-file', 'journald'): + if logging_driver in ('json-file', 'journald', 'local'): output = self.client.logs(container_id, stdout=True, stderr=True, stream=False, timestamps=False) if self.parameters.output_logs: self._output_logs(msg=output)