From 9dc3c3ade239c0788144620dd66e1ed87f0ef41e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= Date: Tue, 30 Jun 2020 09:43:19 +0200 Subject: [PATCH] Bugfix: allow hcloud.yml and hcloud.yaml again as inventory configuration. --- plugins/modules/hcloud_load_balancer.py | 6 ++---- plugins/modules/hcloud_load_balancer_service.py | 2 +- .../integration/targets/hcloud_load_balancer/tasks/main.yml | 4 +++- tests/utils/gitlab/gitlab.sh | 1 + tests/utils/gitlab/integration.sh | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/modules/hcloud_load_balancer.py b/plugins/modules/hcloud_load_balancer.py index 8346cd1..4ece8b3 100644 --- a/plugins/modules/hcloud_load_balancer.py +++ b/plugins/modules/hcloud_load_balancer.py @@ -236,7 +236,7 @@ class AnsibleHcloudLoadBalancer(Hcloud): self._get_load_balancer() disable_public_interface = self.module.params.get("disable_public_interface") - if disable_public_interface is not None and disable_public_interface != self.hcloud_load_balancer.public_net.enabled: + if disable_public_interface is not None and disable_public_interface != (not self.hcloud_load_balancer.public_net.enabled): if not self.module.check_mode: if disable_public_interface is True: self.hcloud_load_balancer.disable_public_interface().wait_until_finished() @@ -250,10 +250,8 @@ class AnsibleHcloudLoadBalancer(Hcloud): def present_load_balancer(self): self._get_load_balancer() if self.hcloud_load_balancer is None: - self.module.debug(msg="Create") self._create_load_balancer() else: - self.module.debug(msg="Update") self._update_load_balancer() def delete_load_balancer(self): @@ -278,7 +276,7 @@ class AnsibleHcloudLoadBalancer(Hcloud): network_zone={"type": "str"}, labels={"type": "dict"}, delete_protection={"type": "bool"}, - disable_public_interface={"type": "bool", "default": False}, + disable_public_interface={"type": "bool"}, state={ "choices": ["absent", "present"], "default": "present", diff --git a/plugins/modules/hcloud_load_balancer_service.py b/plugins/modules/hcloud_load_balancer_service.py index 269a703..83a7034 100644 --- a/plugins/modules/hcloud_load_balancer_service.py +++ b/plugins/modules/hcloud_load_balancer_service.py @@ -322,7 +322,7 @@ class AnsibleHcloudLoadBalancerService(Hcloud): "response": to_native(self.hcloud_load_balancer_service.health_check.http.response), "certificates": [to_native(status_code) for status_code in self.hcloud_load_balancer_service.health_check.http.status_codes], - "tls": self.hcloud_load_balancer_service.health_check.tls, + "tls": self.hcloud_load_balancer_service.health_check.http.tls, } return { "load_balancer": to_native(self.hcloud_load_balancer.name), diff --git a/tests/integration/targets/hcloud_load_balancer/tasks/main.yml b/tests/integration/targets/hcloud_load_balancer/tasks/main.yml index fd187b4..ec555c9 100644 --- a/tests/integration/targets/hcloud_load_balancer/tasks/main.yml +++ b/tests/integration/targets/hcloud_load_balancer/tasks/main.yml @@ -29,7 +29,7 @@ state: present register: result check_mode: yes -- name: test create Load Balancer Load Balancer +- name: test create Load Balancer with check mode assert: that: - result is changed @@ -51,6 +51,8 @@ - name: test create Load Balancer idempotence hcloud_load_balancer: name: "{{ hcloud_load_balancer_name }}" + load_balancer_type: lb11 + network_zone: eu-central state: present register: result - name: verify create Load Balancer idempotence diff --git a/tests/utils/gitlab/gitlab.sh b/tests/utils/gitlab/gitlab.sh index a48dbaa..a23b74d 100755 --- a/tests/utils/gitlab/gitlab.sh +++ b/tests/utils/gitlab/gitlab.sh @@ -46,6 +46,7 @@ fi export ANSIBLE_COLLECTIONS_PATHS="${HOME}/.ansible" SHIPPABLE_RESULT_DIR="$(pwd)/shippable" TEST_DIR="${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/hetzner/hcloud" +rm -rf "${TEST_DIR}" mkdir -p "${TEST_DIR}" cp -r "." "${TEST_DIR}" cd "${TEST_DIR}" diff --git a/tests/utils/gitlab/integration.sh b/tests/utils/gitlab/integration.sh index 4ab2e58..2d660c8 100755 --- a/tests/utils/gitlab/integration.sh +++ b/tests/utils/gitlab/integration.sh @@ -12,4 +12,4 @@ hcloud_api_token=${HCLOUD_TOKEN} export SHIPPABLE="true" export SHIPPABLE_BUILD_NUMBER="gl-$(cat prefix.txt)" export SHIPPABLE_JOB_NUMBER="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1)" -ansible-test integration --color --local -vvvvv "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} +ansible-test integration --color --local -vv "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"}