From 7237798f2074a7610ad8516a4f1aa81c894020f4 Mon Sep 17 00:00:00 2001 From: Will Rouesnel Date: Tue, 24 Nov 2015 00:30:42 +1100 Subject: [PATCH] docker: Fix state=reloaded to detect default LoggingDriver for docker Previously the logging module hard coded the default logging driver. This means if the docker daemon is started with a different logging driver, the ansible module would continually restart it when run. This fix adds a call to docker.Client.info(), which is inspected if a logging driver is not supplied in the playbook, and the container only restarted if the logging driver applied differs from the configured default. In usage, this has solved issues with using alternative logging drivers. --- cloud/docker/docker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloud/docker/docker.py b/cloud/docker/docker.py index 0ab564208ba..59d961c5d14 100644 --- a/cloud/docker/docker.py +++ b/cloud/docker/docker.py @@ -1017,6 +1017,7 @@ class DockerManager(object): running = self.get_running_containers() current = self.get_inspect_containers(running) + defaults = self.client.info() #Get API version api_version = self.client.version()['ApiVersion'] @@ -1288,7 +1289,7 @@ class DockerManager(object): # LOG_DRIVER if self.ensure_capability('log_driver', False): - expected_log_driver = self.module.params.get('log_driver') or 'json-file' + expected_log_driver = self.module.params.get('log_driver') or defaults['LoggingDriver'] actual_log_driver = container['HostConfig']['LogConfig']['Type'] if actual_log_driver != expected_log_driver: self.reload_reasons.append('log_driver ({0} => {1})'.format(actual_log_driver, expected_log_driver))