This repository has been archived on 2024-11-01. You can view files and clone it, but cannot push or open issues or pull requests.
services/_ansible/roles/forgejo_runner/tasks/main.yml

43 lines
1.7 KiB
YAML
Raw Normal View History

2023-12-04 20:36:32 +00:00
---
2023-12-14 01:20:13 +00:00
- name: Set common facts
ansible.builtin.import_tasks: tasks/set-default-facts.yml
2023-12-04 20:36:32 +00:00
- name: Deploy {{ svc.name }}
2023-12-14 01:20:13 +00:00
vars:
svc: "{{ forgejo_runner_svc }}"
env: "{{ forgejo_runner_env }}"
compose: "{{ forgejo_runner_compose }}"
2023-12-04 20:36:32 +00:00
block:
2023-12-13 01:43:15 +00:00
- name: Import tasks to create service directory
ansible.builtin.import_tasks: tasks/steps/create-service-directory.yml
- name: Import tasks to template docker compose file
ansible.builtin.import_tasks: tasks/steps/template-docker-compose.yml
2023-12-04 20:36:32 +00:00
- name: Copy the config
ansible.builtin.copy:
src: config.yml
dest: "{{ (service_path, 'config.yml') | path_join }}"
2023-12-13 01:43:15 +00:00
mode: "0755"
2023-12-04 20:36:32 +00:00
- name: Check if service.env already exists
ansible.builtin.stat:
path: "{{ (service_path, 'service.env') | path_join }}"
2023-12-14 01:20:13 +00:00
register: env_file
2023-12-04 20:36:32 +00:00
2023-12-13 01:43:15 +00:00
- name: Import tasks to prompt for the registration token
ansible.builtin.import_tasks: tasks/prompt-registration-token.yml
2023-12-14 01:20:13 +00:00
when: not env_file.stat.exists or force_forgejo_runner_registration | default(False)
2023-12-04 20:36:32 +00:00
2023-12-13 01:43:15 +00:00
- name: Import tasks create a service.env file
ansible.builtin.import_tasks: tasks/steps/template-service-env.yml
- name: Import start tasks for common service
ansible.builtin.import_tasks: tasks/start-common-service.yml
2023-12-04 20:36:32 +00:00
- name: Register runner
ansible.builtin.command:
2023-12-13 01:43:15 +00:00
cmd: docker compose run --rm -it app sh -c
'forgejo-runner register --no-interactive --token ${FORGEJO_RUNNER_REGISTRATION_TOKEN} --instance ${FORGEJO_INSTANCE_URL}'
2023-12-04 20:36:32 +00:00
chdir: "{{ service_path }}"
2023-12-14 01:20:13 +00:00
when: not env_file.stat.exists or force_forgejo_runner_registration | default(False)
2023-12-13 01:43:15 +00:00
changed_when: true # "when" checks enough. We are sure to change something here.