The daemon-reload, service restart, and service check tasks in service.yml, prune.yml, update_runner.yml, and integration_test.yml were not guarded by docker_rootless_setup. In CI containers without a systemd user bus, these tasks fail with "Failed to connect to bus". Also fix the integration_test.yml validation task to not fail on service status when docker_rootless_setup is false. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
103 lines
3.9 KiB
YAML
103 lines
3.9 KiB
YAML
---
|
|
- name: Check runner registration file exists
|
|
ansible.builtin.stat:
|
|
path: "{{ gitea_runner_data_dir }}/.runner"
|
|
register: runner_file_stat
|
|
|
|
- name: Read runner registration file
|
|
ansible.builtin.slurp:
|
|
src: "{{ gitea_runner_data_dir }}/.runner"
|
|
register: runner_file_content
|
|
when: runner_file_stat.stat.exists | default(false) | bool
|
|
|
|
- name: Parse runner registration data
|
|
ansible.builtin.set_fact:
|
|
runner_reg: >
|
|
{{ (runner_file_content.content | b64decode | from_json)
|
|
if (runner_file_content is defined and runner_file_content.content is defined)
|
|
else {} }}
|
|
when: runner_file_stat.stat.exists | default(false) | bool
|
|
|
|
- name: Verify runner user service active
|
|
ansible.builtin.command: systemctl --user is-active gitea-runner
|
|
become: true
|
|
become_user: "{{ gitea_runner_service_user }}"
|
|
environment:
|
|
XDG_RUNTIME_DIR: "/run/user/{{ gitea_runner_uid }}"
|
|
register: service_check
|
|
changed_when: false
|
|
when:
|
|
- systemd_available.stat.exists
|
|
- docker_rootless_setup
|
|
|
|
- name: Validate runner installation
|
|
ansible.builtin.fail:
|
|
msg: >
|
|
Runner '{{ runner_name }}' is not properly installed:
|
|
{% if not (runner_file_stat.stat.exists | default(false)) %}
|
|
- Registration file (.runner) is missing. Registration may have failed.
|
|
{% endif %}
|
|
{% if docker_rootless_setup and not (service_check.stdout | default('') | trim) == 'active' %}
|
|
- Systemd user service is not active.
|
|
{% endif %}
|
|
when: >
|
|
not (runner_file_stat.stat.exists | default(false))
|
|
or (docker_rootless_setup and not (service_check.stdout | default('') | trim) == 'active')
|
|
|
|
- name: Report runner status
|
|
ansible.builtin.debug:
|
|
msg: >
|
|
Runner '{{ runner_name }}' is installed and running.
|
|
Registered: {{ runner_file_stat.stat.exists | default(false) }}
|
|
{% if runner_reg.id is defined %}Runner ID: {{ runner_reg.id }}{% endif %}
|
|
{% if runner_reg.uuid is defined %}UUID: {{ runner_reg.uuid }}{% endif %}
|
|
{% if runner_reg.address is defined %}Gitea: {{ runner_reg.address }}{% endif %}
|
|
Service: {{ service_check.stdout | default('unknown') | trim }}
|
|
|
|
- name: Optional Gitea API verification
|
|
when:
|
|
- gitea_url is defined
|
|
- gitea_admin_token is defined
|
|
- gitea_admin_token | length > 0
|
|
block:
|
|
- name: Check admin runners API
|
|
ansible.builtin.uri:
|
|
url: "{{ gitea_url }}/api/v1/admin/runners"
|
|
headers:
|
|
Authorization: "token {{ gitea_admin_token }}"
|
|
method: GET
|
|
status_code: [200, 401, 403, 404]
|
|
return_content: true
|
|
body_format: json
|
|
register: admin_api_response
|
|
ignore_errors: true
|
|
|
|
- name: Check repo runners API
|
|
ansible.builtin.uri:
|
|
url: "{{ gitea_url }}/api/v1/repos/{{ gitea_runner_test_repo | default('oblachno-oss/grm') }}/actions/runners"
|
|
headers:
|
|
Authorization: "token {{ gitea_admin_token }}"
|
|
method: GET
|
|
status_code: [200, 401, 403, 404]
|
|
return_content: true
|
|
body_format: json
|
|
register: repo_api_response
|
|
ignore_errors: true
|
|
|
|
- name: Report API status (informational only)
|
|
ansible.builtin.debug:
|
|
msg: >
|
|
API checks (informational only — not used for pass/fail):
|
|
Admin API: {{ admin_api_response.status | default('no response') }}.
|
|
Repo API: {{ repo_api_response.status | default('no response') }}.
|
|
{% if admin_api_response.json.runners | default([]) | selectattr('name', 'equalto', runner_name) | list | length > 0 %}
|
|
Runner found in admin API.
|
|
{% endif %}
|
|
{% if repo_api_response.json.runners | default([]) | selectattr('name', 'equalto', runner_name) | list | length > 0 %}
|
|
Runner found in repo API.
|
|
{% endif %}
|
|
rescue:
|
|
- name: API check failed
|
|
ansible.builtin.debug:
|
|
msg: "API verification skipped due to connection or permission error."
|