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
48 lines
1.9 KiB
YAML
48 lines
1.9 KiB
YAML
---
|
|
# A forced re-registration minted the token in main.yml before dropping .runner.
|
|
- name: Mint runner token
|
|
ansible.builtin.include_tasks: mint_token.yml
|
|
when: not gitea_runner_force_register | bool
|
|
tags: [gitea_runner, register]
|
|
|
|
# In check mode no token was minted and the register command can't be templated
|
|
# without one, so report the intended registration instead.
|
|
- name: Report runner registration (check mode)
|
|
ansible.builtin.debug:
|
|
msg: >-
|
|
Check mode: would generate a runner token on {{ gitea_runner_token_host }} and register
|
|
{{ gitea_runner_name }} against {{ gitea_runner_instance_url }}
|
|
with scope {{ gitea_runner_registration_scope if gitea_runner_registration_scope | length > 0 else '(instance-wide)' }}
|
|
changed_when: true
|
|
when: ansible_check_mode
|
|
tags: [gitea_runner, register]
|
|
|
|
- name: Register Gitea runner
|
|
when: not ansible_check_mode
|
|
become: true
|
|
tags: [gitea_runner, register]
|
|
block:
|
|
- name: Attempt runner registration
|
|
ansible.builtin.command:
|
|
argv:
|
|
- "{{ gitea_runner_install_dir }}/gitea-runner"
|
|
- register
|
|
- --no-interactive
|
|
- --instance
|
|
- "{{ gitea_runner_instance_url }}"
|
|
- --name
|
|
- "{{ gitea_runner_name }}"
|
|
chdir: "{{ gitea_runner_work_dir }}"
|
|
creates: "{{ gitea_runner_work_dir }}/.runner"
|
|
environment:
|
|
GITEA_RUNNER_REGISTRATION_TOKEN: "{{ gitea_runner_token }}"
|
|
register: gitea_runner_register_cmd
|
|
no_log: true
|
|
notify: Restart Gitea Runner
|
|
rescue:
|
|
- name: Fail with sanitized runner registration error
|
|
ansible.builtin.fail:
|
|
msg: >-
|
|
Gitea runner registration failed (rc={{ gitea_runner_register_cmd.rc | default('unknown') }}):
|
|
{{ gitea_runner_register_cmd.stderr | default('') | regex_replace(gitea_runner_token | regex_escape, '***REDACTED***') }}
|