diff --git a/changelogs/fragments/826-docker-compose-v2-version.yml b/changelogs/fragments/826-docker-compose-v2-version.yml new file mode 100644 index 00000000..670d0107 --- /dev/null +++ b/changelogs/fragments/826-docker-compose-v2-version.yml @@ -0,0 +1,2 @@ +bugfixes: + - "docker_compose_v2* modules - abort with a nice error message instead of crash when the Docker Compose CLI plugin version is ``dev`` (https://github.com/ansible-collections/community.docker/issues/825, https://github.com/ansible-collections/community.docker/pull/826)." diff --git a/plugins/module_utils/compose_v2.py b/plugins/module_utils/compose_v2.py index 92f10926..dfe4df47 100644 --- a/plugins/module_utils/compose_v2.py +++ b/plugins/module_utils/compose_v2.py @@ -516,6 +516,12 @@ class BaseComposeManager(DockerBaseClass): compose = self.client.get_client_plugin_info('compose') if compose is None: self.client.fail('Docker CLI {0} does not have the compose plugin installed'.format(self.client.get_cli())) + if compose['Version'] == 'dev': + self.client.fail( + 'Docker CLI {0} has a compose plugin installed, but it reports version "dev".' + ' Please use a version of the plugin that returns a proper version.' + .format(self.client.get_cli()) + ) compose_version = compose['Version'].lstrip('v') self.compose_version = LooseVersion(compose_version) if self.compose_version < LooseVersion(min_version):