Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elb_application_ld modify rule: http-header not working #117

Closed
DylanABacon opened this issue Jun 24, 2020 · 3 comments
Closed

elb_application_ld modify rule: http-header not working #117

DylanABacon opened this issue Jun 24, 2020 · 3 comments
Assignees
Labels

Comments

@DylanABacon
Copy link

SUMMARY

When using the "elb_application_lb" module to create/modify rules for a listener, the modify action for a http-header condition type does not work. If the rule is not already created, the module creates the rule correctly, but when it is already created, it returns an error: KeyError: 'Values'.
I am able to modify this rule with the aws cli.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

elb_application_lb for aws

ANSIBLE VERSION
ansible 2.9.6
  config file = None
  configured module search path = ['/home/dylan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/dylan/.devops_envs/devops_smc/lib/python3.6/site-packages/ansible
  executable location = /home/dylan/.devops_envs/devops_smc/bin/ansible
  python version = 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0]

CONFIGURATION

OS / ENVIRONMENT

Ubuntu 18

STEPS TO REPRODUCE

Create a playbook to create/modify the rule. On the first run it should successfully create the rule. On the second run, it returns an error.

name: create Load Balancer
  elb_application_lb:
    state: present
    name: "{{ load_balancer_name }}"
    security_groups: "{{ elb_security_group_name }}"
    subnets: "{{ vpc_subnet_list }}"
    listeners:
    - Protocol: HTTPS
      Port: 443
      SslPolicy: ELBSecurityPolicy-2016-08
      Certificates:
      - CertificateArn: "{{ https_certificate_arn }}"
      DefaultActions:
      - Type: fixed-response
        FixedResponseConfig:
          ContentType: text/plain
          StatusCode: "503"
      Rules:
      - Conditions:
          - Field: http-header
            HttpHeaderConfig:
              HttpHeaderName: 'User-Agent'
              Values: '*Trident/7:0*rv:11*'
        Priority: '1'
        Actions:
          - Type: fixed-response
            FixedResponseConfig:
              StatusCode: "200"
              ContentType: "text/html"
              MessageBody: "<b>Hello World!</b>"
  register:  create_lb_result
EXPECTED RESULTS

I expect the http-header rule to be updated if it is changed.

ACTUAL RESULTS

An error is returned: KeyError: 'Values'

I am able to modify te rule with the aws cli command:

aws elbv2 modify-rule   --actions Type="fixed-response",FixedResponseConfig='{MessageBody="<b>Hello World!</b>",ContentType="text/html",StatusCode="200"}'  --conditions Field=http-header,HttpHeaderConfig='{HttpHeaderName='User-Agent',Values='*Trident/7.0*rv:11*'}' --rule-arn arn:myarn
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'Values'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "rc": 1
}

MSG:

MODULE FAILURE
See stdout/stderr for the exact error


MODULE_STDERR:

Traceback (most recent call last):
  File "<stdin>", line 102, in <module>
  File "<stdin>", line 94, in _ansiballz_main
  File "<stdin>", line 40, in invoke_module
  File "/usr/lib/python3.6/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_elb_application_lb_payload_8gfeee49/ansible_elb_application_lb_payload.zip/ansible/modules/cloud/amazon/elb_application_lb.py", line 612, in <module>
  File "/tmp/ansible_elb_application_lb_payload_8gfeee49/ansible_elb_application_lb_payload.zip/ansible/modules/cloud/amazon/elb_application_lb.py", line 606, in main
  File "/tmp/ansible_elb_application_lb_payload_8gfeee49/ansible_elb_application_lb_payload.zip/ansible/modules/cloud/amazon/elb_application_lb.py", line 488, in create_or_update_elb
  File "/tmp/ansible_elb_application_lb_payload_8gfeee49/ansible_elb_application_lb_payload.zip/ansible/module_utils/aws/elbv2.py", line 809, in compare_rules
  File "/tmp/ansible_elb_application_lb_payload_8gfeee49/ansible_elb_application_lb_payload.zip/ansible/module_utils/aws/elbv2.py", line 784, in _compare_rule
  File "/tmp/ansible_elb_application_lb_payload_8gfeee49/ansible_elb_application_lb_payload.zip/ansible/module_utils/aws/elbv2.py", line 720, in _compare_condition
KeyError: 'Values'

@ansibullbot
Copy link

Files identified in the description:
None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

goneri added a commit to goneri/community.aws that referenced this issue Jan 7, 2021
goneri added a commit to goneri/community.aws that referenced this issue Jan 19, 2021
tremble pushed a commit to goneri/community.aws that referenced this issue Mar 16, 2021
tremble added a commit that referenced this issue Mar 16, 2021
* 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: #117


Co-authored-by: Mark Chappell <[email protected]>
danquixote pushed a commit to danquixote/community.aws that referenced this issue May 16, 2021
…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 <[email protected]>
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this issue Jul 19, 2021
…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 <[email protected]>
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this issue Jul 19, 2021
…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 <[email protected]>
danielcotton pushed a commit to danielcotton/community.aws that referenced this issue Nov 23, 2021
…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 <[email protected]>
@markuman markuman mentioned this issue Feb 1, 2022
1 task
@jatorcasso
Copy link
Contributor

Has this issue been resolved?

@markuman
Copy link
Member

markuman commented Mar 2, 2022

Has this issue been resolved?

Well spottet. I guess it is included since 1.4.0

@markuman markuman closed this as completed Mar 2, 2022
goneri added a commit to ansible-collections/amazon.aws that referenced this issue Sep 20, 2022
* elb_application_lb: test a rule based on http-header

This should initially fail and be fixed the day #188
is merged.

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

Co-authored-by: Mark Chappell <[email protected]>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@8c0ea48
GomathiselviS pushed a commit to GomathiselviS/amazon.aws that referenced this issue Sep 20, 2022
…ions#347)

* elb_application_lb: test a rule based on http-header

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

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

Co-authored-by: Mark Chappell <[email protected]>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@8c0ea48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants