mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-12-14 06:22:32 +00:00
hcloud_server: Improve Error Message when attaching a not existing firewall (#96)
This commit is contained in:
parent
f4b336a444
commit
ffd998a0d6
3 changed files with 18 additions and 0 deletions
changelogs/fragments
plugins/modules
tests/integration/targets/hcloud_server/tasks
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- hcloud_server Improve Error Message when attaching a not existing firewall to a server
|
|
@ -476,6 +476,8 @@ class AnsibleHcloudServer(Hcloud):
|
|||
self._mark_as_changed()
|
||||
if not self.module.check_mode:
|
||||
fw = self.client.firewalls.get_by_name(fname)
|
||||
if fw is None:
|
||||
self.module.fail_json(msg="firewall %s was not found" % fname)
|
||||
r = FirewallResource(type="server", server=self.hcloud_server)
|
||||
actions = self.client.firewalls.apply_to_resources(fw, [r])
|
||||
for a in actions:
|
||||
|
|
|
@ -480,6 +480,20 @@
|
|||
- main_server.hcloud_server.status == "running"
|
||||
- main_server.root_password != ""
|
||||
|
||||
- name: test add not existing firewall should fail
|
||||
hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
firewalls:
|
||||
- not-existing
|
||||
state: present
|
||||
ignore_errors: yes
|
||||
register: result
|
||||
- name: verifyt add not existing firewall should fail
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "firewall not-existing was not found"'
|
||||
|
||||
- name: test activate rescue mode with check_mode
|
||||
hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
|
|
Loading…
Reference in a new issue