fix gitlab_deploy_key task in check mode (#3622) (#3629)

fixes #3621

* running check mode used to accidentally delete the existing
  ssh key; change it so deletion is skipped in check mode

(cherry picked from commit 8ba7fd5d61)

Co-authored-by: Waldek Maleska <w.maleska@gmail.com>
pull/3634/head
patchback[bot] 2021-10-28 20:19:54 +02:00 committed by GitHub
parent 5bfbd65115
commit ad93c40d40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -0,0 +1,2 @@
bugfixes:
- gitlab_deploy_key - fix the SSH Deploy Key being deleted accidentally while running task in check mode (https://github.com/ansible-collections/community.general/issues/3621, https://github.com/ansible-collections/community.general/pull/3622).

View File

@ -149,6 +149,7 @@ class GitLabDeployKey(object):
# GitLab REST API, so for that case we need to delete and
# than recreate the key
if self.deployKeyObject and self.deployKeyObject.key != key_key:
if not self._module.check_mode:
self.deployKeyObject.delete()
self.deployKeyObject = None