elb_application_lb: when purging rules make deletion the first step (#28749)
This prevents errors when adding new rules that conflict with existing ones that will be deleted. For example this allows adding a new rule with the same priority of a rule that will be purged.
This commit is contained in:
parent
d69c803353
commit
d343a3abd1
1 changed files with 8 additions and 8 deletions
|
@ -755,6 +755,14 @@ def create_or_update_elb_listeners(connection, module, elb):
|
|||
# Get listener based on port so we can use ARN
|
||||
looked_up_listener = get_listener(connection, module, elb['LoadBalancerArn'], listener['Port'])
|
||||
|
||||
# Delete rules
|
||||
for rule in rules_to_delete:
|
||||
try:
|
||||
connection.delete_rule(RuleArn=rule)
|
||||
listener_changed = True
|
||||
except ClientError as e:
|
||||
module.fail_json(msg=e.message, exception=traceback.format_exc(), **camel_dict_to_snake_dict(e.response))
|
||||
|
||||
# Add rules
|
||||
for rule in rules_to_add:
|
||||
try:
|
||||
|
@ -774,14 +782,6 @@ def create_or_update_elb_listeners(connection, module, elb):
|
|||
except ClientError as e:
|
||||
module.fail_json(msg=e.message, exception=traceback.format_exc(), **camel_dict_to_snake_dict(e.response))
|
||||
|
||||
# Delete rules
|
||||
for rule in rules_to_delete:
|
||||
try:
|
||||
connection.delete_rule(RuleArn=rule)
|
||||
listener_changed = True
|
||||
except ClientError as e:
|
||||
module.fail_json(msg=e.message, exception=traceback.format_exc(), **camel_dict_to_snake_dict(e.response))
|
||||
|
||||
return listener_changed
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue