Skip to content

Commit a1ab856

Browse files
committed
Handle the case when gitaly['configuration'] already defined
This can happen if it is already present in gitlab_additional_configurations. In this case send a warning that users have to add the gitaly storage path themselves.
1 parent d04fd9c commit a1ab856

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

roles/gitlab/defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,7 @@ gitlab_mattermost_only_context: "false"
9393

9494
gitlab_feature_flags: []
9595

96+
# Internal variable to determine whether the configuration object for Gitaly
97+
# is already present in gitlab_additional_configurations
98+
__gitaly_configuration_exists: false
9699
...

roles/gitlab/tasks/configure.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,32 @@
1919
- "Reconfigure Primary GitLab"
2020
- "Reconfigure Non Primary GitLab"
2121

22+
- name: "Ensure gitaly['configuration'] is not present in gitlab_additional_configurations"
23+
when: "gitlab_use_internal_gitaly"
24+
block:
25+
- name: "Check if gitaly is present"
26+
when:
27+
- "gitlab_additional_configurations | length > 0"
28+
- "item.gitaly is defined"
29+
ansible.builtin.set_fact:
30+
__gitaly_exists: true
31+
__gitaly_item: "{{ item.gitaly }}"
32+
with_items: "{{ gitlab_additional_configurations }}"
33+
34+
- name: "Check if gitaly['configuration'] is present"
35+
when:
36+
- "item.key is defined"
37+
- "item.key == 'configuration'"
38+
ansible.builtin.set_fact:
39+
__gitaly_configuration_exists: true
40+
with_items: "{{ __gitaly_item | default([]) }}"
41+
42+
- name: "Warn if gitaly['configuration'] is already present"
43+
when:
44+
- "__gitaly_configuration_exists"
45+
ansible.builtin.debug:
46+
msg: "Please make sure to configure gitaly storage paths yourself in gitaly['configuration']"
47+
2248
- name: "Copy GitLab Configuration File."
2349
become: true
2450
ansible.builtin.template:

roles/gitlab/templates/gitlab.rb.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ gitlab_rails['redis_sentinels_password'] = "{{ gitlab_redis_sentinel_password }}
3131
gitlab_rails['monitoring_whitelist'] = ["{{ gitlab_ip_range }}"]
3232

3333
{% if gitlab_use_internal_gitaly %}
34+
{% if not __gitaly_configuration_exists %}
3435
gitaly['configuration'] = {
3536
"storage": [
3637
{
@@ -39,6 +40,7 @@ gitaly['configuration'] = {
3940
},
4041
],
4142
}
43+
{% endif %}
4244
{% else %}
4345
gitaly['enable'] = false
4446
gitlab_rails['gitaly_token'] = "{{ gitlab_gitaly_token }}"

0 commit comments

Comments
 (0)