From 6f1e585da5bf16fe852d062231fca91daf13d375 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 27 Jan 2021 19:56:10 +0100 Subject: [PATCH] Backport of https://github.com/ansible-collections/community.docker/pull/76 to stable-1. (#1689) --- ...ommunity.docker-76-leading-v-support-in-docker-version.yml | 2 ++ plugins/connection/docker.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/community.docker-76-leading-v-support-in-docker-version.yml diff --git a/changelogs/fragments/community.docker-76-leading-v-support-in-docker-version.yml b/changelogs/fragments/community.docker-76-leading-v-support-in-docker-version.yml new file mode 100644 index 0000000000..5ac004d3c5 --- /dev/null +++ b/changelogs/fragments/community.docker-76-leading-v-support-in-docker-version.yml @@ -0,0 +1,2 @@ +bugfixes: + - docker connection plugin - fix Docker version parsing, as some docker versions have a leading ``v`` in the output of the command ``docker version --format "{{.Server.Version}}"`` (https://github.com/ansible-collections/community.docker/pull/76). diff --git a/plugins/connection/docker.py b/plugins/connection/docker.py index 27c87d7265..732620b071 100644 --- a/plugins/connection/docker.py +++ b/plugins/connection/docker.py @@ -116,7 +116,9 @@ class Connection(ConnectionBase): @staticmethod def _sanitize_version(version): - return re.sub(u'[^0-9a-zA-Z.]', u'', version) + version = re.sub(u'[^0-9a-zA-Z.]', u'', version) + version = re.sub(u'^v', u'', version) + return version def _old_docker_version(self): cmd_args = []