|
23 | 23 | become: "{{ gitlab_runner_system_mode }}"
|
24 | 24 | when: (verified_runners.stderr.find("Verifying runner... is removed") != -1)
|
25 | 25 |
|
| 26 | +- name: Construct the runner command without secrets |
| 27 | + # makes the command visible in awx without the secrets and therefore helps with debugging |
| 28 | + set_fact: |
| 29 | + command: > |
| 30 | + {{ gitlab_runner_executable }} register |
| 31 | + --non-interactive |
| 32 | + --url '{{ gitlab_runner.url|default(gitlab_runner_coordinator_url) }}' |
| 33 | + --description '{{ gitlab_runner.name|default(ansible_hostname+"-"+gitlab_runner_index|string) }}' |
| 34 | + --tag-list '{{ gitlab_runner.tags|default([]) | join(",") }}' |
| 35 | + {% if gitlab_runner.clone_url|default(false) %} |
| 36 | + --clone-url "{{ gitlab_runner.clone_url }}" |
| 37 | + {% endif %} |
| 38 | + {% if gitlab_runner.run_untagged|default(true) %} |
| 39 | + --run-untagged |
| 40 | + {% endif %} |
| 41 | + --executor '{{ gitlab_runner.executor|default("shell") }}' |
| 42 | + {% if gitlab_runner.shell is defined %} |
| 43 | + --shell '{{ gitlab_runner.shell }}' |
| 44 | + {% endif %} |
| 45 | + --limit '{{ gitlab_runner.concurrent_specific|default(0) }}' |
| 46 | + --output-limit '{{ gitlab_runner.output_limit|default(4096) }}' |
| 47 | + --locked='{{ gitlab_runner.locked|default(false) }}' |
| 48 | + {% for env_var in gitlab_runner.env_vars|default([]) %} |
| 49 | + --env '{{ env_var }}' |
| 50 | + {% endfor %} |
| 51 | + {% if gitlab_runner.pre_clone_script|default(false) %} |
| 52 | + --pre-clone-script "{{ gitlab_runner.pre_clone_script }}" |
| 53 | + {% endif %} |
| 54 | + {% if gitlab_runner.pre_build_script|default(false) %} |
| 55 | + --pre-build-script "{{ gitlab_runner.pre_build_script }}" |
| 56 | + {% endif %} |
| 57 | + {% if gitlab_runner.tls_ca_file|default(false) %} |
| 58 | + --tls-ca-file "{{ gitlab_runner.tls_ca_file }}" |
| 59 | + {% endif %} |
| 60 | + {% if gitlab_runner.post_build_script|default(false) %} |
| 61 | + --post-build-script "{{ gitlab_runner.post_build_script }}" |
| 62 | + {% endif %} |
| 63 | + --docker-image '{{ gitlab_runner.docker_image|default("alpine") }}' |
| 64 | + {% if gitlab_runner.docker_privileged|default(false) %} |
| 65 | + --docker-privileged |
| 66 | + {% endif %} |
| 67 | + {% if gitlab_runner.docker_wait_for_services_timeout|default(false) %} |
| 68 | + --docker-wait-for-services-timeout '{{ gitlab_runner.docker_wait_for_services_timeout|default(30) }}' |
| 69 | + {% endif %} |
| 70 | + {% if gitlab_runner.docker_tlsverify|default(false) %} |
| 71 | + --docker-tlsverify '{{ gitlab_runner.docker_tlsverify|default("true") }}' |
| 72 | + {% endif %} |
| 73 | + {% if gitlab_runner.docker_disable_cache|default(false) %} |
| 74 | + --docker-disable-cache '{{ gitlab_runner.docker_disable_cache|default("false") }}' |
| 75 | + {% endif %} |
| 76 | + {% if gitlab_runner.docker_dns|default(false) %} |
| 77 | + --docker-dns '{{ gitlab_runner.docker_dns|default("1.1.1.1") }}' |
| 78 | + {% endif %} |
| 79 | + {% if gitlab_runner.docker_dns_search|default(false) %} |
| 80 | + --docker-dns-search '{{ gitlab_runner.docker_dns_search|default([]) }}' |
| 81 | + {% endif %} |
| 82 | + {% if gitlab_runner.docker_disable_cache|default(false) %} |
| 83 | + --docker-disable-cache |
| 84 | + {% endif %} |
| 85 | + {% if gitlab_runner.docker_oom_kill_disable|default(false) %} |
| 86 | + --docker-oom-kill-disable '{{ gitlab_runner.docker_oom_kill_disable|default("false") }}' |
| 87 | + {% endif %} |
| 88 | + {% for policy in gitlab_runner.docker_pull_policy|default([]) %} |
| 89 | + --docker-pull-policy "{{ policy }}" |
| 90 | + {% endfor %} |
| 91 | + {% for volume in gitlab_runner.docker_volumes|default([]) %} |
| 92 | + --docker-volumes "{{ volume }}" |
| 93 | + {% endfor %} |
| 94 | + {% for device in gitlab_runner.docker_devices|default([]) %} |
| 95 | + --docker-devices "{{ device }}" |
| 96 | + {% endfor %} |
| 97 | + --ssh-user '{{ gitlab_runner.ssh_user|default("") }}' |
| 98 | + --ssh-host '{{ gitlab_runner.ssh_host|default("") }}' |
| 99 | + --ssh-port '{{ gitlab_runner.ssh_port|default("") }}' |
| 100 | + --ssh-identity-file '{{ gitlab_runner.ssh_identity_file|default("") }}' |
| 101 | + {% if gitlab_runner.executor == "virtualbox" and gitlab_runner.virtualbox_base_name %} |
| 102 | + --virtualbox-base-name '{{ gitlab_runner.virtualbox_base_name }}' |
| 103 | + --virtualbox-base-snapshot '{{ gitlab_runner.virtualbox_base_snapshot|default("") }}' |
| 104 | + --virtualbox-base-folder '{{ gitlab_runner.virtualbox_base_folder|default("") }}' |
| 105 | + --virtualbox-disable-snapshots '{{ gitlab_runner.virtualbox_disable_snapshots|default(false) }}' |
| 106 | + {% endif %} |
| 107 | + {% if gitlab_runner.cache_type is defined %} |
| 108 | + --cache-type '{{ gitlab_runner.cache_type }}' |
| 109 | + {% endif %} |
| 110 | + {% if gitlab_runner.cache_shared|default(false) %} |
| 111 | + --cache-shared |
| 112 | + {% endif %} |
| 113 | + {% if gitlab_runner.cache_path is defined %} |
| 114 | + --cache-path '{{ gitlab_runner.cache_path }}' |
| 115 | + {% endif %} |
| 116 | + {% if gitlab_runner.cache_s3_server_address is defined %} |
| 117 | + --cache-s3-server-address '{{ gitlab_runner.cache_s3_server_address }}' |
| 118 | + {% if gitlab_runner.cache_s3_access_key is defined %} |
| 119 | + --cache-s3-access-key '{{ gitlab_runner.cache_s3_access_key }}' |
| 120 | + {% endif %} |
| 121 | + {% endif %} |
| 122 | + {% if gitlab_runner.cache_s3_bucket_name is defined %} |
| 123 | + --cache-s3-bucket-name '{{ gitlab_runner.cache_s3_bucket_name }}' |
| 124 | + {% endif %} |
| 125 | + {% if gitlab_runner.cache_s3_bucket_location is defined %} |
| 126 | + --cache-s3-bucket-location '{{ gitlab_runner.cache_s3_bucket_location }}' |
| 127 | + {% endif %} |
| 128 | + {% if gitlab_runner.builds_dir|default(false) %} |
| 129 | + --builds-dir '{{ gitlab_runner.builds_dir }}' |
| 130 | + {% endif %} |
| 131 | + {% if gitlab_runner.custom_build_dir_enabled|default(false) %} |
| 132 | + --custom_build_dir-enabled '{{ gitlab_runner.custom_build_dir_enabled }}' |
| 133 | + {% endif %} |
| 134 | + {% if gitlab_runner.cache_dir|default(false) %} |
| 135 | + --cache-dir '{{ gitlab_runner.cache_dir }}' |
| 136 | + {% endif %} |
| 137 | + {% if gitlab_runner.cache_s3_insecure|default(false) %} |
| 138 | + --cache-s3-insecure |
| 139 | + {% endif %} |
| 140 | + {% if gitlab_runner.extra_registration_option is defined %} |
| 141 | + {{ gitlab_runner.extra_registration_option }} |
| 142 | + {% endif %} |
| 143 | +
|
26 | 144 | - name: Register runner to GitLab
|
27 | 145 | command: >
|
28 |
| - {{ gitlab_runner_executable }} register |
29 |
| - --non-interactive |
30 |
| - --url '{{ gitlab_runner.url|default(gitlab_runner_coordinator_url) }}' |
| 146 | + {{ command }} |
31 | 147 | --registration-token '{{ gitlab_runner.token|default(gitlab_runner_registration_token) }}'
|
32 |
| - --description '{{ gitlab_runner.name|default(ansible_hostname+"-"+gitlab_runner_index|string) }}' |
33 |
| - --tag-list '{{ gitlab_runner.tags|default([]) | join(",") }}' |
34 |
| - {% if gitlab_runner.clone_url|default(false) %} |
35 |
| - --clone-url "{{ gitlab_runner.clone_url }}" |
36 |
| - {% endif %} |
37 |
| - {% if gitlab_runner.run_untagged|default(true) %} |
38 |
| - --run-untagged |
39 |
| - {% endif %} |
40 |
| - --executor '{{ gitlab_runner.executor|default("shell") }}' |
41 |
| - {% if gitlab_runner.shell is defined %} |
42 |
| - --shell '{{ gitlab_runner.shell }}' |
43 |
| - {% endif %} |
44 |
| - --limit '{{ gitlab_runner.concurrent_specific|default(0) }}' |
45 |
| - --output-limit '{{ gitlab_runner.output_limit|default(4096) }}' |
46 |
| - --locked='{{ gitlab_runner.locked|default(false) }}' |
47 |
| - {% for env_var in gitlab_runner.env_vars|default([]) %} |
48 |
| - --env '{{ env_var }}' |
49 |
| - {% endfor %} |
50 |
| - {% if gitlab_runner.pre_clone_script|default(false) %} |
51 |
| - --pre-clone-script "{{ gitlab_runner.pre_clone_script }}" |
52 |
| - {% endif %} |
53 |
| - {% if gitlab_runner.pre_build_script|default(false) %} |
54 |
| - --pre-build-script "{{ gitlab_runner.pre_build_script }}" |
55 |
| - {% endif %} |
56 |
| - {% if gitlab_runner.tls_ca_file|default(false) %} |
57 |
| - --tls-ca-file "{{ gitlab_runner.tls_ca_file }}" |
58 |
| - {% endif %} |
59 |
| - {% if gitlab_runner.post_build_script|default(false) %} |
60 |
| - --post-build-script "{{ gitlab_runner.post_build_script }}" |
61 |
| - {% endif %} |
62 |
| - --docker-image '{{ gitlab_runner.docker_image|default("alpine") }}' |
63 |
| - {% if gitlab_runner.docker_privileged|default(false) %} |
64 |
| - --docker-privileged |
65 |
| - {% endif %} |
66 |
| - {% if gitlab_runner.docker_wait_for_services_timeout|default(false) %} |
67 |
| - --docker-wait-for-services-timeout '{{ gitlab_runner.docker_wait_for_services_timeout|default(30) }}' |
68 |
| - {% endif %} |
69 |
| - {% if gitlab_runner.docker_tlsverify|default(false) %} |
70 |
| - --docker-tlsverify '{{ gitlab_runner.docker_tlsverify|default("true") }}' |
71 |
| - {% endif %} |
72 |
| - {% if gitlab_runner.docker_disable_cache|default(false) %} |
73 |
| - --docker-disable-cache '{{ gitlab_runner.docker_disable_cache|default("false") }}' |
74 |
| - {% endif %} |
75 |
| - {% if gitlab_runner.docker_dns|default(false) %} |
76 |
| - --docker-dns '{{ gitlab_runner.docker_dns|default("1.1.1.1") }}' |
77 |
| - {% endif %} |
78 |
| - {% if gitlab_runner.docker_dns_search|default(false) %} |
79 |
| - --docker-dns-search '{{ gitlab_runner.docker_dns_search|default([]) }}' |
80 |
| - {% endif %} |
81 |
| - {% if gitlab_runner.docker_disable_cache|default(false) %} |
82 |
| - --docker-disable-cache |
83 |
| - {% endif %} |
84 |
| - {% if gitlab_runner.docker_oom_kill_disable|default(false) %} |
85 |
| - --docker-oom-kill-disable '{{ gitlab_runner.docker_oom_kill_disable|default("false") }}' |
86 |
| - {% endif %} |
87 |
| - {% for policy in gitlab_runner.docker_pull_policy|default([]) %} |
88 |
| - --docker-pull-policy "{{ policy }}" |
89 |
| - {% endfor %} |
90 |
| - {% for volume in gitlab_runner.docker_volumes|default([]) %} |
91 |
| - --docker-volumes "{{ volume }}" |
92 |
| - {% endfor %} |
93 |
| - {% for device in gitlab_runner.docker_devices|default([]) %} |
94 |
| - --docker-devices "{{ device }}" |
95 |
| - {% endfor %} |
96 |
| - --ssh-user '{{ gitlab_runner.ssh_user|default("") }}' |
97 |
| - --ssh-host '{{ gitlab_runner.ssh_host|default("") }}' |
98 |
| - --ssh-port '{{ gitlab_runner.ssh_port|default("") }}' |
99 |
| - --ssh-password '{{ gitlab_runner.ssh_password|default("") }}' |
100 |
| - --ssh-identity-file '{{ gitlab_runner.ssh_identity_file|default("") }}' |
101 |
| - {% if gitlab_runner.executor == "virtualbox" and gitlab_runner.virtualbox_base_name %} |
102 |
| - --virtualbox-base-name '{{ gitlab_runner.virtualbox_base_name }}' |
103 |
| - --virtualbox-base-snapshot '{{ gitlab_runner.virtualbox_base_snapshot|default("") }}' |
104 |
| - --virtualbox-base-folder '{{ gitlab_runner.virtualbox_base_folder|default("") }}' |
105 |
| - --virtualbox-disable-snapshots '{{ gitlab_runner.virtualbox_disable_snapshots|default(false) }}' |
106 |
| - {% endif %} |
107 |
| - {% if gitlab_runner.cache_type is defined %} |
108 |
| - --cache-type '{{ gitlab_runner.cache_type }}' |
109 |
| - {% endif %} |
110 |
| - {% if gitlab_runner.cache_shared|default(false) %} |
111 |
| - --cache-shared |
112 |
| - {% endif %} |
113 |
| - {% if gitlab_runner.cache_path is defined %} |
114 |
| - --cache-path '{{ gitlab_runner.cache_path }}' |
115 |
| - {% endif %} |
116 |
| - {% if gitlab_runner.cache_s3_server_address is defined %} |
117 |
| - --cache-s3-server-address '{{ gitlab_runner.cache_s3_server_address }}' |
118 |
| - {% if gitlab_runner.cache_s3_access_key is defined %} |
119 |
| - --cache-s3-access-key '{{ gitlab_runner.cache_s3_access_key }}' |
120 |
| - {% endif %} |
121 | 148 | {% if gitlab_runner.cache_s3_secret_key is defined %}
|
122 | 149 | --cache-s3-secret-key '{{ gitlab_runner.cache_s3_secret_key }}'
|
123 | 150 | {% endif %}
|
124 |
| - {% endif %} |
125 |
| - {% if gitlab_runner.cache_s3_bucket_name is defined %} |
126 |
| - --cache-s3-bucket-name '{{ gitlab_runner.cache_s3_bucket_name }}' |
127 |
| - {% endif %} |
128 |
| - {% if gitlab_runner.cache_s3_bucket_location is defined %} |
129 |
| - --cache-s3-bucket-location '{{ gitlab_runner.cache_s3_bucket_location }}' |
130 |
| - {% endif %} |
131 |
| - {% if gitlab_runner.builds_dir|default(false) %} |
132 |
| - --builds-dir '{{ gitlab_runner.builds_dir }}' |
133 |
| - {% endif %} |
134 |
| - {% if gitlab_runner.custom_build_dir_enabled|default(false) %} |
135 |
| - --custom_build_dir-enabled '{{ gitlab_runner.custom_build_dir_enabled }}' |
136 |
| - {% endif %} |
137 |
| - {% if gitlab_runner.cache_dir|default(false) %} |
138 |
| - --cache-dir '{{ gitlab_runner.cache_dir }}' |
139 |
| - {% endif %} |
140 |
| - {% if gitlab_runner.cache_s3_insecure|default(false) %} |
141 |
| - --cache-s3-insecure |
142 |
| - {% endif %} |
143 |
| - {% if gitlab_runner.extra_registration_option is defined %} |
144 |
| - {{ gitlab_runner.extra_registration_option }} |
145 |
| - {% endif %} |
| 151 | + --ssh-password '{{ gitlab_runner.ssh_password|default("") }}' |
146 | 152 | when: (verified_runners.stderr.find("Verifying runner... is removed") != -1) or
|
147 | 153 | ((configured_runners.stderr.find('\n' + gitlab_runner.name|default(ansible_hostname+'-'+gitlab_runner_index|string)) == -1) and
|
148 | 154 | (gitlab_runner.state|default('present') == 'present'))
|
|
0 commit comments