mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-11-10 06:34:13 +00:00
hcloud_rdns improve error message on not existing server/Floating IP (#99)
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
This commit is contained in:
parent
9b1492a32c
commit
2be9ff3240
3 changed files with 18 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- hcloud_rdns improve error message on not existing server/Floating IP
|
|
@ -143,10 +143,14 @@ class AnsibleHcloudReverseDNS(Hcloud):
|
|||
self.hcloud_resource = self.client.servers.get_by_name(
|
||||
self.module.params.get("server")
|
||||
)
|
||||
if self.hcloud_resource is None:
|
||||
self.module.fail_json(msg="The selected server does not exist")
|
||||
elif self.module.params.get("floating_ip"):
|
||||
self.hcloud_resource = self.client.floating_ips.get_by_name(
|
||||
self.module.params.get("floating_ip")
|
||||
)
|
||||
if self.hcloud_resource is None:
|
||||
self.module.fail_json(msg="The selected Floating IP does not exist")
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg=e.message)
|
||||
|
||||
|
|
|
@ -36,7 +36,18 @@
|
|||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "missing required arguments: ip_address"'
|
||||
|
||||
- name: test fail on not existing resource
|
||||
hcloud_rdns:
|
||||
server: "not-existing"
|
||||
ip_address: "127.0.0.1"
|
||||
state: present
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
- name: verify fail on not existing resou
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "The selected server does not exist"'
|
||||
- name: test create rdns
|
||||
hcloud_rdns:
|
||||
server: "{{ hcloud_server_name }}"
|
||||
|
|
Loading…
Reference in a new issue