fix gitlab_deploy_key task in check mode (#3622)

fixes #3621

* running check mode used to accidentally delete the existing
  ssh key; change it so deletion is skipped in check mode
This commit is contained in:
Waldek Maleska
2021-10-28 19:07:05 +01:00
committed by GitHub
parent 3a2f52c1db
commit 8ba7fd5d61
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,7 +149,8 @@ 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:
self.deployKeyObject.delete()
if not self._module.check_mode:
self.deployKeyObject.delete()
self.deployKeyObject = None
# Because we have already call existsDeployKey in main()