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
104 stars 37 forks source link

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

Open s4ke opened 1 year ago

s4ke commented 1 year ago
SUMMARY

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

ISSUE TYPE
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
github-actions[bot] commented 11 months ago

This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.

jooola commented 7 months ago

@s4ke The load balancer service module does indeed not validate the arguments correclty. If you define health check you must define all the required arguments.

You can enable the verbose mode to see the error message from the API, telling you what fields are missing or invalid.