From cffb2bdee9cf28f1bb54e99618b4f19a3e7a3add Mon Sep 17 00:00:00 2001 From: Brandon W Maister Date: Mon, 6 Oct 2014 10:49:22 -0400 Subject: [PATCH] Add `cache_subnet_group` to elasticache module According to the [docs] cache subnet groups are required inside a VPC. [docs]: http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/CacheSubnetGroups.html --- lib/ansible/modules/cloud/amazon/elasticache.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/elasticache.py b/lib/ansible/modules/cloud/amazon/elasticache.py index 4e76d593cc9..cb5a790a3cf 100644 --- a/lib/ansible/modules/cloud/amazon/elasticache.py +++ b/lib/ansible/modules/cloud/amazon/elasticache.py @@ -58,6 +58,12 @@ options: - The port number on which each of the cache nodes will accept connections required: false default: 11211 + cache_subnet_group: + description: + - The subnet group name to associate with. Only use if inside a vpc. Required if inside a vpc + required: conditional + default: None + version_added: "1.7" security_group_ids: description: - A list of vpc security group names to associate with this cache cluster. Only use if inside a vpc @@ -66,7 +72,7 @@ options: version_added: "1.6" cache_security_groups: description: - - A list of cache security group names to associate with this cache cluster + - A list of cache security group names to associate with this cache cluster. Must be an empty list if inside a vpc required: false default: ['default'] zone: @@ -155,7 +161,8 @@ class ElastiCacheManager(object): EXIST_STATUSES = ['available', 'creating', 'rebooting', 'modifying'] def __init__(self, module, name, engine, cache_engine_version, node_type, - num_nodes, cache_port, cache_security_groups, security_group_ids, zone, wait, + num_nodes, cache_port, cache_subnet_group, + cache_security_groups, security_group_ids, zone, wait, hard_modify, aws_access_key, aws_secret_key, region): self.module = module self.name = name @@ -164,6 +171,7 @@ class ElastiCacheManager(object): self.node_type = node_type self.num_nodes = num_nodes self.cache_port = cache_port + self.cache_subnet_group = cache_subnet_group self.cache_security_groups = cache_security_groups self.security_group_ids = security_group_ids self.zone = zone @@ -222,6 +230,7 @@ class ElastiCacheManager(object): engine_version=self.cache_engine_version, cache_security_group_names=self.cache_security_groups, security_group_ids=self.security_group_ids, + cache_subnet_group_name=self.cache_subnet_group, preferred_availability_zone=self.zone, port=self.cache_port) except boto.exception.BotoServerError, e: @@ -484,6 +493,7 @@ def main(): node_type={'required': False, 'default': 'cache.m1.small'}, 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'], 'type': 'list'}, security_group_ids={'required': False, 'default': [], @@ -507,6 +517,7 @@ def main(): node_type = module.params['node_type'] num_nodes = module.params['num_nodes'] cache_port = module.params['cache_port'] + cache_subnet_group = module.params['cache_subnet_group'] cache_security_groups = module.params['cache_security_groups'] security_group_ids = module.params['security_group_ids'] zone = module.params['zone'] @@ -522,6 +533,7 @@ def main(): elasticache_manager = ElastiCacheManager(module, name, engine, cache_engine_version, node_type, num_nodes, cache_port, + cache_subnet_group, cache_security_groups, security_group_ids, zone, wait, hard_modify, aws_access_key,