diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index 24e86813df..e40f136024 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -844,14 +844,14 @@ class TaskParameters(DockerBaseClass): if ':' in vol: if len(vol.split(':')) == 3: host, container, mode = vol.split(':') - if re.match(r'[\.~]', host): - host = os.path.abspath(host) + if re.match(r'[.~]', host): + host = os.path.abspath(os.path.expanduser(host)) new_vols.append("%s:%s:%s" % (host, container, mode)) continue elif len(vol.split(':')) == 2: parts = vol.split(':') - if parts[1] not in VOLUME_PERMISSIONS and re.match(r'[\.~]', parts[0]): - host = os.path.abspath(parts[0]) + if parts[1] not in VOLUME_PERMISSIONS and re.match(r'[.~]', parts[0]): + host = os.path.abspath(os.path.expanduser(parts[0])) new_vols.append("%s:%s:rw" % (host, parts[1])) continue new_vols.append(vol) diff --git a/test/sanity/code-smell/use-argspec-type-path.py b/test/sanity/code-smell/use-argspec-type-path.py index e0315f081a..4c23cb3820 100755 --- a/test/sanity/code-smell/use-argspec-type-path.py +++ b/test/sanity/code-smell/use-argspec-type-path.py @@ -7,6 +7,7 @@ import sys def main(): skip = set([ # add legitimate uses of expanduser to the following list + 'lib/ansible/modules/cloud/docker/docker_container.py', # uses colon-separated paths, can't use type=path 'lib/ansible/modules/cloud/lxc/lxc_container.py', 'lib/ansible/modules/cloud/rackspace/rax_files_objects.py', 'lib/ansible/modules/database/mongodb/mongodb_parameter.py',