Add support for mounting host volumes with Z and z options

pull/18777/head
Steve Spencer 9 years ago committed by Matt Clay
parent f2f0f83ee6
commit 769d7db1d0

@ -81,8 +81,7 @@ options:
volumes:
description:
- List of volumes to mount within the container using docker CLI-style
- 'syntax: C(/host:/container[:mode]) where "mode" may be "rw" or "ro".'
required: false
- 'syntax: C(/host:/container[:mode]) where "mode" may be "rw", "ro", "Z", "z".'
default: null
volumes_from:
description:
@ -638,14 +637,14 @@ class DockerManager(object):
# host mount (e.g. /mnt:/tmp, bind mounts host's /tmp to /mnt in the container)
elif 2 <= len(parts) <= 3:
# default to read-write
ro = False
mode = 'rw'
# with supplied bind mode
if len(parts) == 3:
if parts[2] not in ['ro', 'rw']:
self.module.fail_json(msg='bind mode needs to either be "ro" or "rw"')
if parts[2] not in ['ro', 'rw', 'z', 'Z']:
self.module.fail_json(msg='bind mode needs to be one of "ro", "rw", "z", or "Z"')
else:
ro = parts[2] == 'ro'
self.binds[parts[0]] = {'bind': parts[1], 'ro': ro }
mode = parts[2]
self.binds[parts[0]] = {'bind': parts[1], 'mode': mode }
else:
self.module.fail_json(msg='volumes support 1 to 3 arguments')
@ -1225,10 +1224,7 @@ class DockerManager(object):
for host_path, config in self.binds.iteritems():
if isinstance(config, dict):
container_path = config['bind']
if config['ro']:
mode = 'ro'
else:
mode = 'rw'
mode = config['mode']
else:
container_path = config
mode = 'rw'

Loading…
Cancel
Save