mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
Allow setting Floating IP RDNS entries with hcloud_rdns
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
This commit is contained in:
parent
2579712280
commit
013a78b6a5
2 changed files with 8 additions and 9 deletions
|
|
@ -132,9 +132,9 @@ class AnsibleHcloudReverseDNS(Hcloud):
|
|||
}
|
||||
|
||||
if self.module.params.get("server"):
|
||||
result["server"] = to_native(self.hcloud_resource.name),
|
||||
result["server"] = to_native(self.hcloud_resource.name)
|
||||
elif self.module.params.get("floating_ip"):
|
||||
result["floating_ip"] = to_native(self.hcloud_resource.name),
|
||||
result["floating_ip"] = to_native(self.hcloud_resource.name)
|
||||
return result
|
||||
|
||||
def _get_resource(self):
|
||||
|
|
@ -144,7 +144,7 @@ class AnsibleHcloudReverseDNS(Hcloud):
|
|||
self.module.params.get("server")
|
||||
)
|
||||
elif self.module.params.get("floating_ip"):
|
||||
self.hcloud_resource = self.client.floating_ip.get_by_name(
|
||||
self.hcloud_resource = self.client.floating_ips.get_by_name(
|
||||
self.module.params.get("floating_ip")
|
||||
)
|
||||
except APIException as e:
|
||||
|
|
@ -168,7 +168,7 @@ class AnsibleHcloudReverseDNS(Hcloud):
|
|||
"dns_ptr": self.hcloud_resource.dns_ptr[0]["dns_ptr"],
|
||||
}
|
||||
else:
|
||||
self.module.fail_json(msg="The selected server does not have this IP address")
|
||||
self.module.fail_json(msg="The selected Floating IP does not have this IP address")
|
||||
|
||||
elif utils.validate_ip_v6_address(ip_address):
|
||||
if self.module.params.get("server"):
|
||||
|
|
@ -200,7 +200,6 @@ class AnsibleHcloudReverseDNS(Hcloud):
|
|||
if not self.module.check_mode:
|
||||
self.hcloud_resource.change_dns_ptr(**params).wait_until_finished()
|
||||
|
||||
self.log("created rdns", type(self.hcloud_resource))
|
||||
self._mark_as_changed()
|
||||
self._get_resource()
|
||||
self._get_rdns()
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
- name: test create rdns
|
||||
hcloud_rdns:
|
||||
server: "{{ hcloud_server_name }}"
|
||||
ip_address: "{{ setup.hcloud_server.ipv4_address }}"
|
||||
ip_address: "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
|
||||
dns_ptr: "example.com"
|
||||
state: present
|
||||
register: rdns
|
||||
|
|
@ -49,13 +49,13 @@
|
|||
that:
|
||||
- rdns is changed
|
||||
- rdns.hcloud_rdns.server == "{{ hcloud_server_name }}"
|
||||
- rdns.hcloud_rdns.ip_address == "{{ setup.hcloud_server.ipv4_address }}"
|
||||
- rdns.hcloud_rdns.ip_address == "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
|
||||
- rdns.hcloud_rdns.dns_ptr == "example.com"
|
||||
|
||||
- name: test create rdns idempotency
|
||||
hcloud_rdns:
|
||||
server: "{{ hcloud_server_name }}"
|
||||
ip_address: "{{ setup.hcloud_server.ipv4_address }}"
|
||||
ip_address: "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
|
||||
dns_ptr: "example.com"
|
||||
state: present
|
||||
register: result
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
- name: test absent rdns
|
||||
hcloud_rdns:
|
||||
server: "{{ hcloud_server_name }}"
|
||||
ip_address: "{{ setup.hcloud_server.ipv4_address }}"
|
||||
ip_address: "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify test absent rdns
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue