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.
This commit is contained in:
Brandon W Maister 2015-03-12 15:14:14 -04:00 committed by Matt Clay
parent ad248376b1
commit c1571928e5

View file

@ -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")