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

Improve Error handling on SSH Key creation (#57)

This commit is contained in:
Lukas Kämmerling 2021-02-23 10:05:32 +01:00 committed by GitHub
parent 9af840105a
commit f59c76de2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 6 deletions

View file

@ -156,7 +156,7 @@ class AnsibleHcloudSSHKey(Hcloud):
self.module.params.get("name")
)
except APIException as e:
except Exception as e:
self.module.fail_json(msg=e.message)
def _create_ssh_key(self):
@ -170,7 +170,10 @@ class AnsibleHcloudSSHKey(Hcloud):
}
if not self.module.check_mode:
self.client.ssh_keys.create(**params)
try:
self.client.ssh_keys.create(**params)
except Exception as e:
self.module.fail_json(msg=e.message)
self._mark_as_changed()
self._get_ssh_key()