ansible-collections / hetzner.hcloud

A collection to manage resources on Hetzner Cloud
https://galaxy.ansible.com/ui/repo/published/hetzner/hcloud
GNU General Public License v3.0
105 stars 37 forks source link

hcloud_load_balancer_service returns certificates instead of status codes #332

Closed cf-sewe closed 1 year ago

cf-sewe commented 1 year ago

When creating a hcloud_load_balancer_service in mode TCP, but using http health check, then the returned array is incorrectly returning certificates: [ 200 ] instead of the configured status codes list.

This leads to repeated unnecessary updates.

[11:02:16]     ↳ swarm/hcloud_loadbalancer: Create Hetzner Cloud Load Balancer Service with Port 443
META: noop
META: noop
↳  cl1-fsn1-1 -> localhost | CHANGED | 848ms
{
  - hcloud_load_balancer_service: {
    - load_balancer: cl1-lb
    - protocol: tcp
    - listen_port: 443
    - destination_port: 443
    - proxyprotocol: True
    - http: None
    - health_check: {
      - protocol: http
      - port: 443
      - interval: 5
      - timeout: 1
      - retries: 3
      - http: {
        - domain: ""
        - path: /ping
        - response: ""
        - certificates: [ 200 ]
        - tls: True
      }
    }
  }
}

for Ansible code:

- name: "Create Hetzner Cloud Load Balancer Service with Port 443"
  delegate_to: localhost
  hetzner.hcloud.hcloud_load_balancer_service:
    state: "present"
    api_token: "{{ swarm_hcloud_api_token }}"
    load_balancer: "{{ swarm_cluster_name }}-lb"
    protocol: "tcp"
    proxyprotocol: true
    listen_port: 443
    destination_port: 443
    health_check:
      protocol: "http"
      port: 443
      interval: 5
      timeout: 1
      retries: 3
      http:
        domain: ""
        path: "/ping"
        response: ""
        status_codes:
          - '200'
        tls: true

Problematic code line (ff):

https://github.com/ansible-collections/hetzner.hcloud/blob/73f0e3c708ac3d55af3ff1d5a7f08b15524ece98/plugins/modules/hcloud_load_balancer_service.py#L325

cf-sewe commented 1 year ago

Thank you, @jooola :)