feat(gitea_runner): add the gitea_runner role
Copied from the maintainer's local role and reworked for the Collection: the binary swap and rollback of an update go through the internal _binary_update role, input checks move to tasks/validate.yml, the removal ends the role, commands take argv, and the molecule tooling needs an explicit collections requirements file. Adds a molecule scenario with stub Docker, runner and release files. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
This commit is contained in:
1 parent
3ed614e00e
commit
e296eea609
28 files changed
+1988
-3
No files matched your search
@@ -0,0 +1,46 @@
|
||||
---
|
||||
# The registration inputs have empty role defaults; refuse to register without them.
|
||||
- name: Require registration inputs
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- gitea_runner_token_host | length > 0
|
||||
- gitea_runner_token_host in groups['all']
|
||||
- gitea_runner_instance_url | length > 0
|
||||
- gitea_runner_name | length > 0
|
||||
fail_msg: >-
|
||||
Registration needs gitea_runner_token_host (inventory host with Gitea that mints the token;
|
||||
it must be a host in the inventory), gitea_runner_instance_url and gitea_runner_name.
|
||||
Set them in group_vars or host_vars.
|
||||
tags: [gitea_runner, register]
|
||||
|
||||
# Nothing here may run under --check: the token is a live credential minted on the
|
||||
# Gitea server. register.yml reports the intended registration instead.
|
||||
- name: Mint the token on the token host
|
||||
when: not ansible_check_mode
|
||||
block:
|
||||
# argv: no value passes through a command string.
|
||||
- name: Generate runner token
|
||||
delegate_to: "{{ gitea_runner_token_host }}"
|
||||
become: true
|
||||
no_log: true
|
||||
ansible.builtin.command:
|
||||
argv: >-
|
||||
{{ ['sudo', '-u', gitea_runner_gitea_user, gitea_runner_gitea_install_dir ~ '/gitea',
|
||||
'--config', gitea_runner_gitea_app_dir ~ '/app.ini', 'actions', 'generate-runner-token']
|
||||
+ (['--scope', gitea_runner_registration_scope] if gitea_runner_registration_scope | length > 0 else []) }}
|
||||
register: gitea_runner_token_cmd
|
||||
failed_when: gitea_runner_token_cmd.rc != 0 or gitea_runner_token_cmd.stdout is not search('\S+')
|
||||
changed_when: false
|
||||
tags: [gitea_runner, register]
|
||||
|
||||
- name: Set runner token
|
||||
no_log: true
|
||||
ansible.builtin.set_fact:
|
||||
gitea_runner_token: "{{ gitea_runner_token_cmd.stdout | regex_search('([a-zA-Z0-9]+)', '\\1') | first }}"
|
||||
tags: [gitea_runner, register]
|
||||
|
||||
- name: Fail if runner token extraction failed
|
||||
ansible.builtin.fail:
|
||||
msg: "Failed to extract Gitea runner token"
|
||||
when: gitea_runner_token is not defined or gitea_runner_token | length == 0
|
||||
tags: [gitea_runner, register]
|
||||
Reference in new issue
Block a user