579 lines
18 KiB
YAML
579 lines
18 KiB
YAML
|
---
|
||
|
- name: Set concurrent limit option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*limit ='
|
||
|
line: ' limit = {{ gitlab_runner.concurrent_specific|default(0) }}'
|
||
|
state: present
|
||
|
insertafter: '^\s*name ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set coordinator URL
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*url ='
|
||
|
line: ' url = {{ gitlab_runner_coordinator_url | to_json }}'
|
||
|
state: present
|
||
|
insertafter: '^\s*limit ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set clone URL
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*clone_url ='
|
||
|
line: ' clone_url = {{ gitlab_runner.clone_url | to_json }}'
|
||
|
state: present
|
||
|
insertafter: '^\s*url ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
when: gitlab_runner.clone_url is defined
|
||
|
|
||
|
- name: Set environment option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*environment ='
|
||
|
line: ' environment = {{ gitlab_runner.env_vars|default([]) | to_json }}'
|
||
|
state: present
|
||
|
insertafter: '^\s*url ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set pre_clone_script
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*pre_clone_script ='
|
||
|
line: ' pre_clone_script = {{ gitlab_runner.pre_clone_script | to_json }}'
|
||
|
state: present
|
||
|
insertafter: '^\s*url ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
when: gitlab_runner.pre_clone_script is defined
|
||
|
|
||
|
- name: Set pre_build_script
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*pre_build_script ='
|
||
|
line: ' pre_build_script = {{ gitlab_runner.pre_build_script | to_json }}'
|
||
|
state: present
|
||
|
insertafter: '^\s*url ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
when: gitlab_runner.pre_build_script is defined
|
||
|
|
||
|
- name: Set post_build_script
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*post_build_script ='
|
||
|
line: ' post_build_script = {{ gitlab_runner.post_build_script | to_json }}'
|
||
|
state: present
|
||
|
insertafter: '^\s*url ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
when: gitlab_runner.post_build_script is defined
|
||
|
|
||
|
- name: Set runner executor option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*executor ='
|
||
|
line: ' executor = {{ gitlab_runner.executor|default("shell") | to_json }}'
|
||
|
state: present
|
||
|
insertafter: '^\s*url ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set runner shell option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*shell ='
|
||
|
line: ' shell = {{ gitlab_runner.shell|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.shell is defined else 'absent' }}"
|
||
|
insertafter: '^\s*executor ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set runner executor section
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*\[runners\.{{ gitlab_runner.executor|default("shell") }}\]'
|
||
|
line: ' [runners.{{ gitlab_runner.executor|replace("docker+machine","machine")|default("shell") }}]'
|
||
|
state: "{{ 'absent' if (gitlab_runner.executor|default('shell')) == 'shell' else 'present' }}"
|
||
|
insertafter: '^\s*executor ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set output_limit option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*output_limit ='
|
||
|
line: ' output_limit = {{ gitlab_runner.output_limit|default(4096) }}'
|
||
|
state: present
|
||
|
insertafter: '^\s*executor ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
|
||
|
#### [runners.docker] section ####
|
||
|
- name: Set runner docker image option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*image ='
|
||
|
line: ' image = {{ gitlab_runner.docker_image|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.docker_image is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.docker\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set docker privileged option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*privileged ='
|
||
|
line: ' privileged = {{ gitlab_runner.docker_privileged|default(false) | lower }}'
|
||
|
state: "{{ 'present' if gitlab_runner.docker_privileged is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.docker\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set docker tlsverify option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*tls_verify ='
|
||
|
line: ' tls_verify = {{ gitlab_runner.docker_tlsverify|default(false) | lower }}'
|
||
|
state: "{{ 'present' if gitlab_runner.docker_tlsverify is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.docker\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set docker DNS option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*dns ='
|
||
|
line: ' dns = {{ gitlab_runner.docker_dns|default(false) | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.docker_dns is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.docker\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set docker volumes option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*volumes ='
|
||
|
line: ' volumes = {{ gitlab_runner.docker_volumes|default([])|to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.docker_volumes is defined else 'absent' }}"
|
||
|
insertafter: '^\s*executor ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set runner docker network option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*network_mode ='
|
||
|
line: ' network_mode = {{ gitlab_runner.docker_network_mode|default("bridge") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.docker_network_mode is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.docker\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
|
||
|
#### [runners.cache] section ####
|
||
|
- name: Set cache section
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*\[runners\.cache\]'
|
||
|
line: ' [runners.cache]'
|
||
|
state: present
|
||
|
insertafter: EOF
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache s3 section
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*\[runners\.cache\.s3\]'
|
||
|
line: ' [runners.cache.s3]'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_type is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache gcs section
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*\[runners\.cache\.gcs\]'
|
||
|
line: ' [runners.cache.gcs]'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_gcs_bucket_name is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache type option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*Type ='
|
||
|
line: ' Type = {{ gitlab_runner.cache_type|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_type is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache path option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*Path ='
|
||
|
line: ' Path = {{ gitlab_runner.cache_path|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_path is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache shared option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*Shared ='
|
||
|
line: ' Shared = {{ gitlab_runner.cache_shared|default("") | lower }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_shared is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
|
||
|
#### [runners.cache.s3] section ####
|
||
|
- name: Set cache s3 server addresss
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*ServerAddress ='
|
||
|
line: ' ServerAddress = {{ gitlab_runner.cache_s3_server_address|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_s3_server_address is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\.s3\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache s3 access key
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*AccessKey ='
|
||
|
line: ' AccessKey = {{ gitlab_runner.cache_s3_access_key|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_s3_access_key is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\.s3\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache s3 secret key
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*SecretKey ='
|
||
|
line: ' SecretKey = {{ gitlab_runner.cache_s3_secret_key|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_s3_secret_key is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\.s3\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache s3 bucket name option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*BucketName ='
|
||
|
line: ' BucketName = {{ gitlab_runner.cache_s3_bucket_name|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_s3_bucket_name is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\.s3\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
when: gitlab_runner.cache_type is defined and gitlab_runner.cache_type == 's3'
|
||
|
|
||
|
- name: Set cache s3 bucket location option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*BucketLocation ='
|
||
|
line: ' BucketLocation = {{ gitlab_runner.cache_s3_bucket_location|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_s3_bucket_location is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\.s3\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache s3 insecure option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*Insecure ='
|
||
|
line: ' Insecure = {{ gitlab_runner.cache_s3_insecure|default("") | lower }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_s3_insecure is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\.s3\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
|
||
|
#### [runners.cache.gcs] section ####
|
||
|
- name: Set cache gcs bucket name
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*BucketName ='
|
||
|
line: ' BucketName = {{ gitlab_runner.cache_gcs_bucket_name|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_gcs_bucket_name is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\.gcs\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
when: gitlab_runner.cache_type is defined and gitlab_runner.cache_type == 'gcs'
|
||
|
|
||
|
- name: Set cache gcs credentials file
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*CredentialsFile ='
|
||
|
line: ' CredentialsFile = {{ gitlab_runner.cache_gcs_credentials_file|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_gcs_credentials_file is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\.gcs\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache gcs access id
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*AccessID ='
|
||
|
line: ' AccessID = {{ gitlab_runner.cache_gcs_access_id|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_gcs_access_id is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\.gcs\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache gcs private key
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*PrivateKey ='
|
||
|
line: ' PrivateKey = {{ gitlab_runner.cache_gcs_private_key|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_gcs_private_key is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.cache\.gcs\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
|
||
|
#### [runners.ssh] section #####
|
||
|
- name: Set ssh user option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*user ='
|
||
|
line: ' user = {{ gitlab_runner.ssh_user|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.ssh_user is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.ssh\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set ssh host option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*host ='
|
||
|
line: ' host = {{ gitlab_runner.ssh_host|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.ssh_host is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.ssh\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set ssh port option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*port ='
|
||
|
line: ' port = "{{ gitlab_runner.ssh_port|default("") | to_json }}"'
|
||
|
state: "{{ 'present' if gitlab_runner.ssh_port is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.ssh\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set ssh password option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*password ='
|
||
|
line: ' password = {{ gitlab_runner.ssh_password|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.ssh_password is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.ssh\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set ssh identity file option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*identity_file ='
|
||
|
line: ' identity_file = {{ gitlab_runner.ssh_identity_file|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.ssh_identity_file is defined else 'absent' }}"
|
||
|
insertafter: '^\s*\[runners\.ssh\]'
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set builds dir file option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*builds_dir ='
|
||
|
line: ' builds_dir = {{ gitlab_runner.builds_dir|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.builds_dir is defined else 'absent' }}"
|
||
|
insertafter: '^\s*executor ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Set cache dir file option
|
||
|
lineinfile:
|
||
|
dest: "{{ temp_runner_config.path }}"
|
||
|
regexp: '^\s*cache_dir ='
|
||
|
line: ' cache_dir = {{ gitlab_runner.cache_dir|default("") | to_json }}'
|
||
|
state: "{{ 'present' if gitlab_runner.cache_dir is defined else 'absent' }}"
|
||
|
insertafter: '^\s*executor ='
|
||
|
backrefs: no
|
||
|
check_mode: no
|
||
|
notify:
|
||
|
- restart_gitlab_runner
|
||
|
- restart_gitlab_runner_macos
|
||
|
|
||
|
- name: Ensure directory permissions
|
||
|
file:
|
||
|
dest: "{{ item }}"
|
||
|
state: directory
|
||
|
owner: "{{ gitlab_runner_runtime_owner|default(omit) }}"
|
||
|
group: "{{ gitlab_runner_runtime_group|default(omit) }}"
|
||
|
mode: 0770
|
||
|
modification_time: preserve
|
||
|
access_time: preserve
|
||
|
recurse: yes
|
||
|
loop:
|
||
|
- "{{ gitlab_runner.builds_dir | default(\"\") }}"
|
||
|
- "{{ gitlab_runner.cache_dir | default(\"\") }}"
|
||
|
when: item|length
|
||
|
|
||
|
- name: Ensure directory access test
|
||
|
command: "/usr/bin/test -r {{ item }}"
|
||
|
loop:
|
||
|
- "{{ gitlab_runner.builds_dir | default(\"\") }}"
|
||
|
- "{{ gitlab_runner.cache_dir | default(\"\") }}"
|
||
|
when: item|length
|
||
|
changed_when: False
|
||
|
become: yes
|
||
|
become_user: "{{ gitlab_runner_runtime_owner|default(omit) }}"
|
||
|
register: ensure_directory_access
|
||
|
ignore_errors: true
|
||
|
|
||
|
- name: Ensure directory access fail on error
|
||
|
fail:
|
||
|
msg: "Error: user gitlab-runner failed to test access to {{ item.item }}. Check parent folder(s) permissions"
|
||
|
loop: "{{ ensure_directory_access.results }}"
|
||
|
when:
|
||
|
- item.rc is defined and item.rc != 0
|
||
|
|
||
|
- include: section-config-runner.yml
|
||
|
loop: "{{ gitlab_runner.extra_configs|list }}"
|
||
|
loop_control:
|
||
|
loop_var: section
|
||
|
when:
|
||
|
- gitlab_runner.extra_configs is defined
|
||
|
- gitlab_runner.extra_configs|list|length > 0
|