From 87ce5cd603b9ae208f69cf21da83830efc3a7e47 Mon Sep 17 00:00:00 2001 From: Pavel Glushchak Date: Mon, 24 Apr 2017 15:22:35 +0300 Subject: [PATCH] kolla_toolbox: allow docker api version to be specified When docker-py is newer than docker daemon following APIError may be raised: client is newer than server (client API version: 1.24, server API version: 1.22) So it's better to pass api_version='auto' to docker client, so client will discover suitable version if not specified. Change-Id: Ib747ed91b315ca762936a6efa6b71a29b2d2ae1e Signed-off-by: Pavel Glushchak --- ansible/library/kolla_toolbox.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ansible/library/kolla_toolbox.py b/ansible/library/kolla_toolbox.py index 8725434008..56039a5fba 100644 --- a/ansible/library/kolla_toolbox.py +++ b/ansible/library/kolla_toolbox.py @@ -38,6 +38,12 @@ options: - The extra variables used by the module required: False type: str or dict + api_version: + description: + - The version of the API for docker-py to use when contacting Docker + required: False + type: str + default: auto author: Jeffrey Zhang ''' @@ -113,10 +119,12 @@ def main(): specs = dict( module_name=dict(type='str'), module_args=dict(type='str'), - module_extra_vars=dict(type='json') - ) + module_extra_vars=dict(type='json'), + api_version=dict(required=False, type='str', default='auto') + ) module = AnsibleModule(argument_spec=specs, bypass_checks=True) - client = get_docker_client()() + client = get_docker_client()( + version=module.params.get('api_version')) command_line = gen_commandline(module.params) kolla_toolbox = client.containers(filters=dict(name='kolla_toolbox', status='running'))