From b3262479e97a6c1936d9e92ec2c8dbe29fc14d16 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 4 Sep 2015 15:59:19 -0700 Subject: [PATCH] Fix read-only usage to depend on the docker-py and docker server version --- lib/ansible/modules/cloud/docker/docker.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/cloud/docker/docker.py b/lib/ansible/modules/cloud/docker/docker.py index f9ab4277348..9a4ab47401f 100644 --- a/lib/ansible/modules/cloud/docker/docker.py +++ b/lib/ansible/modules/cloud/docker/docker.py @@ -273,7 +273,7 @@ options: read_only: description: - Mount the container's root filesystem as read only - default: false + default: null aliases: [] version_added: "2.0" restart_policy: @@ -801,13 +801,12 @@ class DockerManager(object): 'privileged': self.module.params.get('privileged'), 'links': self.links, 'network_mode': self.module.params.get('net'), - 'read_only': self.module.params.get('read_only'), } optionals = {} for optional_param in ('dns', 'volumes_from', 'restart_policy', 'restart_policy_retry', 'pid', 'extra_hosts', 'log_driver', - 'cap_add', 'cap_drop'): + 'cap_add', 'cap_drop', 'read_only'): optionals[optional_param] = self.module.params.get(optional_param) if optionals['dns'] is not None: @@ -850,6 +849,10 @@ class DockerManager(object): self.ensure_capability('cap_drop') params['cap_drop'] = optionals['cap_drop'] + if optionals['read_only'] is not None: + self.ensure_capability('read_only') + params['read_only'] = optionals['read_only'] + return params def create_host_config(self): @@ -1645,7 +1648,7 @@ def main(): cpu_set = dict(default=None), cap_add = dict(default=None, type='list'), cap_drop = dict(default=None, type='list'), - read_only = dict(default=False, type='bool'), + read_only = dict(default=None, type='bool'), ), required_together = ( ['tls_client_cert', 'tls_client_key'],