Repository: ansible-collections/community.general

Issue:
community.general.gitlab_runner KeyError: 'access_level' bug
### Summary

Line 237 always gives KeyError:

https://github.com/ansible-collections/community.general/blob/d2094669859fe4b48aa20f1b3ae868b61023b51d/plugins/modules/gitlab_runner.py#L227-L239

arguments is just defined right there and it doesn't have 'access_level' key. The if always fails in the line 237.

### Issue Type

Bug Report

### Component Name

gitlab_runner

### Ansible Version

```console (paste below)
$ ansible --version
ansible [core 2.13.6]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.10 (main, Feb  9 2023, 02:08:14) [GCC 12.2.1 20220924]
  jinja version = 3.1.2
  libyaml = True

```


### Community.general Version

```console (paste below)
$ ansible-galaxy collection list community.general

# /usr/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 5.8.0  

# /root/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 6.4.0  

```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed

```


### OS / Environment

_No response_

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)
- name: "Register {{ runner_name }} runner"
  become: yes
  community.general.gitlab_runner:
    access_level: not_protected
    api_url: "{{ gitlab_api_url }}"
    api_token: "{{ gitlab_admin_api_token }}"
    registration_token: "{{ runner_registration_token }}"
    description: "{{ runner_description }}"
    state: present
    active: True
    tag_list: "{{ runner_tag_list }}"
    run_untagged: False
    locked: no
    owned: yes
```


### Expected Results

Playbook runs successfully

### Actual Results

```console (paste below)

tmp/ansible_community.general.gitlab_runner_payload_64flh7vp/ansible_community.general.gitlab_runner_payload.zip/ansible_collections/community/general/plugins/modules/gitlab_runner.py\", line 237, in create_or_update_runner\r\nKeyError: 'access_level'\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/gitlab_runner.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/gitlab_runner.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @Lunik @SamyCoenen @Shaps @dj-wasabi @lgatellier @marwatk @metanovii @nejch @scodeman @sh0shin @suukit @waheedi @zanssa
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
This was introduced in #5930.

CC @cfiehe @nejch

Resolving patch:
diff --git a/plugins/modules/gitlab_runner.py b/plugins/modules/gitlab_runner.py
--- a/plugins/modules/gitlab_runner.py
+++ b/plugins/modules/gitlab_runner.py
@@ -234,9 +234,8 @@ def create_or_update_runner(self, description, options):
             '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 @@ def create_or_update_runner(self, description, options):
                 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


Test patch: