diff --git a/changelogs/fragments/6112-fix_key_error_in_gitlab_runner_creation_update.yml b/changelogs/fragments/6112-fix_key_error_in_gitlab_runner_creation_update.yml new file mode 100644 index 0000000000..d752aed347 --- /dev/null +++ b/changelogs/fragments/6112-fix_key_error_in_gitlab_runner_creation_update.yml @@ -0,0 +1,2 @@ +bugfixes: + - gitlab_runner - fix ``KeyError`` on runner creation and update (https://github.com/ansible-collections/community.general/issues/6112). diff --git a/plugins/modules/gitlab_runner.py b/plugins/modules/gitlab_runner.py index f0da30e8f2..22d210b6c2 100644 --- a/plugins/modules/gitlab_runner.py +++ b/plugins/modules/gitlab_runner.py @@ -234,9 +234,8 @@ class GitLabRunner(object): 'maximum_timeout': options['maximum_timeout'], 'tag_list': options['tag_list'], } - if arguments['access_level'] is not None: + if options.get('access_level') is not None: arguments['access_level'] = options['access_level'] - # Because we have already call userExists in main() if self.runner_object is None: arguments['description'] = description @@ -251,7 +250,7 @@ class GitLabRunner(object): access_level_on_creation = False if not access_level_on_creation: - del arguments['access_level'] + arguments.pop('access_level', None) runner = self.create_runner(arguments) changed = True