homeserver/roles/riemers.gitlab-runner/tasks/config-runners.yml

35 lines
980 B
YAML

---
- name: Get existing config.toml
slurp:
src: "{{ gitlab_runner_config_file }}"
register: runner_config_file
become: "{{ gitlab_runner_system_mode }}"
- name: Get pre-existing runner configs
set_fact:
runner_configs: "{{ (runner_config_file['content'] | b64decode).split('[[runners]]\n') }}"
- name: Create temporary directory
tempfile:
state: directory
suffix: gitlab-runner-config
register: temp_runner_config_dir
check_mode: no
changed_when: false
- name: Write config section for each runner
include_tasks: config-runner.yml
loop: "{{ runner_configs }}"
loop_control:
index_var: runner_config_index
loop_var: runner_config
- name: Assemble new config.toml
assemble:
src: "{{ temp_runner_config_dir.path }}"
dest: "{{ gitlab_runner_config_file }}"
delimiter: '[[runners]]\n'
backup: yes
validate: "{{ gitlab_runner_executable }} verify -c %s"
mode: 0600
become: "{{ gitlab_runner_system_mode }}"