--- - name: Initial one-time setup for the Gitea Actions Runner hosts: gitrunner become: true vars: gitea_runner_version: "3.5.0" # Token has to be generated here (site-wide scope): # https://git.phyllo.me/admin/actions/runners (Site Administration) # A token minted under a user's Settings -> Actions -> Runners is # USER-scoped: the runner registers and shows online but never picks up # jobs from org repos (they stay `queued`, runner_id 0). Paste it here: # registration_token: "" registration_token: "" tasks: - name: Create act runner user ansible.builtin.user: name: "act_runner" system: true shell: /bin/bash home: "/var/lib/act_runner" create_home: true state: present - name: Create /etc/act_runner directory ansible.builtin.file: path: /etc/act_runner state: directory owner: "act_runner" group: "act_runner" mode: "0755" - name: Install Gitea Runner ansible.builtin.get_url: url: "https://gitea.com/gitea/gitea-runner/releases/download/v{{ gitea_runner_version }}/gitea-runner-{{ gitea_runner_version }}-linux-amd64" dest: "/usr/local/bin/gitea-runner" mode: "0755" force: "{{ (ansible_facts['cmdline']['force'] is defined) | default(false) }}" retries: 3 delay: 5 - name: Create Gitea Runner configuration file ansible.builtin.copy: content: | log: level: info runner: file: "/var/lib/act_runner/.runner" capacity: 4 timeout: 3h shutdown_timeout: 0s insecure: false fetch_timeout: 5s fetch_interval: 2s github_mirror: '' labels: - "fedora:host" cache: enabled: true dir: /var/lib/act_runner/.act-runner/actcache host: "" port: 0 external_server: "" container: network: "" privileged: true options: workdir_parent: valid_volumes: [] docker_host: "" force_pull: true force_rebuild: false require_docker: false docker_timeout: 0s host: workdir_parent: /var/lib/act_runner/act-runner/workdir dest: /etc/act_runner/config.yaml owner: "act_runner" group: "act_runner" mode: "0755" backup: true register: config_file - name: Check if runner is already registered ansible.builtin.stat: path: /var/lib/act_runner/.runner register: runner_registered changed_when: false - name: Register the runner with Gitea (if not already registered) ansible.builtin.command: > /usr/local/bin/gitea-runner register --no-interactive --config /etc/act_runner/config.yaml --instance https://git.phyllo.me --token {{ registration_token }} --name fedora-nuc when: not runner_registered.stat.exists changed_when: true notify: restart act runner service - name: Create Act Runner service file ansible.builtin.copy: content: | [Unit] Description=Gitea Actions Runner Documentation=https://gitea.com/gitea/gitea-runner After=network.target [Service] ExecStart=/usr/local/bin/gitea-runner daemon --config /etc/act_runner/config.yaml ExecReload=/bin/kill -s HUP $MAINPID WorkingDirectory=/var/lib/act_runner TimeoutSec=0 Restart=always RestartSec=10 [Install] WantedBy=multi-user.target dest: /etc/systemd/system/act_runner.service mode: "0644" backup: true notify: restart act runner service - name: Ensure act_runner service is enabled and started ansible.builtin.systemd: name: act_runner enabled: true state: started daemon_reload: true