From b0c10a7d31f0e632b3d115493d0a718291e19291 Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Thu, 22 Oct 2015 21:41:17 -0400 Subject: [PATCH] allow os_server to accept a list of security groups This commit allows the `security_groups` parameter of the `os_server` module to be either a YAML list or a common-delimited string (much like the `nics` attribute). E.g., this: - os_nova_server: [...] security_groups: - default - webserver Or this: - os_nova_server: [...] security_groups: default,webserver --- cloud/openstack/os_server.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cloud/openstack/os_server.py b/cloud/openstack/os_server.py index aa06899213f..189840e2498 100644 --- a/cloud/openstack/os_server.py +++ b/cloud/openstack/os_server.py @@ -76,7 +76,8 @@ options: default: None security_groups: description: - - The name of the security group to which the instance should be added + - Names of the security groups to which the instance should be + added. This may be a YAML list or a common separated string. required: false default: None nics: @@ -366,7 +367,7 @@ def _create_server(module, cloud): flavor=flavor_dict['id'], nics=nics, meta=module.params['meta'], - security_groups=module.params['security_groups'].split(','), + security_groups=module.params['security_groups'], userdata=module.params['userdata'], config_drive=module.params['config_drive'], ) @@ -459,7 +460,7 @@ def main(): flavor_ram = dict(default=None, type='int'), flavor_include = dict(default=None), key_name = dict(default=None), - security_groups = dict(default='default'), + security_groups = dict(default=['default'], type='list'), nics = dict(default=[], type='list'), meta = dict(default=None), userdata = dict(default=None),