From 8579a4064f5d914afea62bfa87732953ce873f97 Mon Sep 17 00:00:00 2001 From: Emil Simeonov Date: Sun, 21 Jun 2026 00:00:07 +0200 Subject: [PATCH] fix: guard all systemctl --user tasks with docker_rootless_setup 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> --- ansible/roles/gitea-runner/tasks/integration_test.yml | 7 +++++-- ansible/roles/gitea-runner/tasks/prune.yml | 3 +++ ansible/roles/gitea-runner/tasks/service.yml | 3 +++ ansible/roles/gitea-runner/tasks/update_runner.yml | 4 +++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ansible/roles/gitea-runner/tasks/integration_test.yml b/ansible/roles/gitea-runner/tasks/integration_test.yml index 415bfca..11575ae 100644 --- a/ansible/roles/gitea-runner/tasks/integration_test.yml +++ b/ansible/roles/gitea-runner/tasks/integration_test.yml @@ -26,6 +26,9 @@ 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: @@ -34,12 +37,12 @@ {% if not (runner_file_stat.stat.exists | default(false)) %} - Registration file (.runner) is missing. Registration may have failed. {% endif %} - {% if not (service_check.stdout | default('') | trim) == 'active' %} + {% 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 not (service_check.stdout | default('') | trim) == 'active' + or (docker_rootless_setup and not (service_check.stdout | default('') | trim) == 'active') - name: Report runner status ansible.builtin.debug: diff --git a/ansible/roles/gitea-runner/tasks/prune.yml b/ansible/roles/gitea-runner/tasks/prune.yml index 9f0a666..55e8d5d 100644 --- a/ansible/roles/gitea-runner/tasks/prune.yml +++ b/ansible/roles/gitea-runner/tasks/prune.yml @@ -22,6 +22,9 @@ environment: XDG_RUNTIME_DIR: "/run/user/{{ gitea_runner_uid }}" changed_when: true + when: + - systemd_available.stat.exists + - docker_rootless_setup - name: Enable and start docker-prune user timer ansible.builtin.command: systemctl --user enable --now docker-prune.timer diff --git a/ansible/roles/gitea-runner/tasks/service.yml b/ansible/roles/gitea-runner/tasks/service.yml index 7be5e81..63373c7 100644 --- a/ansible/roles/gitea-runner/tasks/service.yml +++ b/ansible/roles/gitea-runner/tasks/service.yml @@ -14,6 +14,9 @@ environment: XDG_RUNTIME_DIR: "/run/user/{{ gitea_runner_uid }}" changed_when: true + when: + - systemd_available.stat.exists + - docker_rootless_setup - name: Enable and start gitea-runner user service ansible.builtin.command: systemctl --user enable --now gitea-runner diff --git a/ansible/roles/gitea-runner/tasks/update_runner.yml b/ansible/roles/gitea-runner/tasks/update_runner.yml index fbb555c..9b5b7d8 100644 --- a/ansible/roles/gitea-runner/tasks/update_runner.yml +++ b/ansible/roles/gitea-runner/tasks/update_runner.yml @@ -8,5 +8,7 @@ become_user: "{{ gitea_runner_service_user }}" environment: XDG_RUNTIME_DIR: "/run/user/{{ gitea_runner_uid }}" - when: systemd_available.stat.exists | default(false) | bool + when: + - systemd_available.stat.exists | default(false) | bool + - docker_rootless_setup changed_when: true