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

Fix idempotency

This commit is contained in:
ohdearaugustin 2020-10-02 21:46:19 +02:00
parent fe84174cb6
commit be6213f6e0

View file

@ -259,7 +259,7 @@ class AnsibleHcloudFloatingIP(Hcloud):
self._mark_as_changed()
server = self.module.params.get("server")
if server is not None:
if server is not None and server != self.hcloud_floating_ip.server.name:
if self.module.params.get("force") or self.hcloud_floating_ip.server is None:
if not self.module.check_mode:
self.hcloud_floating_ip.assign(
@ -267,7 +267,7 @@ class AnsibleHcloudFloatingIP(Hcloud):
)
else:
self.module.warn(
"Floating IP is already assigned to server %s. You need to unassign the Floating IP or use force=yes."
"Floating IP is already assigned to another server %s. You need to unassign the Floating IP or use force=yes."
% self.hcloud_floating_ip.server.name
)
self._mark_as_changed()