[cloud] Only get rules if listener in elb_application_lb been identified in compare_rules (#30604)
* Only get rules if listener has been identified in compare_rules * Always cast the listener port to an integer. (cherry picked from commit 7cdaa3089ed2053f6fcfcea524a0322f40a2a822)
This commit is contained in:
parent
25eb9154e9
commit
19c6fe9a78
1 changed files with 14 additions and 6 deletions
|
@ -615,6 +615,8 @@ def compare_listeners(connection, module, current_listeners, new_listeners, purg
|
|||
Compare listeners and return listeners to add, listeners to modify and listeners to remove
|
||||
Listeners are compared based on port
|
||||
|
||||
:param connection: ELBv2 boto3 connection
|
||||
:param module: Ansible module object
|
||||
:param current_listeners:
|
||||
:param new_listeners:
|
||||
:param purge_listeners:
|
||||
|
@ -655,10 +657,10 @@ def compare_rules(connection, module, current_listeners, listener):
|
|||
Compare rules and return rules to add, rules to modify and rules to remove
|
||||
Rules are compared based on priority
|
||||
|
||||
:param connection:
|
||||
:param module:
|
||||
:param current_listeners:
|
||||
:param listener:
|
||||
:param connection: ELBv2 boto3 connection
|
||||
:param module: Ansible module object
|
||||
:param current_listeners: list of listeners currently associated with the ELB
|
||||
:param listener: dict object of a listener passed by the user
|
||||
:return:
|
||||
"""
|
||||
|
||||
|
@ -668,8 +670,11 @@ def compare_rules(connection, module, current_listeners, listener):
|
|||
listener['ListenerArn'] = current_listener['ListenerArn']
|
||||
break
|
||||
|
||||
# Get rules for the listener
|
||||
# If the listener exists (i.e. has an ARN) get rules for the listener
|
||||
if 'ListenerArn' in listener:
|
||||
current_rules = get_listener_rules(connection, module, listener['ListenerArn'])
|
||||
else:
|
||||
current_rules = []
|
||||
|
||||
rules_to_modify = []
|
||||
rules_to_delete = []
|
||||
|
@ -993,6 +998,9 @@ def main():
|
|||
if key not in ['Protocol', 'Port', 'SslPolicy', 'Certificates', 'DefaultActions', 'Rules']:
|
||||
module.fail_json(msg="listeners parameter contains invalid dict keys. Should be one of 'Protocol', "
|
||||
"'Port', 'SslPolicy', 'Certificates', 'DefaultActions', 'Rules'.")
|
||||
# Make sure Port is always an integer
|
||||
elif key == 'Port':
|
||||
listener[key] = int(listener[key])
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 required for this module')
|
||||
|
|
Loading…
Reference in a new issue