From c1571928e5d36007767b5f2beb78d924790afb7c Mon Sep 17 00:00:00 2001 From: Brandon W Maister Date: Thu, 12 Mar 2015 15:14:14 -0400 Subject: [PATCH] Make cache_subnet_group default to empty security groups Since they can't be specified together, it seems like setting the default to no security groups is the right option. --- lib/ansible/modules/cloud/amazon/elasticache.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/amazon/elasticache.py b/lib/ansible/modules/cloud/amazon/elasticache.py index cb5a790a3cf..18be34560a5 100644 --- a/lib/ansible/modules/cloud/amazon/elasticache.py +++ b/lib/ansible/modules/cloud/amazon/elasticache.py @@ -485,6 +485,7 @@ class ElastiCacheManager(object): def main(): argument_spec = ec2_argument_spec() + default = object() argument_spec.update(dict( state={'required': True, 'choices': ['present', 'absent', 'rebooted']}, name={'required': True}, @@ -494,7 +495,7 @@ def main(): num_nodes={'required': False, 'default': None, 'type': 'int'}, cache_port={'required': False, 'default': 11211, 'type': 'int'}, cache_subnet_group={'required': False, 'default': None}, - cache_security_groups={'required': False, 'default': ['default'], + cache_security_groups={'required': False, 'default': [default], 'type': 'list'}, security_group_ids={'required': False, 'default': [], 'type': 'list'}, @@ -524,6 +525,14 @@ def main(): wait = module.params['wait'] hard_modify = module.params['hard_modify'] + if cache_subnet_group and cache_security_groups == [default]: + cache_security_groups = [] + if cache_subnet_group and cache_security_groups: + module.fail_json(msg="Can't specify both cache_subnet_group and cache_security_groups") + + if cache_security_groups == [default]: + cache_security_groups = ['default'] + if state == 'present' and not num_nodes: module.fail_json(msg="'num_nodes' is a required parameter. Please specify num_nodes > 0")