Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community.general.gitlab_runner KeyError: 'access_level' bug #6112

Closed
1 task done
papdaniel opened this issue Feb 28, 2023 · 4 comments
Closed
1 task done

community.general.gitlab_runner KeyError: 'access_level' bug #6112

papdaniel opened this issue Feb 28, 2023 · 4 comments
Labels
bug This issue/PR relates to a bug gitlab module module plugins plugin (any type) source_control

Comments

@papdaniel
Copy link

papdaniel commented Feb 28, 2023

Summary

Line 237 always gives KeyError:

def create_or_update_runner(self, description, options):
changed = False
arguments = {
'active': options['active'],
'locked': options['locked'],
'run_untagged': options['run_untagged'],
'maximum_timeout': options['maximum_timeout'],
'tag_list': options['tag_list'],
}
if arguments['access_level'] is not None:
arguments['access_level'] = options['access_level']

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

$ 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

$ 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

$ ansible-config dump --only-changed

OS / Environment

No response

Steps to Reproduce

- 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

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

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

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

@ansibullbot ansibullbot added bug This issue/PR relates to a bug gitlab module module plugins plugin (any type) source_control labels Feb 28, 2023
@felixfontein
Copy link
Collaborator

This was introduced in #5930.

CC @cfiehe @nejch

cfiehe pushed a commit to cfiehe/community.general that referenced this issue Mar 2, 2023
…ror: 'access_level'

The fix ensures that no 'KeyError' is raised, when 'access_level' is not provided as module parameter or when 'access_level_on_creation' is false.

Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
@cfiehe
Copy link
Contributor

cfiehe commented Mar 2, 2023

I have fixed the problem and provided a pull request: #6130

@papdaniel @felixfontein @nejch
Sorry for the issue!

cfiehe pushed a commit to cfiehe/community.general that referenced this issue Mar 2, 2023
…ror: 'access_level'

The fix ensures that no 'KeyError' is raised, when 'access_level' is not provided as module parameter or when 'access_level_on_creation' is false.

Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
patchback bot pushed a commit that referenced this issue Mar 4, 2023
…#6130)

The fix ensures that no 'KeyError' is raised, when 'access_level' is not provided as module parameter or when 'access_level_on_creation' is false.

Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
Co-authored-by: Christoph Fiehe <c.fiehe@eurodata.de>
(cherry picked from commit c077818)
felixfontein pushed a commit that referenced this issue Mar 4, 2023
….gitlab_runner KeyError: 'access_level' (#6142)

Fixes #6112: community.general.gitlab_runner KeyError: 'access_level' (#6130)

The fix ensures that no 'KeyError' is raised, when 'access_level' is not provided as module parameter or when 'access_level_on_creation' is false.

Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de>
Co-authored-by: Christoph Fiehe <c.fiehe@eurodata.de>
(cherry picked from commit c077818)

Co-authored-by: cfiehe <cfiehe@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug gitlab module module plugins plugin (any type) source_control
Projects
None yet
Development

No branches or pull requests

4 participants