feat: Add labels to runners
All checks were successful
/ ansible-docsmith (push) Successful in 58s

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2026-02-16 07:59:58 +01:00
commit b7199071b1
Signed by: jriou
GPG key ID: 9A099EDA51316854
6 changed files with 41 additions and 23 deletions

View file

@ -78,7 +78,7 @@ The following variables can be configured for this role:
| `forgejo_runners_version` | `str` | No | `"9.1.1"` | Version of the runners | | `forgejo_runners_version` | `str` | No | `"9.1.1"` | Version of the runners |
| `forgejo_runners_config_dir` | `path` | No | `"/etc/forgejo-runners"` | Path to the configuration directory of the runners | | `forgejo_runners_config_dir` | `path` | No | `"/etc/forgejo-runners"` | Path to the configuration directory of the runners |
| `forgejo_runners_instance` | `str` | No | N/A | URL of the Forgejo instance to register the runners | | `forgejo_runners_instance` | `str` | No | N/A | URL of the Forgejo instance to register the runners |
| `forgejo_runners` | `dict` | No | N/A | List of runners to configure<br><br>The key is the name of the repository on the instance<br><br>The value is the token | | `forgejo_runners` | `dict` | No | N/A | List of runners to configure<br><br>The key is the name of the repository on the instance<br><br>The value is a dict with a `token` key and optionally a dict of `labels` |
### `forgejo_server`<a id="variable-forgejo_server"></a> ### `forgejo_server`<a id="variable-forgejo_server"></a>
@ -283,7 +283,7 @@ List of runners to configure
The key is the name of the repository on the instance The key is the name of the repository on the instance
The value is the token The value is a dict with a `token` key and optionally a dict of `labels`
- **Type**: `dict` - **Type**: `dict`
- **Required**: No - **Required**: No
@ -309,6 +309,28 @@ Then run the playbook:
ansible-playbook forgejo.yml ansible-playbook forgejo.yml
``` ```
## Runners
Example of runners configuration:
```yaml
- hosts: forgejo
roles:
- jriou.forgejo
vars:
forgejo_runners:
coller:
token: **redacted**
labels:
debian12: docker://data.forgejo.org/oci/debian:bookworm
debian13: docker://data.forgejo.org/oci/debian:trixie
ansible:
token: **redacted**
labels:
docker: docker://data.forgejo.org/oci/node:latest
```
## Donate ## Donate
As we all love FOSS projects, you should consider [donating to As we all love FOSS projects, you should consider [donating to

View file

@ -113,7 +113,7 @@ forgejo_runners_config_dir: /etc/forgejo-runners
# #
# The key is the name of the repository on the instance # The key is the name of the repository on the instance
# #
# The value is the token # The value is a dict with a `token` key and optionally a dict of `labels`
# #
# - Type: dict # - Type: dict
# - Required: No # - Required: No

View file

@ -102,5 +102,5 @@ argument_specs:
description: description:
- List of runners to configure - List of runners to configure
- The key is the name of the repository on the instance - The key is the name of the repository on the instance
- The value is the token - The value is a dict with a `token` key and optionally a dict of `labels`
type: dict type: dict

View file

@ -18,4 +18,4 @@
- name: deploy runners - name: deploy runners
ansible.builtin.include_tasks: deploy-runners.yml ansible.builtin.include_tasks: deploy-runners.yml
when: forgejo_runners when: forgejo_runners is defined

View file

@ -2,11 +2,11 @@
- name: check variables - name: check variables
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- forgejo_runners_instance | mandatory - forgejo_runners_instance is defined
- forgejo_runners_version | mandatory - forgejo_runners_version is defined
- forgejo_runners_config_dir | mandatory - forgejo_runners_config_dir is defined
- item.key | mandatory - "'key' in item"
- item.value | mandatory - "'value' in item"
- name: create runner subdirectory - name: create runner subdirectory
ansible.builtin.file: ansible.builtin.file:
@ -33,8 +33,7 @@
notify: start runners notify: start runners
- name: create runner configuration - name: create runner configuration
ansible.builtin.copy: ansible.builtin.template:
src: runners/config.yml src: runners/config.yml.j2
dest: "{{ forgejo_runners_config_dir }}/{{ item.key }}/config.yml" dest: "{{ forgejo_runners_config_dir }}/{{ item.key }}/config.yml"
force: false
notify: start runners notify: start runners

View file

@ -1,8 +1,4 @@
# Example configuration file, it's safe to copy this as the default config file without any modification. {{ ansible_managed | comment }}
# You don't have to copy this file to your instance,
# just run `forgejo-runner generate-config > config.yaml` to generate a config file.
log: log:
level: info level: info
job_level: info job_level: info
@ -10,17 +6,18 @@ log:
runner: runner:
file: .runner file: .runner
capacity: 1 capacity: 1
envs:
A_TEST_ENV_NAME_1: a_test_env_value_1
A_TEST_ENV_NAME_2: a_test_env_value_2
env_file: .env
timeout: 3h timeout: 3h
shutdown_timeout: 3h shutdown_timeout: 3h
insecure: false insecure: false
fetch_timeout: 5s fetch_timeout: 5s
fetch_interval: 2s fetch_interval: 2s
report_interval: 1s report_interval: 1s
labels: [] {% if item.value.labels | default({}) %}
labels:
{% for label_name, label_value in item.value.labels.items() %}
- {{ label_name }}: {{ label_value }}
{% endfor %}
{% endif %}
cache: cache:
enabled: true enabled: true