From afd24ccd3557587eac0830be50680737ccb89fce Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 18 Jun 2023 21:27:29 +0200 Subject: [PATCH] [PR #6712/e85b0080 backport][stable-6] gitlab_group => Make most options optional (#6724) gitlab_group => Make most options optional (#6712) * Make most options optional as they should be * Add filter to create_group instead * Remove whitespace * Add changelog fragment * Added description and extension to fragment * Update changelogs/fragments/6712-gitlab_group-filtered-for-none-values.yml Co-authored-by: Felix Fontein * Update plugins/modules/gitlab_group.py Co-authored-by: Felix Fontein * Make Python 2.6 compatible. * Another shot at compatibility. --------- Co-authored-by: Felix Fontein (cherry picked from commit e85b0080360100d34d0bd366b85a321743314440) Co-authored-by: Intellium --- .../fragments/6712-gitlab_group-filtered-for-none-values.yml | 2 ++ plugins/modules/gitlab_group.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/6712-gitlab_group-filtered-for-none-values.yml diff --git a/changelogs/fragments/6712-gitlab_group-filtered-for-none-values.yml b/changelogs/fragments/6712-gitlab_group-filtered-for-none-values.yml new file mode 100644 index 0000000000..53c02d4588 --- /dev/null +++ b/changelogs/fragments/6712-gitlab_group-filtered-for-none-values.yml @@ -0,0 +1,2 @@ +bugfixes: + - gitlab_group - the module passed parameters to the API call even when not set. The module is now filtering out ``None`` values to remediate this (https://github.com/ansible-collections/community.general/pull/6712). diff --git a/plugins/modules/gitlab_group.py b/plugins/modules/gitlab_group.py index 624028f298..4de1ffc5f0 100644 --- a/plugins/modules/gitlab_group.py +++ b/plugins/modules/gitlab_group.py @@ -255,7 +255,10 @@ class GitLabGroup(object): return True try: - group = self._gitlab.groups.create(arguments) + # Filter out None values + filtered = dict((arg_key, arg_value) for arg_key, arg_value in arguments.items() if arg_value is not None) + + group = self._gitlab.groups.create(filtered) except (gitlab.exceptions.GitlabCreateError) as e: self._module.fail_json(msg="Failed to create group: %s " % to_native(e))