Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Network load balancer #33808

Merged
merged 10 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -14,7 +14,6 @@
except ImportError:
pass
import traceback
import time
from copy import deepcopy


Expand Down Expand Up @@ -263,7 +262,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 @@ -339,6 +339,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 @@ -355,7 +356,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 @@ -370,16 +371,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