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_target_group: health_check_port is ignored #43244

Closed
dseeley-sky opened this issue Jul 25, 2018 · 9 comments · Fixed by #43247
Closed

elb_target_group: health_check_port is ignored #43244

dseeley-sky opened this issue Jul 25, 2018 · 9 comments · Fixed by #43247
Labels
affects_2.6 This issue/PR affects Ansible v2.6 aws bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community.

Comments

@dseeley-sky
Copy link
Contributor

SUMMARY

When creating a elb_target_group, setting health_check_port has no effect and 'traffic-port' is always selected

ISSUE TYPE
  • Bug Report
COMPONENT NAME

elb_target_group

ANSIBLE VERSION
ansible 2.6.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/dse09/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
CONFIGURATION
OS / ENVIRONMENT

CentOS 7

STEPS TO REPRODUCE
- name: create targetgroup
  elb_target_group:
    name: "test-tg"
    protocol: tcp
    port: 12345
    vpc_id: vpc-xxxx
    health_check_protocol: tcp
    health_check_port: 80
    successful_response_codes: "200"
    state: present
  register: elb_target_group

- debug: msg={{elb_target_group}}
EXPECTED RESULTS

I expect the target group to be created with the health check port set to 80.

If the command is run using aws cli, it works fine:

$ aws elbv2 create-target-group --name test-tg --protocol TCP --port 12345 --health-check-port 80 --vpc-id vpc-3xxxx
{
    "TargetGroups": [
        {
            "TargetType": "instance",
            "HealthCheckIntervalSeconds": 30,
            "VpcId": "vpc-xxxx",
            "Protocol": "TCP",
            "HealthCheckTimeoutSeconds": 10,
            "HealthCheckProtocol": "TCP",
            "UnhealthyThresholdCount": 3,
            "HealthyThresholdCount": 3,
            "TargetGroupArn": "arn:aws:elasticloadbalancing:eu-west-1:0xxxx:targetgroup/test-tg/0xxxxxxxx",
            "HealthCheckPort": "80",
            "Port": 12345,
            "TargetGroupName": "test-tg"
        }
    ]
}
ACTUAL RESULTS

targetgroup is created with health_check_port set to 'traffic-port'.

TASK [create targetgroup] *********************************************************************************************************************************************************************************
task path: /home/dse09/src/vtp-bcmed-proxy/test2.yml:7
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/amazon/elb_target_group.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: dse09
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 && sleep 0'
changed: [localhost] => {
    "changed": true,
    "deregistration_delay_timeout_seconds": "300",
    "health_check_interval_seconds": 30,
    "health_check_port": "traffic-port",
    "health_check_protocol": "TCP",
    "health_check_timeout_seconds": 10,
    "healthy_threshold_count": 3,
    "invocation": {
        "module_args": {
            "aws_access_key": null,
            "aws_secret_key": null,
            "deregistration_delay_timeout": null,
            "ec2_url": null,
            "health_check_interval": null,
            "health_check_path": null,
            "health_check_port": "80",
            "health_check_protocol": "tcp",
            "health_check_timeout": null,
            "healthy_threshold_count": null,
            "modify_targets": true,
            "name": "test-tg",
            "port": 12345,
            "profile": null,
            "protocol": "tcp",
            "purge_tags": true,
            "region": null,
            "security_token": null,
            "state": "present",
            "stickiness_enabled": null,
            "stickiness_lb_cookie_duration": null,
            "stickiness_type": "lb_cookie",
            "successful_response_codes": "200",
            "tags": {},
            "target_type": "instance",
            "targets": null,
            "unhealthy_threshold_count": null,
            "validate_certs": true,
            "vpc_id": "vpc-xxxx",
            "wait": null,
            "wait_timeout": null
        }
    },
    "load_balancer_arns": [],
    "port": 12345,
    "protocol": "TCP",
    "proxy_protocol_v2_enabled": "false",
    "tags": {},
    "target_group_arn": "arn:aws:elasticloadbalancing:eu-west-1:xxxx:targetgroup/test-tg/xxxx",
    "target_group_name": "test-tg",
    "target_type": "instance",
    "unhealthy_threshold_count": 3,
    "vpc_id": "vpc-xxxx"
}

TASK [debug] **********************************************************************************************************************************************************************************************
task path: /home/dse09/src/vtp-bcmed-proxy/test2.yml:19
ok: [localhost] => {
    "msg": {
        "changed": true,
        "deregistration_delay_timeout_seconds": "300",
        "failed": false,
        "health_check_interval_seconds": 30,
        "health_check_port": "traffic-port",
        "health_check_protocol": "TCP",
        "health_check_timeout_seconds": 10,
        "healthy_threshold_count": 3,
        "load_balancer_arns": [],
        "port": 12345,
        "protocol": "TCP",
        "proxy_protocol_v2_enabled": "false",
        "tags": {},
        "target_group_arn": "arn:aws:elasticloadbalancing:eu-west-1:xxxx:targetgroup/test-tg/xxx",
        "target_group_name": "test-tg",
        "target_type": "instance",
        "unhealthy_threshold_count": 3,
        "vpc_id": "vpc-xxxx"
    }
}
@ansibot
Copy link
Contributor

ansibot commented Jul 25, 2018

Files identified in the description:

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

@ansibot
Copy link
Contributor

ansibot commented Jul 25, 2018

cc @wimnat
click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Jul 25, 2018

Hi dseeley-sky,

Thank you for the issue, just so you are aware we have a dedicated Working Group for aws.
You can find other people interested in this in #ansible-aws on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot ansibot added affects_2.6 This issue/PR affects Ansible v2.6 aws bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. labels Jul 25, 2018
@wimnat
Copy link
Contributor

wimnat commented Jul 25, 2018

This is happening because it's TCP type. I'll raise a PR with a fix shortly.

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Jul 25, 2018
@dseeley-sky
Copy link
Contributor Author

FYI - the other parameters (health_check_interval, health_check_timeout, etc) are also ignored.

@wimnat
Copy link
Contributor

wimnat commented Jul 25, 2018

@dseeley-sky try the above PR and see if it fixes it for you

@dseeley-sky
Copy link
Contributor Author

@wimnat Yes - this fixes it - thanks!

@wimnat
Copy link
Contributor

wimnat commented Jul 26, 2018

@dseeley-sky can you please comment "shipit" on the PR?

felixfontein pushed a commit to felixfontein/ansible that referenced this issue Sep 6, 2018
…e#43247)

* Fix health check configurations being ignored - ansible#43244

* Ensure health_check_protocol is not None before check

* Simplify long indented if statement
s-hertel pushed a commit to s-hertel/ansible that referenced this issue Sep 6, 2018
…e#43247)

* Fix health check configurations being ignored - ansible#43244

* Ensure health_check_protocol is not None before check

* Simplify long indented if statement

(cherry picked from commit 7e426b0)
abadger pushed a commit that referenced this issue Sep 6, 2018
* Fix health check configurations being ignored - #43244

* Ensure health_check_protocol is not None before check

* Simplify long indented if statement

(cherry picked from commit 7e426b0)
@chenl87
Copy link
Contributor

chenl87 commented Oct 28, 2018

@dseeley-sky
It seems like the health_check_path is being set only when there's a health_check_protocol provided:
if module.params.get("health_check_protocol") is not None and module.params.get("health_check_protocol").upper() != 'TCP':
if module.params.get("health_check_path") is not None:
params['HealthCheckPath'] = module.params.get("health_check_path")

Now when setting a health_check_path without providing a protocol the target group is being created with default HTTP protocol and the health_check_path is being ignored and set to "/"

I think we should either cancel this dependency between the path and the protocol or add a check and fail the run if there's a path set but no protocol set (and update the documentation accordingly).

WDYT?

@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.6 This issue/PR affects Ansible v2.6 aws bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants