1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add elb_application_lb tests for modifying listeners (#40716)

This commit is contained in:
Sloane Hertel 2018-05-25 11:16:29 -04:00 committed by GitHub
parent 33e1453d5a
commit 6fb128b235
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,147 @@
- block:
- name: set connection information for all tasks
set_fact:
aws_connection_info: &aws_connection_info
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
security_token: "{{ security_token }}"
region: "{{ aws_region }}"
no_log: yes
- name: add a rule to the listener
elb_application_lb:
name: "{{ alb_name }}"
subnets: "{{ alb_subnets }}"
security_groups: "{{ sec_group.group_id }}"
state: present
listeners:
- Protocol: HTTP
Port: 80
DefaultActions:
- Type: forward
TargetGroupName: "{{ tg_name }}"
Rules:
- Conditions:
- Field: path-pattern
Values:
- '/test'
Priority: '1'
Actions:
- TargetGroupName: "{{ tg_name }}"
Type: forward
<<: *aws_connection_info
register: alb
- assert:
that:
- alb.changed
- alb.listeners[0].rules|length == 2
- name: test replacing the rule with one with the same priority
elb_application_lb:
name: "{{ alb_name }}"
subnets: "{{ alb_subnets }}"
security_groups: "{{ sec_group.group_id }}"
state: present
purge_listeners: true
listeners:
- Protocol: HTTP
Port: 80
DefaultActions:
- Type: forward
TargetGroupName: "{{ tg_name }}"
Rules:
- Conditions:
- Field: path-pattern
Values:
- '/new'
Priority: '1'
Actions:
- TargetGroupName: "{{ tg_name }}"
Type: forward
<<: *aws_connection_info
register: alb
- assert:
that:
- alb.changed
- alb.listeners[0].rules|length == 2
- name: test the rule will not be removed without purge_listeners
elb_application_lb:
name: "{{ alb_name }}"
subnets: "{{ alb_subnets }}"
security_groups: "{{ sec_group.group_id }}"
state: present
listeners:
- Protocol: HTTP
Port: 80
DefaultActions:
- Type: forward
TargetGroupName: "{{ tg_name }}"
<<: *aws_connection_info
register: alb
- assert:
that:
- not alb.changed
- alb.listeners[0].rules|length == 2
- name: remove the rule
elb_application_lb:
name: "{{ alb_name }}"
subnets: "{{ alb_subnets }}"
security_groups: "{{ sec_group.group_id }}"
state: present
purge_listeners: true
listeners:
- Protocol: HTTP
Port: 80
DefaultActions:
- Type: forward
TargetGroupName: "{{ tg_name }}"
Rules: []
<<: *aws_connection_info
register: alb
- assert:
that:
- alb.changed
- alb.listeners[0].rules|length == 1
- name: remove listener from ALB
elb_application_lb:
name: "{{ alb_name }}"
subnets: "{{ alb_subnets }}"
security_groups: "{{ sec_group.group_id }}"
state: present
listeners: []
<<: *aws_connection_info
register: alb
- assert:
that:
- alb.changed
- not alb.listeners
- name: add the listener to the ALB
elb_application_lb:
name: "{{ alb_name }}"
subnets: "{{ alb_subnets }}"
security_groups: "{{ sec_group.group_id }}"
state: present
listeners:
- Protocol: HTTP
Port: 80
DefaultActions:
- Type: forward
TargetGroupName: "{{ tg_name }}"
<<: *aws_connection_info
register: alb
- assert:
that:
- alb.changed
- alb.listeners|length == 1
- alb.availability_zones|length == 2