From 2c95641d66d5ca0eac3bb95d7361a71eb89758d1 Mon Sep 17 00:00:00 2001 From: Steve Spencer Date: Wed, 11 Nov 2015 16:44:01 +0200 Subject: [PATCH] Add support for mounting host volumes with Z and z options --- cloud/docker/docker.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/cloud/docker/docker.py b/cloud/docker/docker.py index 0ecfb93b0c2..12e7851f910 100644 --- a/cloud/docker/docker.py +++ b/cloud/docker/docker.py @@ -80,7 +80,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".' + - 'syntax: C(/host:/container[:mode]) where "mode" may be "rw", "ro", "Z", "z".' default: null volumes_from: description: @@ -626,14 +626,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') @@ -1197,10 +1197,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'