Skip to content

Commit

Permalink
New module: AWS Network load balancer (ansible#33808)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wimnat authored and gothicx committed May 29, 2018
1 parent 5896d93 commit cb4fb9b
Show file tree
Hide file tree
Showing 12 changed files with 1,095 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/ansible/module_utils/aws/elbv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
except ImportError:
pass
import traceback
import time
from copy import deepcopy


Expand Down Expand Up @@ -262,7 +261,8 @@ def create_elb(self):

def modify_elb_attributes(self):
"""
Update ELB attributes if required
Update Application ELB attributes if required
:return:
"""

Expand Down Expand Up @@ -338,6 +338,7 @@ def __init__(self, connection, connection_ec2, module):

# 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):
"""
Expand All @@ -354,7 +355,7 @@ def create_elb(self):
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:
Expand All @@ -369,16 +370,18 @@ def create_elb(self):

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:
Expand Down

0 comments on commit cb4fb9b

Please sign in to comment.