summaryrefslogtreecommitdiffstats
path: root/ansible_collections/hetzner/hcloud/plugins/modules/floating_ip.py
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/hetzner/hcloud/plugins/modules/floating_ip.py')
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/modules/floating_ip.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/ansible_collections/hetzner/hcloud/plugins/modules/floating_ip.py b/ansible_collections/hetzner/hcloud/plugins/modules/floating_ip.py
index e037dd7a1..022036124 100644
--- a/ansible_collections/hetzner/hcloud/plugins/modules/floating_ip.py
+++ b/ansible_collections/hetzner/hcloud/plugins/modules/floating_ip.py
@@ -160,7 +160,6 @@ hcloud_floating_ip:
"""
from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.common.text.converters import to_native
from ..module_utils.hcloud import AnsibleHCloud
from ..module_utils.vendor.hcloud import HCloudException
@@ -173,19 +172,15 @@ class AnsibleHCloudFloatingIP(AnsibleHCloud):
hcloud_floating_ip: BoundFloatingIP | None = None
def _prepare_result(self):
- server = None
-
- if self.hcloud_floating_ip.server is not None:
- server = to_native(self.hcloud_floating_ip.server.name)
return {
- "id": to_native(self.hcloud_floating_ip.id),
- "name": to_native(self.hcloud_floating_ip.name),
- "description": to_native(self.hcloud_floating_ip.description),
- "ip": to_native(self.hcloud_floating_ip.ip),
- "type": to_native(self.hcloud_floating_ip.type),
- "home_location": to_native(self.hcloud_floating_ip.home_location.name),
+ "id": str(self.hcloud_floating_ip.id),
+ "name": self.hcloud_floating_ip.name,
+ "description": self.hcloud_floating_ip.description,
+ "ip": self.hcloud_floating_ip.ip,
+ "type": self.hcloud_floating_ip.type,
+ "home_location": self.hcloud_floating_ip.home_location.name,
"labels": self.hcloud_floating_ip.labels,
- "server": server,
+ "server": self.hcloud_floating_ip.server.name if self.hcloud_floating_ip.server is not None else None,
"delete_protection": self.hcloud_floating_ip.protection["delete"],
}
@@ -221,7 +216,8 @@ class AnsibleHCloudFloatingIP(AnsibleHCloud):
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()
+ action = self.hcloud_floating_ip.change_protection(delete=delete_protection)
+ action.wait_until_finished()
except HCloudException as exception:
self.fail_json_hcloud(exception)
self._mark_as_changed()
@@ -266,7 +262,8 @@ class AnsibleHCloudFloatingIP(AnsibleHCloud):
delete_protection = self.module.params.get("delete_protection")
if delete_protection is not None and delete_protection != self.hcloud_floating_ip.protection["delete"]:
if not self.module.check_mode:
- self.hcloud_floating_ip.change_protection(delete=delete_protection).wait_until_finished()
+ action = self.hcloud_floating_ip.change_protection(delete=delete_protection)
+ action.wait_until_finished()
self._mark_as_changed()
self._get_floating_ip()