mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
Allow creating resources with protection (#30)
* Allow all supporting resources to be created with protection Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
This commit is contained in:
parent
87d989fcbe
commit
fe84174cb6
11 changed files with 275 additions and 2 deletions
|
|
@ -237,6 +237,10 @@ class AnsibleHcloudFloatingIP(Hcloud):
|
|||
resp = self.client.floating_ips.create(**params)
|
||||
self.hcloud_floating_ip = resp.floating_ip
|
||||
|
||||
delete_protection = self.module.params.get("delete_protection")
|
||||
if delete_protection is not None:
|
||||
self.hcloud_floating_ip.change_protection(delete=delete_protection).wait_until_finished()
|
||||
|
||||
self._mark_as_changed()
|
||||
self._get_floating_ip()
|
||||
|
||||
|
|
|
|||
|
|
@ -217,6 +217,11 @@ class AnsibleHcloudLoadBalancer(Hcloud):
|
|||
resp = self.client.load_balancers.create(**params)
|
||||
resp.action.wait_until_finished(max_retries=1000)
|
||||
|
||||
delete_protection = self.module.params.get("delete_protection")
|
||||
if delete_protection is not None:
|
||||
self._get_load_balancer()
|
||||
self.hcloud_load_balancer.change_protection(delete=delete_protection).wait_until_finished()
|
||||
|
||||
self._mark_as_changed()
|
||||
self._get_load_balancer()
|
||||
|
||||
|
|
|
|||
|
|
@ -161,6 +161,11 @@ class AnsibleHcloudNetwork(Hcloud):
|
|||
if not self.module.check_mode:
|
||||
self.client.networks.create(**params)
|
||||
|
||||
delete_protection = self.module.params.get("delete_protection")
|
||||
if delete_protection is not None:
|
||||
self._get_network()
|
||||
self.hcloud_network.change_protection(delete=delete_protection).wait_until_finished()
|
||||
|
||||
self._mark_as_changed()
|
||||
self._get_network()
|
||||
|
||||
|
|
|
|||
|
|
@ -357,6 +357,12 @@ class AnsibleHcloudServer(Hcloud):
|
|||
self._get_server()
|
||||
self.hcloud_server.enable_backup().wait_until_finished()
|
||||
|
||||
delete_protection = self.module.params.get("delete_protection")
|
||||
rebuild_protection = self.module.params.get("rebuild_protection")
|
||||
if delete_protection is not None and rebuild_protection is not None:
|
||||
self._get_server()
|
||||
self.hcloud_server.change_protection(delete=delete_protection,
|
||||
rebuild=rebuild_protection).wait_until_finished()
|
||||
self._mark_as_changed()
|
||||
self._get_server()
|
||||
|
||||
|
|
|
|||
|
|
@ -228,6 +228,10 @@ class AnsibleHcloudVolume(Hcloud):
|
|||
resp = self.client.volumes.create(**params)
|
||||
resp.action.wait_until_finished()
|
||||
[action.wait_until_finished() for action in resp.next_actions]
|
||||
delete_protection = self.module.params.get("delete_protection")
|
||||
if delete_protection is not None:
|
||||
self._get_volume()
|
||||
self.hcloud_volume.change_protection(delete=delete_protection).wait_until_finished()
|
||||
|
||||
self._mark_as_changed()
|
||||
self._get_volume()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue