From a3acd2c439da30d52d481a8f526a9a8a96e0b1de Mon Sep 17 00:00:00 2001 From: Jeffrey Zhang Date: Fri, 3 Feb 2017 15:04:04 +0800 Subject: [PATCH] Fix the pid_mode and ipc_mode value check for kolla_docker module bypass_checks is disabled by Ib2e19794bbe804470a880253d5870254041358c8 . But we use pid_mode: "{{ service.pid_mode | default('') }}" pattern in the yaml file. whereas pid_mode only support "host" value, this patch add '' as a choice of these two parameters. Change-Id: Ib83ed5e437ca868f0e42ce740ad1125d2fa48ff4 --- ansible/library/kolla_docker.py | 6 ++++-- tests/test_kolla_docker.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py index a4d57f838a..6f5a940cd6 100644 --- a/ansible/library/kolla_docker.py +++ b/ansible/library/kolla_docker.py @@ -675,6 +675,8 @@ class DockerWorker(object): def generate_module(): + # NOTE(jeffrey4l): add empty string '' to choices let us use + # pid_mode: "{{ service.pid_mode | default ('') }}" in yaml argument_spec = dict( common_options=dict(required=False, type='dict', default=dict()), action=dict(required=True, type='str', @@ -695,10 +697,10 @@ def generate_module(): name=dict(required=False, type='str'), environment=dict(required=False, type='dict'), image=dict(required=False, type='str'), - ipc_mode=dict(required=False, type='str', choices=['host']), + ipc_mode=dict(required=False, type='str', choices=['host', '']), cap_add=dict(required=False, type='list', default=list()), security_opt=dict(required=False, type='list', default=list()), - pid_mode=dict(required=False, type='str', choices=['host']), + pid_mode=dict(required=False, type='str', choices=['host', '']), privileged=dict(required=False, type='bool', default=False), remove_on_exit=dict(required=False, type='bool', default=True), restart_policy=dict(required=False, type='str', choices=[ diff --git a/tests/test_kolla_docker.py b/tests/test_kolla_docker.py index 69e302765d..bc5e910e68 100644 --- a/tests/test_kolla_docker.py +++ b/tests/test_kolla_docker.py @@ -60,10 +60,10 @@ class ModuleArgsTest(base.BaseTestCase): name=dict(required=False, type='str'), environment=dict(required=False, type='dict'), image=dict(required=False, type='str'), - ipc_mode=dict(required=False, type='str', choices=['host']), + ipc_mode=dict(required=False, type='str', choices=['host', '']), cap_add=dict(required=False, type='list', default=list()), security_opt=dict(required=False, type='list', default=list()), - pid_mode=dict(required=False, type='str', choices=['host']), + pid_mode=dict(required=False, type='str', choices=['host', '']), privileged=dict(required=False, type='bool', default=False), remove_on_exit=dict(required=False, type='bool', default=True), restart_policy=dict(