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.
This commit is contained in:
Will Rouesnel 2015-11-24 00:30:42 +11:00 committed by Matt Clay
parent c075c000c8
commit b565da78b3

View file

@ -1081,6 +1081,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']
@ -1398,7 +1399,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))