mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
fix: wait for floating ip assign action (#694)
##### SUMMARY Wait for the floating ip assign action to complete before continuing. This reduce the chances of running into `locked` errors. ##### ISSUE TYPE - Bugfix Pull Request ##### COMPONENT NAME floating_ip
This commit is contained in:
parent
826e6a5309
commit
c3ec5d1dcc
2 changed files with 8 additions and 3 deletions
2
changelogs/fragments/wait-floating-ip-assign-action.yml
Normal file
2
changelogs/fragments/wait-floating-ip-assign-action.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- floating_ip - Wait for the Floating IP assign action to complete to reduce chances of running into ``locked`` errors.
|
||||||
|
|
@ -242,7 +242,8 @@ class AnsibleHCloudFloatingIP(AnsibleHCloud):
|
||||||
if server is not None and self.hcloud_floating_ip.server is not None:
|
if server is not None and self.hcloud_floating_ip.server is not None:
|
||||||
if self.module.params.get("force") and server != self.hcloud_floating_ip.server.name:
|
if self.module.params.get("force") and server != self.hcloud_floating_ip.server.name:
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
self.hcloud_floating_ip.assign(self.client.servers.get_by_name(server))
|
action = self.hcloud_floating_ip.assign(self.client.servers.get_by_name(server))
|
||||||
|
action.wait_until_finished()
|
||||||
self._mark_as_changed()
|
self._mark_as_changed()
|
||||||
elif server != self.hcloud_floating_ip.server.name:
|
elif server != self.hcloud_floating_ip.server.name:
|
||||||
self.module.warn(
|
self.module.warn(
|
||||||
|
|
@ -253,11 +254,13 @@ class AnsibleHCloudFloatingIP(AnsibleHCloud):
|
||||||
self._mark_as_changed()
|
self._mark_as_changed()
|
||||||
elif server is not None and self.hcloud_floating_ip.server is None:
|
elif server is not None and self.hcloud_floating_ip.server is None:
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
self.hcloud_floating_ip.assign(self.client.servers.get_by_name(server))
|
action = self.hcloud_floating_ip.assign(self.client.servers.get_by_name(server))
|
||||||
|
action.wait_until_finished()
|
||||||
self._mark_as_changed()
|
self._mark_as_changed()
|
||||||
elif server is None and self.hcloud_floating_ip.server is not None:
|
elif server is None and self.hcloud_floating_ip.server is not None:
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
self.hcloud_floating_ip.unassign()
|
action = self.hcloud_floating_ip.unassign()
|
||||||
|
action.wait_until_finished()
|
||||||
self._mark_as_changed()
|
self._mark_as_changed()
|
||||||
|
|
||||||
delete_protection = self.module.params.get("delete_protection")
|
delete_protection = self.module.params.get("delete_protection")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue