add idle_timeout support
This commit is contained in:
parent
4a8bd74f52
commit
f90bcfee1f
1 changed files with 28 additions and 4 deletions
|
@ -109,6 +109,12 @@ options:
|
|||
required: false
|
||||
aliases: []
|
||||
version_added: "1.8"
|
||||
idle_timeout:
|
||||
description:
|
||||
- ELB connections from clients and to servers are timed out after this amount of time
|
||||
required: false
|
||||
aliases: []
|
||||
version_added: "2.0"
|
||||
cross_az_load_balancing:
|
||||
description:
|
||||
- Distribute load across all configured Availablity Zones
|
||||
|
@ -241,13 +247,14 @@ EXAMPLES = """
|
|||
load_balancer_port: 80
|
||||
instance_port: 80
|
||||
|
||||
# Create an ELB with connection draining and cross availability
|
||||
# Create an ELB with connection draining, increased idle timeout and cross availability
|
||||
# zone load balancing
|
||||
- local_action:
|
||||
module: ec2_elb_lb
|
||||
name: "New ELB"
|
||||
state: present
|
||||
connection_draining_timeout: 60
|
||||
idle_timeout: 300
|
||||
cross_az_load_balancing: "yes"
|
||||
region: us-east-1
|
||||
zones:
|
||||
|
@ -314,7 +321,7 @@ class ElbManager(object):
|
|||
zones=None, purge_zones=None, security_group_ids=None,
|
||||
health_check=None, subnets=None, purge_subnets=None,
|
||||
scheme="internet-facing", connection_draining_timeout=None,
|
||||
cross_az_load_balancing=None, access_logs=None,
|
||||
idle_timeout, cross_az_load_balancing=None, access_logs=None,
|
||||
stickiness=None, region=None, **aws_connect_params):
|
||||
|
||||
self.module = module
|
||||
|
@ -329,6 +336,7 @@ class ElbManager(object):
|
|||
self.purge_subnets = purge_subnets
|
||||
self.scheme = scheme
|
||||
self.connection_draining_timeout = connection_draining_timeout
|
||||
self.idle_timeout = idle_timeout
|
||||
self.cross_az_load_balancing = cross_az_load_balancing
|
||||
self.access_logs = access_logs
|
||||
self.stickiness = stickiness
|
||||
|
@ -357,6 +365,8 @@ class ElbManager(object):
|
|||
# set them to avoid errors
|
||||
if self._check_attribute_support('connection_draining'):
|
||||
self._set_connection_draining_timeout()
|
||||
if self._check_attribute_support('connecting_settings'):
|
||||
self._set_idle_timeout()
|
||||
if self._check_attribute_support('cross_zone_load_balancing'):
|
||||
self._set_cross_az_load_balancing()
|
||||
if self._check_attribute_support('access_log'):
|
||||
|
@ -454,6 +464,9 @@ class ElbManager(object):
|
|||
if self._check_attribute_support('connection_draining'):
|
||||
info['connection_draining_timeout'] = self.elb_conn.get_lb_attribute(self.name, 'ConnectionDraining').timeout
|
||||
|
||||
if self._check_attribute_support('connecting_settings'):
|
||||
info['idle_timeout'] = self.elb_conn.get_lb_attribute(self.name, 'ConnectingSettings').idle_timeout
|
||||
|
||||
if self._check_attribute_support('cross_zone_load_balancing'):
|
||||
is_cross_az_lb_enabled = self.elb_conn.get_lb_attribute(self.name, 'CrossZoneLoadBalancing')
|
||||
if is_cross_az_lb_enabled:
|
||||
|
@ -743,6 +756,12 @@ class ElbManager(object):
|
|||
attributes.connection_draining.enabled = False
|
||||
self.elb_conn.modify_lb_attribute(self.name, 'ConnectionDraining', attributes.connection_draining)
|
||||
|
||||
def _set_idle_timeout(self):
|
||||
attributes = self.elb.get_attributes()
|
||||
if self.idle_timeout is not None:
|
||||
attributes.connecting_settings.idle_timeout = self.idle_timeout
|
||||
self.elb_conn.modify_lb_attribute(self.name, 'ConnectingSettings', attributes.connecting_settings)
|
||||
|
||||
def _policy_name(self, policy_type):
|
||||
return __file__.split('/')[-1].replace('_', '-') + '-' + policy_type
|
||||
|
||||
|
@ -867,6 +886,7 @@ def main():
|
|||
purge_subnets={'default': False, 'required': False, 'type': 'bool'},
|
||||
scheme={'default': 'internet-facing', 'required': False},
|
||||
connection_draining_timeout={'default': None, 'required': False},
|
||||
idle_timeout={'default': None, 'required': False},
|
||||
cross_az_load_balancing={'default': None, 'required': False},
|
||||
stickiness={'default': None, 'required': False, 'type': 'dict'},
|
||||
access_logs={'default': None, 'required': False, 'type': 'dict'}
|
||||
|
@ -899,6 +919,7 @@ def main():
|
|||
purge_subnets = module.params['purge_subnets']
|
||||
scheme = module.params['scheme']
|
||||
connection_draining_timeout = module.params['connection_draining_timeout']
|
||||
idle_timeout = module.params['idle_timeout']
|
||||
cross_az_load_balancing = module.params['cross_az_load_balancing']
|
||||
stickiness = module.params['stickiness']
|
||||
|
||||
|
@ -926,8 +947,8 @@ def main():
|
|||
elb_man = ElbManager(module, name, listeners, purge_listeners, zones,
|
||||
purge_zones, security_group_ids, health_check,
|
||||
subnets, purge_subnets, scheme,
|
||||
connection_draining_timeout, cross_az_load_balancing,
|
||||
access_logs, stickiness,
|
||||
connection_draining_timeout, idle_timeout,
|
||||
cross_az_load_balancing, access_logs, stickiness,
|
||||
region=region, **aws_connect_params)
|
||||
|
||||
# check for unsupported attributes for this version of boto
|
||||
|
@ -937,6 +958,9 @@ def main():
|
|||
if connection_draining_timeout and not elb_man._check_attribute_support('connection_draining'):
|
||||
module.fail_json(msg="You must install boto >= 2.28.0 to use the connection_draining_timeout attribute")
|
||||
|
||||
if idle_timeout and not elb_man._check_attribute_support('connecting_settings'):
|
||||
module.fail_json(msg="You must install boto >= 2.33.0 to use the idle_timeout attribute")
|
||||
|
||||
if state == 'present':
|
||||
elb_man.ensure_ok()
|
||||
elif state == 'absent':
|
||||
|
|
Loading…
Reference in a new issue