New module: AWS Network load balancer (#33808)

* New module - elb_network_lb

* Fix creating a load balancer without tags

* Linter

Fix purging tags

Remove extra imports

* add support for cross zone lb, doc update and fix tagging

* pep8 fixes

* Add integration tests for elb_network_lb module

* more pep8

* Remove non-applicable option for NLBs

* fix target protocol

* pep8
This commit is contained in:
Rob 2018-05-25 06:38:34 +10:00 committed by Ryan Brown
commit 858f0fc000
12 changed files with 1095 additions and 8 deletions

View file

@ -13,7 +13,6 @@ try:
except ImportError:
pass
import traceback
import time
from copy import deepcopy
@ -262,7 +261,8 @@ class ApplicationLoadBalancer(ElasticLoadBalancerV2):
def modify_elb_attributes(self):
"""
Update ELB attributes if required
Update Application ELB attributes if required
:return:
"""
@ -338,6 +338,7 @@ class NetworkLoadBalancer(ElasticLoadBalancerV2):
# Ansible module parameters specific to NLBs
self.type = 'network'
self.cross_zone_load_balancing = module.params.get('cross_zone_load_balancing')
def create_elb(self):
"""
@ -354,7 +355,7 @@ class NetworkLoadBalancer(ElasticLoadBalancerV2):
if self.subnets is not None:
params['Subnets'] = self.subnets
params['Scheme'] = self.scheme
if self.tags is not None:
if self.tags:
params['Tags'] = self.tags
try:
@ -369,16 +370,18 @@ class NetworkLoadBalancer(ElasticLoadBalancerV2):
def modify_elb_attributes(self):
"""
Update ELB attributes if required
Update Network ELB attributes if required
:return:
"""
update_attributes = []
if self.deletion_protection and self.elb_attributes['deletion_protection_enabled'] != "true":
update_attributes.append({'Key': 'deletion_protection.enabled', 'Value': "true"})
if self.deletion_protection is not None and not self.deletion_protection and self.elb_attributes['deletion_protection_enabled'] != "false":
update_attributes.append({'Key': 'deletion_protection.enabled', 'Value': "false"})
if self.cross_zone_load_balancing is not None and str(self.cross_zone_load_balancing).lower() != \
self.elb_attributes['load_balancing_cross_zone_enabled']:
update_attributes.append({'Key': 'load_balancing.cross_zone.enabled', 'Value': str(self.cross_zone_load_balancing).lower()})
if self.deletion_protection is not None and str(self.deletion_protection).lower() != self.elb_attributes['deletion_protection_enabled']:
update_attributes.append({'Key': 'deletion_protection.enabled', 'Value': str(self.deletion_protection).lower()})
if update_attributes:
try: