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:
parent
577306e74b
commit
a488b3a8ed
2 changed files with 43 additions and 5 deletions
|
@ -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')
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -88,6 +88,36 @@
|
|||
- not alb.changed
|
||||
- alb.listeners[0].rules|length == 2
|
||||
|
||||
- name: test a rule can be added and other rules will not be removed when purge_rules is no.
|
||||
elb_application_lb:
|
||||
name: "{{ alb_name }}"
|
||||
subnets: "{{ alb_subnets }}"
|
||||
security_groups: "{{ sec_group.group_id }}"
|
||||
state: present
|
||||
purge_rules: no
|
||||
listeners:
|
||||
- Protocol: HTTP
|
||||
Port: 80
|
||||
DefaultActions:
|
||||
- Type: forward
|
||||
TargetGroupName: "{{ tg_name }}"
|
||||
Rules:
|
||||
- Conditions:
|
||||
- Field: path-pattern
|
||||
Values:
|
||||
- '/new'
|
||||
Priority: '2'
|
||||
Actions:
|
||||
- TargetGroupName: "{{ tg_name }}"
|
||||
Type: forward
|
||||
<<: *aws_connection_info
|
||||
register: alb
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- alb.changed
|
||||
- alb.listeners[0].rules|length == 3
|
||||
|
||||
- name: remove the rule
|
||||
elb_application_lb:
|
||||
name: "{{ alb_name }}"
|
||||
|
|
Loading…
Reference in a new issue