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

hcloud_server: Improve Error Message when attaching a not existing firewall (#96)

This commit is contained in:
Lukas Kämmerling 2021-07-16 11:37:33 +02:00 committed by GitHub
parent f4b336a444
commit ffd998a0d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View file

@ -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: