Repository navigation
github_deploy_key: do not delete the key with state=absent in check mode - #13132
Conversation
Fixes ansible-collections#12348. Assisted-by: Grok Bot
felixfontein
left a comment
There was a problem hiding this comment.
Thanks for your contriibution!
Match the non-check-mode result for state=absent: return id and the 'Deploy key successfully deleted' message only when a key would be removed, and 'Deploy key does not exist' otherwise. Add the PR link to the changelog fragment.
Backport to stable-13: 💚 backport PR created✅ Backport PR branch: Backported as #13160 🤖 @patchback |
|
@sarankumar1325 thanks for your contribution! |
Backport to stable-12: 💚 backport PR created✅ Backport PR branch: Backported as #13162 🤖 @patchback |
Backport to stable-11: 💚 backport PR created✅ Backport PR branch: Backported as #13161 🤖 @patchback |
…lete the key with state=absent in check mode (#13160) github_deploy_key: do not delete the key with state=absent in check mode (#13132) * github_deploy_key: do not delete the key with state=absent in check mode Fixes #12348. Assisted-by: Grok Bot * github_deploy_key: only return id in check mode when the key exists Match the non-check-mode result for state=absent: return id and the 'Deploy key successfully deleted' message only when a key would be removed, and 'Deploy key does not exist' otherwise. Add the PR link to the changelog fragment. (cherry picked from commit f7b4249) Co-authored-by: sarankumar <120080287+sarankumar1325@users.noreply.github.com>
…lete the key with state=absent in check mode (#13162) * github_deploy_key: do not delete the key with state=absent in check mode (#13132) * github_deploy_key: do not delete the key with state=absent in check mode Fixes #12348. Assisted-by: Grok Bot * github_deploy_key: only return id in check mode when the key exists Match the non-check-mode result for state=absent: return id and the 'Deploy key successfully deleted' message only when a key would be removed, and 'Deploy key does not exist' otherwise. Add the PR link to the changelog fragment. (cherry picked from commit f7b4249) * Remove new unit tests. --------- Co-authored-by: sarankumar <120080287+sarankumar1325@users.noreply.github.com> Co-authored-by: Felix Fontein <felix@fontein.de>
…lete the key with state=absent in check mode (#13161) * github_deploy_key: do not delete the key with state=absent in check mode (#13132) * github_deploy_key: do not delete the key with state=absent in check mode Fixes #12348. Assisted-by: Grok Bot * github_deploy_key: only return id in check mode when the key exists Match the non-check-mode result for state=absent: return id and the 'Deploy key successfully deleted' message only when a key would be removed, and 'Deploy key does not exist' otherwise. Add the PR link to the changelog fragment. (cherry picked from commit f7b4249) * Remove Python 3.7+ syntax. * Add boilerplate. * Remove new unit tests. --------- Co-authored-by: sarankumar <120080287+sarankumar1325@users.noreply.github.com> Co-authored-by: Felix Fontein <felix@fontein.de>
SUMMARY
github_deploy_keywithstate: absentdeleted an existing deploy key even in check mode. The check-mode block inmain()only handledstate: present, so forstate: absentexecution fell through toremove_existing_key()and sent theDELETErequest.In check mode with
state: absent, the module now only looks up the key and reportschanged: trueif it exists (with itsid) orchanged: falseif it doesn't, without calling the API'sDELETEendpoint.Fixes #12348
Assisted-by: Grok Bot (AI assistant); I reviewed and tested the change.
ISSUE TYPE
COMPONENT NAME
github_deploy_key
ADDITIONAL INFORMATION
Added
tests/unit/plugins/modules/test_github_deploy_key.py(mocksfetch_url):changed=True, only aGETis sent (this test fails onmainbecause aDELETEis issued)changed=False, noDELETE/keys/<id>