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))