1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00

hcloud_load_balancer Allow changing the type of a Load Balancer (#21)

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
This commit is contained in:
Lukas Kämmerling 2020-08-10 09:58:30 +02:00 committed by GitHub
parent 19257f6d43
commit 9deba9db7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 0 deletions

View file

@ -243,6 +243,18 @@ class AnsibleHcloudLoadBalancer(Hcloud):
else:
self.hcloud_load_balancer.enable_public_interface().wait_until_finished()
self._mark_as_changed()
load_balancer_type = self.module.params.get("load_balancer_type")
if load_balancer_type is not None and self.hcloud_load_balancer.load_balancer_type.name != load_balancer_type:
new_load_balancer_type = self.client.server_types.get_by_name(load_balancer_type)
if not new_load_balancer_type:
self.module.fail_json(msg="unknown load balancer type")
if not self.module.check_mode:
self.hcloud_load_balancer.change_type(
load_balancer_type=new_load_balancer_type,
).wait_until_finished(max_retries=1000)
self._mark_as_changed()
self._get_load_balancer()
except APIException as e:
self.module.fail_json(msg=e.message)