mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 13:21:25 -07:00
fix: github_deploy_key check key exists on 422 (#10011)
* fix: github_deploy_key check key exists on 422 If we get a 422 response code as we add a key, check if it's because the key already exists or for another reason. fixes: #6718 * chore: add changelog 10011-github_deploy_key-check-key-present * chore: fix changelog fragment * chore: fix changelog fragment * Update changelog fragment. --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
e0a283bb36
commit
c248073079
2 changed files with 8 additions and 1 deletions
|
@ -259,7 +259,12 @@ class GithubDeployKey(object):
|
|||
key_id = response_body["id"]
|
||||
self.module.exit_json(changed=True, msg="Deploy key successfully added", id=key_id)
|
||||
elif status_code == 422:
|
||||
self.module.exit_json(changed=False, msg="Deploy key already exists")
|
||||
# there might be multiple reasons for a 422
|
||||
# so we must check if the reason is that the key already exists
|
||||
if self.get_existing_key():
|
||||
self.module.exit_json(changed=False, msg="Deploy key already exists")
|
||||
else:
|
||||
self.handle_error(method="POST", info=info)
|
||||
else:
|
||||
self.handle_error(method="POST", info=info)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue