From 31d62c5947083850a236ef06513f0fd2e26ee421 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 21:41:59 +0200 Subject: [PATCH] Fix: gitlab_deploy_key idempotency (#3473) (#3511) * Fix: gitlab_deploy_key idempotency The module was not retrieving all the deploy keys leading to non idempotency on projects with multiple deploy keys. SEE: https://python-gitlab.readthedocs.io/en/stable/api-usage.html#pagination * Update changelogs/fragments/3473-gitlab_deploy_key-fix_idempotency.yml Co-authored-by: Felix Fontein Co-authored-by: Jonathan Piron Co-authored-by: Felix Fontein (cherry picked from commit 0bc4518f3b409c202c2fea6a5233601058119431) Co-authored-by: Jonathan Piron --- changelogs/fragments/3473-gitlab_deploy_key-fix_idempotency.yml | 2 ++ plugins/modules/source_control/gitlab/gitlab_deploy_key.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/3473-gitlab_deploy_key-fix_idempotency.yml diff --git a/changelogs/fragments/3473-gitlab_deploy_key-fix_idempotency.yml b/changelogs/fragments/3473-gitlab_deploy_key-fix_idempotency.yml new file mode 100644 index 0000000000..45dc8f9641 --- /dev/null +++ b/changelogs/fragments/3473-gitlab_deploy_key-fix_idempotency.yml @@ -0,0 +1,2 @@ +bugfixes: + - gitlab_deploy_key - fix idempotency on projects with multiple deploy keys (https://github.com/ansible-collections/community.general/pull/3473). diff --git a/plugins/modules/source_control/gitlab/gitlab_deploy_key.py b/plugins/modules/source_control/gitlab/gitlab_deploy_key.py index 1174718e68..91a7df26b3 100644 --- a/plugins/modules/source_control/gitlab/gitlab_deploy_key.py +++ b/plugins/modules/source_control/gitlab/gitlab_deploy_key.py @@ -204,7 +204,7 @@ class GitLabDeployKey(object): @param key_title Title of the key ''' def findDeployKey(self, project, key_title): - deployKeys = project.keys.list() + deployKeys = project.keys.list(all=True) for deployKey in deployKeys: if (deployKey.title == key_title): return deployKey