You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check mode fails due to a code issue in the module regarding the check mode.
Line 519 expects the object called gitlab_runner.runner_object to be an object, however it receives a boolean due to an assignment in the function create_or_update_runnerat line 325, when calling the create_runner function there is check for "check_mode" performed and it returns trueat line 346 instead of a proper runner object, which then breaks at line 519.
main where the exception happens
if gitlab_runner.create_or_update_runner(runner_description, runner_values):
-> module.exit_json(changed=True, runner=gitlab_runner.runner_object._attrs, # Faulty attribute
msg="Successfully created or updated the runner %s" % runner_description)
create_or_update_runner function (from line 325 to the end of it)
-> runner = self.create_runner(arguments) # Assignment happens here
changed = True
else:
changed, runner = self.update_runner(self.runner_object, arguments)
if changed:
if self._module.check_mode:
self._module.exit_json(changed=True, msg="Successfully updated the runner %s" % description)
try:
runner.save()
except Exception as e:
self._module.fail_json(msg="Failed to update runner: %s " % to_native(e))
-> self.runner_object = runner # And then here
return changed
create_runner function (see the return performed for the check_mode)
def create_runner(self, arguments):
if self._module.check_mode:
-> return True # Problematic code
try:
if arguments.get('token') is not None:
runner = self._gitlab.runners.create(arguments)
elif LooseVersion(gitlab.__version__) < LooseVersion('4.0.0'):
self._module.fail_json(msg="New runner creation workflow requires python-gitlab 4.0.0 or higher")
else:
runner = self._gitlab.user.runners.create(arguments)
except (gitlab.exceptions.GitlabCreateError) as e:
self._module.fail_json(msg="Failed to create runner: %s " % to_native(e))
return runner
Issue Type
Bug Report
Component Name
community.general.gitlab_runner module
Ansible Version
2.13.2
Community.general Version
9.4.0
Configuration
No response
OS / Environment
RHEL 9
Steps to Reproduce
Run the community.general.gitlab_runner module in check for the creation of a runner
We use the new API token (not the old registration token, but I don't think it matters)
Expected Results
Check mode doesn't fail
Actual Results
Stack trace:
The full traceback is:
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1726081189.0393121-194-134545082989152/AnsiballZ_gitlab_runner.py", line 107, in <module>
_ansiballz_main()
File "/root/.ansible/tmp/ansible-tmp-1726081189.0393121-194-134545082989152/AnsiballZ_gitlab_runner.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/root/.ansible/tmp/ansible-tmp-1726081189.0393121-194-134545082989152/AnsiballZ_gitlab_runner.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.gitlab_runner', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.gitlab_runner', _modlib_path=modlib_path),
File "<frozen runpy>", line 226, in run_module
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "/tmp/ansible_community.general.gitlab_runner_payload_ing1rl38/ansible_community.general.gitlab_runner_payload.zip/ansible_collections/community/general/plugins/modules/gitlab_runner.py", line 527, in <module>
File "/tmp/ansible_community.general.gitlab_runner_payload_ing1rl38/ansible_community.general.gitlab_runner_payload.zip/ansible_collections/community/general/plugins/modules/gitlab_runner.py", line 519, in main
AttributeError: 'bool' object has no attribute '_attrs'
fatal: [<REDACTED> -> localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1726081189.0393121-194-134545082989152/AnsiballZ_gitlab_runner.py\", line 107, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1726081189.0393121-194-134545082989152/AnsiballZ_gitlab_runner.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1726081189.0393121-194-134545082989152/AnsiballZ_gitlab_runner.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.gitlab_runner', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.gitlab_runner', _modlib_path=modlib_path),\n File \"<frozen runpy>\", line 226, in run_module\n File \"<frozen runpy>\", line 98, in _run_module_code\n File \"<frozen runpy>\", line 88, in _run_code\n File \"/tmp/ansible_community.general.gitlab_runner_payload_ing1rl38/ansible_community.general.gitlab_runner_payload.zip/ansible_collections/community/general/plugins/modules/gitlab_runner.py\", line 527, in <module>\n File \"/tmp/ansible_community.general.gitlab_runner_payload_ing1rl38/ansible_community.general.gitlab_runner_payload.zip/ansible_collections/community/general/plugins/modules/gitlab_runner.py\", line 519, in main\nAttributeError: 'bool' object has no attribute '_attrs'\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
Code of Conduct
I agree to follow the Ansible Code of Conduct
The text was updated successfully, but these errors were encountered:
marcandre-larochelle-bell
changed the title
Gitlab Runner module check mode isn't working properly
community.general.gitlab_runner check mode is throwing an Exception
Sep 11, 2024
russoz
changed the title
community.general.gitlab_runner check mode is throwing an Exception
gitlab_runner: check mode is throwing an Exception
Oct 10, 2024
Summary
Check mode fails due to a code issue in the module regarding the check mode.
Line 519 expects the object called
gitlab_runner.runner_object
to be an object, however it receives a boolean due to an assignment in the functioncreate_or_update_runner
at line 325, when calling thecreate_runner
function there is check for "check_mode" performed and it returnstrue
at line 346 instead of a proper runner object, which then breaks at line 519.main
where the exception happenscreate_or_update_runner
function (from line 325 to the end of it)create_runner
function (see the return performed for the check_mode)Issue Type
Bug Report
Component Name
community.general.gitlab_runner module
Ansible Version
2.13.2
Community.general Version
9.4.0
Configuration
No response
OS / Environment
RHEL 9
Steps to Reproduce
Expected Results
Check mode doesn't fail
Actual Results
Stack trace:
Code of Conduct
The text was updated successfully, but these errors were encountered: