From 98c86c54cdd0909a5ac1d47684305e96e16c1433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadej=20Borov=C5=A1ak?= Date: Sun, 28 Feb 2021 23:22:36 +0100 Subject: [PATCH] Inform synchronize module about community.docker collection The synchronize action plugin has a built-in list of connection plugins that it knows how to handle. One of those connection plugins is the docker connection plugin. And because the docker content has been moved around quite a lot, the docker connection plugin has quite a few names: - docker in Ansible 2.9, - community.general.docker for community.general < 2.0.0, and - community.docker.docker since a few months ago. And while the synchronize module already knew about the first two names, the last one was still missing. This commit fixes that omission and adds a third name into the mix. --- ...dd_community_docker_connection_plugin_alias.yml | 4 ++++ plugins/action/synchronize.py | 14 ++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/144_add_community_docker_connection_plugin_alias.yml diff --git a/changelogs/fragments/144_add_community_docker_connection_plugin_alias.yml b/changelogs/fragments/144_add_community_docker_connection_plugin_alias.yml new file mode 100644 index 0000000000..345b777b12 --- /dev/null +++ b/changelogs/fragments/144_add_community_docker_connection_plugin_alias.yml @@ -0,0 +1,4 @@ +--- +bugfixes: + - synchronize - add ``community.docker.docker`` to the list of supported + transports (https://github.com/ansible-collections/ansible.posix/issues/132). diff --git a/plugins/action/synchronize.py b/plugins/action/synchronize.py index 9fa43e8c65..f0c21e6704 100644 --- a/plugins/action/synchronize.py +++ b/plugins/action/synchronize.py @@ -60,7 +60,7 @@ def _format_rsync_rsh_target(self, host, path, user): return path # If using docker or buildah, do not add user information - if self._remote_transport not in ['docker', 'community.general.docker', 'buildah', 'containers.podman.buildah'] and user: + if self._remote_transport not in ['docker', 'community.general.docker', 'community.docker.docker', 'buildah', 'containers.podman.buildah'] and user: user_prefix = '%s@' % (user, ) if self._host_is_ipv6_address(host): @@ -170,7 +170,7 @@ def run(self, tmp=None, task_vars=None): self._remote_transport = self._connection.transport # Handle docker connection options - if self._remote_transport in ['docker', 'community.general.docker']: + if self._remote_transport in ['docker', 'community.general.docker', 'community.docker.docker']: self._docker_cmd = self._connection.docker_cmd if self._play_context.docker_extra_args: self._docker_cmd = "%s %s" % (self._docker_cmd, self._play_context.docker_extra_args) @@ -192,7 +192,7 @@ def run(self, tmp=None, task_vars=None): # ssh paramiko docker buildah and local are fully supported transports. Anything # else only works with delegate_to if delegate_to is None and self._connection.transport not in \ - ('ssh', 'paramiko', 'local', 'docker', 'community.general.docker', 'buildah', 'containers.podman.buildah'): + ('ssh', 'paramiko', 'local', 'docker', 'community.general.docker', 'community.docker.docker', 'buildah', 'containers.podman.buildah'): result['failed'] = True result['msg'] = ( "synchronize uses rsync to function. rsync needs to connect to the remote " @@ -365,7 +365,7 @@ def run(self, tmp=None, task_vars=None): if not dest_is_local: # don't escalate for docker. doing --rsync-path with docker exec fails # and we can switch directly to the user via docker arguments - if self._play_context.become and not rsync_path and self._remote_transport not in ['docker', 'community.general.docker']: + if self._play_context.become and not rsync_path and self._remote_transport not in ['docker', 'community.general.docker', 'community.docker.docker']: # If no rsync_path is set, become was originally set, and dest is # remote then add privilege escalation here. if self._play_context.become_method == 'sudo': @@ -389,7 +389,9 @@ def run(self, tmp=None, task_vars=None): # If launching synchronize against docker container # use rsync_opts to support container to override rsh options - if self._remote_transport in ['docker', 'community.general.docker', 'buildah', 'containers.podman.buildah'] and not use_delegate: + if self._remote_transport in [ + 'docker', 'community.general.docker', 'community.docker.docker', 'buildah', 'containers.podman.buildah' + ] and not use_delegate: # Replicate what we do in the module argumentspec handling for lists if not isinstance(_tmp_args.get('rsync_opts'), MutableSequence): tmp_rsync_opts = _tmp_args.get('rsync_opts', []) @@ -402,7 +404,7 @@ def run(self, tmp=None, task_vars=None): if '--blocking-io' not in _tmp_args['rsync_opts']: _tmp_args['rsync_opts'].append('--blocking-io') - if self._remote_transport in ['docker', 'community.general.docker']: + if self._remote_transport in ['docker', 'community.general.docker', 'community.docker.docker']: if become and self._play_context.become_user: _tmp_args['rsync_opts'].append("--rsh=%s exec -u %s -i" % (self._docker_cmd, self._play_context.become_user)) elif user is not None: