elb_application_lb purge rules option (#43113)

* Add parameter to keep elb rules

Does not purge elb rules. This is usefull if running the elb_application_lb
 role and there is the desire to keep existing rules.

* Change variable name keep_rules to purge_rules

The descriptor purge has been used in the past.

* Changed default for purge_rules

Default is purge_rules. This is how the module has functioned previously. This change maintains
 the previous behavior.

* Add integration test for purge_rules flag

* Change wording of test task

* Fix merge conflcit

* Changed default for purge_rules

Default is purge_rules. This is how the module has functioned previously. This change maintains
 the previous behavior.

* merge conflcit

* Change wording of test task

* Add purge_rules option to test

* Change test description wording

* Expand purge_rules documentation

* Clarifies documentation for purge_rules option
This commit is contained in:
mjmayer 2018-07-25 03:55:34 -07:00 committed by Will Thames
parent 577306e74b
commit a488b3a8ed
2 changed files with 43 additions and 5 deletions

View file

@ -119,6 +119,12 @@ options:
description:
- The time in seconds to use in conjunction with I(wait).
version_added: 2.6
purge_rules:
description:
- When set to no, keep the existing load balancer rules in place. Will modify and add, but will not delete.
default: yes
type: bool
version_added: 2.7
extends_documentation_fragment:
- aws
- ec2
@ -444,10 +450,11 @@ def create_or_update_elb(elb_obj):
rules_to_add, rules_to_modify, rules_to_delete = rules_obj.compare_rules()
# Delete rules
for rule in rules_to_delete:
rule_obj = ELBListenerRule(elb_obj.connection, elb_obj.module, {'RuleArn': rule}, rules_obj.listener_arn)
rule_obj.delete()
elb_obj.changed = True
if elb_obj.module.params['purge_rules']:
for rule in rules_to_delete:
rule_obj = ELBListenerRule(elb_obj.connection, elb_obj.module, {'RuleArn': rule}, rules_obj.listener_arn)
rule_obj.delete()
elb_obj.changed = True
# Add rules
for rule in rules_to_add:
@ -524,7 +531,8 @@ def main():
state=dict(choices=['present', 'absent'], type='str'),
tags=dict(type='dict'),
wait_timeout=dict(type='int'),
wait=dict(default=False, type='bool')
wait=dict(default=False, type='bool'),
purge_rules=dict(default=True, type='bool')
)
)