--- argument_specs: main: short_description: Install, register and run a Gitea Actions runner with a Docker executor description: - >- Validates the inputs, then either removes the runner (C(gitea_runner_remove), which ends the role) or creates the runner user, installs Docker and the C(gitea-runner) binary on first install, registers the runner when no C(.runner) file exists, renders C(config.yaml), writes the systemd unit and starts the service. Optionally schedules a Docker prune, updates the binary (C(gitea_runner_update)) with rollback through the internal C(mortis.kamino._binary_update) role, and adds a host-executor label for jobs that use the host's Docker daemon (C(gitea_runner_molecule_enabled)). The role builds no container image. - >- Registration delegates C(gitea actions generate-runner-token) to the inventory host C(gitea_runner_token_host), which must have Gitea installed (for example by C(mortis.kamino.gitea)). The delegated command reads C(gitea_runner_gitea_user), C(gitea_runner_gitea_install_dir) and C(gitea_runner_gitea_app_dir), which must match the Gitea installation on that host; variables of the C(gitea) role do not reach this role. C(gitea_runner_token_host), C(gitea_runner_instance_url) and C(gitea_runner_name) have empty role defaults and are asserted only when registration runs, so a run that never registers is not blocked. - >- Reads gathered facts (C(ansible_date_time), for the forced re-registration backup name) and C(ansible_check_mode). options: gitea_runner_remove: type: bool default: false description: - >- When true the service is stopped and disabled, and the unit file, the binary, the Docker prune units and the prune gate script are removed. The role ends there: nothing is installed, registered or configured in the same run. The runner is not deregistered in Gitea. gitea_runner_remove_data: type: bool default: false description: - Only read while C(gitea_runner_remove) is true. When true C(gitea_runner_work_dir), including the registration file, is deleted. gitea_runner_force_register: type: bool default: false description: - >- When true the registration token is minted first (a failed mint stops before anything is touched). Then, when a registration exists, the previous C(.runner.bak.*) backups are pruned, C(.runner) is copied to C(.runner.bak.) (mode 0600), the service is stopped, C(.runner) is removed and the runner is registered again. Use it after C(gitea_runner_instance_url) or C(gitea_runner_registration_scope) changes. Refused when C(GITHUB_ACTIONS), C(GITEA_ACTIONS) or C(CI) is set on the controller. Under C(--check) nothing is removed or registered. The old runner stays in Gitea as offline; delete it in Site Administration, Actions, Runners. gitea_runner_update: type: bool default: false description: - >- When true the update tasks run after configuration. The installed version is compared with C(gitea_runner_version) and only a difference triggers a verified download to a staging path next to the live binary. The swap is then handed to C(mortis.kamino._binary_update), which stops the service, backs up the live binary, swaps, restarts, checks the version and rolls back on failure. A failed download leaves the runner running. gitea_runner_version: type: str description: - >- Runner release to install, for example C(6.0.1). The role default is a pinned version, see C(defaults/main.yml); pin it in inventory to move the runner independently of Collection releases. - >- Asserted at role start to be C(X.Y.Z) digits only, with no leading C(v): it is used in the download URL and compared with the version the binary reports. gitea_runner_download_url: type: raw description: - >- URL of the runner binary. The role default is a Jinja expression built from C(gitea_runner_version) that points at dl.gitea.com for linux amd64. gitea_runner_checksum_url: type: raw description: - >- URL of the checksum file the runner binary is verified against (sha256) on install and update. It must list the file name of C(gitea_runner_download_url). The role default is the dl.gitea.com C(.sha256) file built from C(gitea_runner_version). gitea_runner_user: type: str default: gitea-runner description: - System user that runs the daemon. Created by the role and added to the C(docker) group. gitea_runner_group: type: str default: gitea-runner description: - Primary group of the runner user and group of its work directory. Created by the role. gitea_runner_home: type: path default: /home/gitea-runner description: - Home of the runner user. gitea_runner_install_dir: type: path default: /usr/local/bin description: - Directory that holds the C(gitea-runner) binary. gitea_runner_work_dir: type: path default: /var/lib/gitea-runner description: - Directory with C(.runner) and C(config.yaml). It is not passed to the runner as a job work directory. gitea_runner_service_unit: type: path default: /etc/systemd/system/gitea-runner.service description: - Path of the systemd unit file. gitea_runner_name: type: str default: "" description: - >- Name the runner registers with. The role default is empty; an empty value fails the registration (C(tasks/mint_token.yml)), so runs that never register are not blocked. gitea_runner_instance_url: type: str default: "" description: - >- Gitea instance the runner registers against, for example C(https://git.example.com/). The role default is empty; an empty value fails the registration (C(tasks/mint_token.yml)), so runs that never register are not blocked. gitea_runner_token_host: type: str default: "" description: - >- Inventory host that has Gitea installed and mints the registration token; the token command is delegated to it. The role default is empty; an empty value, or a host that is not in the inventory, fails the registration. gitea_runner_registration_scope: type: str default: "" description: - >- Scope passed as C(--scope) to C(gitea actions generate-runner-token): an owner (user or organisation) or C(owner/repo). Empty registers an instance-wide runner and passes no C(--scope). The format is asserted at role start. Only read when registering, so on a runner that already has C(.runner) a change takes effect with C(gitea_runner_force_register). gitea_runner_gitea_install_dir: type: path default: /usr/local/bin description: - >- Directory of the C(gitea) binary on C(gitea_runner_token_host), used by the delegated token command. Keep it in step with the Gitea installation on that host. gitea_runner_gitea_user: type: str default: git description: - >- User that runs the delegated token command on C(gitea_runner_token_host). Keep it in step with the Gitea installation on that host. gitea_runner_gitea_app_dir: type: path default: /etc/gitea description: - >- Directory of C(app.ini) on C(gitea_runner_token_host), passed with C(--config) to the delegated token command. Keep it in step with the Gitea installation on that host. gitea_runner_log_level: type: str default: info description: - Value of C(log.level) in C(config.yaml). gitea_runner_capacity: type: int default: 1 description: - Value of C(runner.capacity), the number of jobs run at once. Size the host's memory and cores for it. gitea_runner_labels: type: list elements: str default: [docker, ubuntu-lxc] description: - >- Labels exposed to workflows. The executor and job image come from each label's suffix (C(:host) or C(docker://)); a label with no suffix runs its jobs on the host. When C(gitea_runner_molecule_enabled) is true the label C(:host) is added automatically. gitea_runner_container_privileged: type: bool default: false description: - Value of C(container.privileged). gitea_runner_container_docker_host: type: str default: "unix:///var/run/docker.sock" description: - >- Value of C(container.docker_host). C(-) lets the runner find the daemon but does not mount the socket into job containers. gitea_runner_docker_prune_enabled: type: bool default: false description: - >- When true a systemd timer runs C(gitea-runner-docker-prune.service), which prunes stopped containers, unused images, build cache and anonymous volumes. It is skipped while a container younger than C(gitea_runner_docker_prune_job_max_age) runs. Named volumes are kept. - Setting it back to false leaves the units in place; C(gitea_runner_remove) deletes them. gitea_runner_docker_prune_schedule: type: str default: "Sun *-*-* 04:30:00" description: - >- C(OnCalendar) value of the prune timer. Only read when C(gitea_runner_docker_prune_enabled) is true, and then asserted at role start to hold no newline or C(%). gitea_runner_docker_prune_container_age: type: str default: 24h description: - >- Stopped containers older than this are removed (the C(until) filter of C(docker container prune)). A number with C(s), C(m) or C(h), asserted at role start when the prune is enabled. gitea_runner_docker_prune_image_age: type: str default: 168h description: - >- Unused images and build cache older than this are removed (the C(until) filter). It compares the creation time of the image, not the pull time, so an old-built pinned image that no container uses is removed and pulled again. Same format as C(gitea_runner_docker_prune_container_age). gitea_runner_docker_prune_job_max_age: type: int default: 21600 description: - >- Seconds. The prune is skipped while a container younger than this runs (a job may use it). An older container is treated as a leaked job container: it is logged and ignored. Keep it above the longest job timeout. gitea_runner_docker_prune_keep_per_repository: type: int default: 0 description: - >- Newest image IDs kept per repository, by creation time; C(0) turns the count prune off. Above C(0) the weekly prune and the pressure prune remove every other image no container uses, dangling images included. An image with several tags counts once, and one kept by any of its repositories stays. Only read when C(gitea_runner_docker_prune_enabled) is true. gitea_runner_docker_prune_disk_threshold_percent: type: int default: 0 description: - >- Use, in percent, of the filesystem holding the Docker root above which C(gitea-runner-docker-prune-pressure.service) runs the count prune and a builder prune capped at C(gitea_runner_docker_prune_builder_keep_storage), behind the same job gate as the weekly prune. C(0) turns it off, and setting it back to C(0) stops the timer and removes its units. C(1) to C(99), and above C(0) only with C(gitea_runner_docker_prune_keep_per_repository) above C(0), asserted at role start when the prune is enabled. gitea_runner_docker_prune_disk_check_schedule: type: str default: hourly description: - >- C(OnCalendar) value of the pressure prune timer. Same check as C(gitea_runner_docker_prune_schedule). gitea_runner_docker_prune_builder_keep_storage: type: str default: 10GB description: - >- C(--keep-storage) of the builder prune under disk pressure: the build cache kept. A number with an optional C(B), C(KB), C(MB), C(GB) or C(TB), asserted at role start when the prune is enabled. gitea_runner_container_volumes: type: list elements: str description: - Extra mounts for job containers, rendered as C(container.volumes). No role default exists and the key is omitted when undefined. gitea_runner_molecule_enabled: type: bool default: false description: - >- When true the C(:host) label is added to the runner and C(git) and C(python3) are installed on the host. A job on that label runs on the host and uses its Docker daemon; it brings its own toolchain in an image, and the role installs no test tooling. The runner user is in the C(docker) group, so a job on that label is root-equivalent on the host. gitea_runner_molecule_label: type: str default: molecule description: - Name of the host-executor label, registered as C(