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.
pull/18777/head
Brandon W Maister 10 years ago committed by Matt Clay
parent ad248376b1
commit c1571928e5

@ -485,6 +485,7 @@ class ElastiCacheManager(object):
def main(): def main():
argument_spec = ec2_argument_spec() argument_spec = ec2_argument_spec()
default = object()
argument_spec.update(dict( argument_spec.update(dict(
state={'required': True, 'choices': ['present', 'absent', 'rebooted']}, state={'required': True, 'choices': ['present', 'absent', 'rebooted']},
name={'required': True}, name={'required': True},
@ -494,7 +495,7 @@ def main():
num_nodes={'required': False, 'default': None, 'type': 'int'}, num_nodes={'required': False, 'default': None, 'type': 'int'},
cache_port={'required': False, 'default': 11211, 'type': 'int'}, cache_port={'required': False, 'default': 11211, 'type': 'int'},
cache_subnet_group={'required': False, 'default': None}, cache_subnet_group={'required': False, 'default': None},
cache_security_groups={'required': False, 'default': ['default'], cache_security_groups={'required': False, 'default': [default],
'type': 'list'}, 'type': 'list'},
security_group_ids={'required': False, 'default': [], security_group_ids={'required': False, 'default': [],
'type': 'list'}, 'type': 'list'},
@ -524,6 +525,14 @@ def main():
wait = module.params['wait'] wait = module.params['wait']
hard_modify = module.params['hard_modify'] 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: if state == 'present' and not num_nodes:
module.fail_json(msg="'num_nodes' is a required parameter. Please specify num_nodes > 0") module.fail_json(msg="'num_nodes' is a required parameter. Please specify num_nodes > 0")

Loading…
Cancel
Save