hetzner.hcloud icon indicating copy to clipboard operation
hetzner.hcloud copied to clipboard

hcloud_load_balancer_service fails to be created with health_check when load balancer service does not exist

Open s4ke opened this issue 1 year ago • 2 comments

SUMMARY

hcloud_load_balancer_service fails to be created with health_check when load balancer service does not exist

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hcloud_load_balancer_service

ANSIBLE VERSION
ansible [core 2.13.5]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/martinb/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/martinb/neuroforge_projects/github/swarmsible-hetzner/swarmsible-hetzner/venv/lib/python3.8/site-packages/ansible
  ansible collection location = /home/martinb/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/martinb/neuroforge_projects/github/swarmsible-hetzner/swarmsible-hetzner/venv/bin/ansible
  python version = 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
# /home/martinb/neuroforge_projects/github/swarmsible-hetzner/swarmsible-hetzner/venv/lib/python3.8/site-packages/ansible_collections
Collection     Version
-------------- -------
hetzner.hcloud 1.8.2  

# /home/martinb/.ansible/collections/ansible_collections
Collection     Version
-------------- -------
hetzner.hcloud 1.8.2  
CONFIGURATION

OS / ENVIRONMENT

Kubuntu 20.04

STEPS TO REPRODUCE

Use the following task:

- name: Create Load Balancer service with Port 443
  hetzner.hcloud.hcloud_load_balancer_service:
    api_token: "{{ hcloud_token }}"
    load_balancer: "swarmlb"
    protocol: https
    listen_port: 443
    state: present
    health_check:
      http:
        status_codes:
          - "404"
        tls: no
    http:
      redirect_http: true
      certificates:
        - "{{ swarm_lb_certificate_name }}"

Run on a project without the load balancer existing

EXPECTED RESULTS

The load balancer being created successful

ACTUAL RESULTS

The error is

fatal: [localhost]: FAILED! => {"changed": false, "msg": "invalid input in field 'health_check'"}

If we create the load balancer with no custom health_check before it works:

- name: Create Load Balancer service with Port 443 (work around, creating a new load balancer with health_check fails)
  hetzner.hcloud.hcloud_load_balancer_service:
    api_token: "{{ hcloud_token }}"
    load_balancer: "swarmlb"
    protocol: https
    listen_port: 443
    state: present
    http:
      redirect_http: true
      certificates:
        - "{{ swarm_lb_certificate_name }}"
  when: not swarm_lb_found | bool

s4ke avatar Oct 23 '22 15:10 s4ke