Skip to content

Commit

Permalink
elb_application_lb: test a rule based on http-header (ansible-collect…
Browse files Browse the repository at this point in the history
…ions#347)

* elb_application_lb: test a rule based on http-header

This should initially fail and be fixed the day ansible-collections/amazon.aws#188
is merged.

See: ansible-collections/amazon.aws#187
See: ansible-collections#117


Co-authored-by: Mark Chappell <mchappel@redhat.com>
  • Loading branch information
goneri and tremble committed Mar 16, 2021
1 parent 4d08f46 commit 6c04b94
Showing 1 changed file with 50 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,27 +159,43 @@
- Type: fixed-response
FixedResponseConfig: "{{ FixedResponseActionConfig }}"
Rules:
- Conditions:
- Field: http-header
HttpHeaderConfig:
HttpHeaderName: 'User-Agent'
Values: ['*Trident/7:0*rv:*']
- Field: http-header
HttpHeaderConfig:
HttpHeaderName: 'X-Something'
Values: ['foobar']
Priority: '1'
Actions:
- Type: fixed-response
FixedResponseConfig:
StatusCode: "200"
ContentType: "text/html"
MessageBody: "<b>Hello World!</b>"
- Conditions:
- Field: path-pattern
Values:
- "/forward-path/*"
Priority: 1
Priority: 2
Actions:
- Type: forward
TargetGroupName: "{{ tg_name }}"
- Conditions:
- Field: path-pattern
Values:
- "/redirect-path/*"
Priority: 2
Priority: 3
Actions:
- Type: redirect
RedirectConfig: "{{ RedirectActionConfig }}"
- Conditions:
- Field: path-pattern
Values:
- "/fixed-response-path/"
Priority: 3
Priority: 4
Actions:
- Type: fixed-response
FixedResponseConfig: "{{ FixedResponseActionConfig }}"
Expand All @@ -189,13 +205,15 @@
that:
- alb.changed
- alb.listeners|length == 1
- alb.listeners[0].rules|length == 4 ## defaultactions is included as a rule
- alb.listeners[0].rules|length == 5 ## defaultactions is included as a rule
- alb.listeners[0].rules[0].actions|length == 1
- alb.listeners[0].rules[0].actions[0].type == "forward"
- alb.listeners[0].rules[0].actions[0].type == "fixed-response"
- alb.listeners[0].rules[1].actions|length == 1
- alb.listeners[0].rules[1].actions[0].type == "redirect"
- alb.listeners[0].rules[1].actions[0].type == "forward"
- alb.listeners[0].rules[2].actions|length == 1
- alb.listeners[0].rules[2].actions[0].type == "fixed-response"
- alb.listeners[0].rules[2].actions[0].type == "redirect"
- alb.listeners[0].rules[3].actions|length == 1
- alb.listeners[0].rules[3].actions[0].type == "fixed-response"

- name: test idempotence multiple non-default rules
elb_application_lb:
Expand All @@ -210,27 +228,43 @@
- Type: fixed-response
FixedResponseConfig: "{{ FixedResponseActionConfig }}"
Rules:
- Conditions:
- Field: http-header
HttpHeaderConfig:
HttpHeaderName: 'User-Agent'
Values: ['*Trident/7:0*rv:*']
- Field: http-header
HttpHeaderConfig:
HttpHeaderName: 'X-Something'
Values: ['foobar']
Priority: '1'
Actions:
- Type: fixed-response
FixedResponseConfig:
StatusCode: "200"
ContentType: "text/html"
MessageBody: "<b>Hello World!</b>"
- Conditions:
- Field: path-pattern
Values:
- "/forward-path/*"
Priority: 1
Priority: 2
Actions:
- Type: forward
TargetGroupName: "{{ tg_name }}"
- Conditions:
- Field: path-pattern
Values:
- "/redirect-path/*"
Priority: 2
Priority: 3
Actions:
- Type: redirect
RedirectConfig: "{{ RedirectActionConfig }}"
- Conditions:
- Field: path-pattern
Values:
- "/fixed-response-path/"
Priority: 3
Priority: 4
Actions:
- Type: fixed-response
FixedResponseConfig: "{{ FixedResponseActionConfig }}"
Expand All @@ -240,13 +274,15 @@
that:
- not alb.changed
- alb.listeners|length == 1
- alb.listeners[0].rules|length == 4 ## defaultactions is included as a rule
- alb.listeners[0].rules|length == 5 ## defaultactions is included as a rule
- alb.listeners[0].rules[0].actions|length == 1
- alb.listeners[0].rules[0].actions[0].type == "forward"
- alb.listeners[0].rules[0].actions[0].type == "fixed-response"
- alb.listeners[0].rules[1].actions|length == 1
- alb.listeners[0].rules[1].actions[0].type == "redirect"
- alb.listeners[0].rules[1].actions[0].type == "forward"
- alb.listeners[0].rules[2].actions|length == 1
- alb.listeners[0].rules[2].actions[0].type == "fixed-response"
- alb.listeners[0].rules[2].actions[0].type == "redirect"
- alb.listeners[0].rules[3].actions|length == 1
- alb.listeners[0].rules[3].actions[0].type == "fixed-response"


# - name: test creating ALB with a default listener with multiple actions
Expand Down

0 comments on commit 6c04b94

Please sign in to comment.