Skip to content

Commit 177e410

Browse files
authored
Merge pull request #416 from tobiashuste/replace-git-data-dirs
Replace git_data_dirs
2 parents e831964 + c721b78 commit 177e410

File tree

5 files changed

+55
-7
lines changed

5 files changed

+55
-7
lines changed

molecule/gitlab/molecule.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ provisioner:
2929
inventory:
3030
host_vars:
3131
instancegitlab:
32+
gitlab_version: "17.11.2"
33+
gitlab_release: "ce.0"
3234
gitlab_edition: "gitlab-ce"
3335
gitlab_ip_range: "0.0.0.0/0"
3436
gitlab_additional_configurations:

molecule/gitlab/verify.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,22 @@
1414
- name: "Assert that GitLab Omnibus package is installed"
1515
ansible.builtin.assert:
1616
that:
17-
- "'{{ gitlab_edition }}' in ansible_facts.packages"
17+
- "gitlab_edition in ansible_facts.packages"
1818
when:
1919
- "gitlab_edition is defined"
2020

21+
- name: "Set expected package version of GitLab"
22+
ansible.builtin.set_fact:
23+
gitlab_expected_package_version: "{{ gitlab_version }}-{{ gitlab_release }}"
24+
when:
25+
- "gitlab_edition is defined"
26+
- "gitlab_version is defined"
27+
- "gitlab_release is defined"
28+
2129
- name: "Assert that installed GitLab version is equal to the desired one"
2230
ansible.builtin.assert:
2331
that:
24-
- "ansible_facts.packages['{{ gitlab_edition }}'][0].version == gitlab_version"
25-
- "ansible_facts.packages['{{ gitlab_edition }}'][0].release == gitlab_release"
32+
- "ansible_facts.packages[gitlab_edition][0].version == gitlab_expected_package_version"
2633
when:
2734
- "gitlab_edition is defined"
2835
- "gitlab_version is defined"

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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,31 @@
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_item: "{{ item.gitaly }}"
31+
with_items: "{{ gitlab_additional_configurations }}"
32+
33+
- name: "Check if gitaly['configuration'] is present"
34+
when:
35+
- "item.key is defined"
36+
- "item.key == 'configuration'"
37+
ansible.builtin.set_fact:
38+
__gitaly_configuration_exists: true
39+
with_items: "{{ __gitaly_item | default([]) }}"
40+
41+
- name: "Warn if gitaly['configuration'] is already present"
42+
when:
43+
- "__gitaly_configuration_exists"
44+
ansible.builtin.debug:
45+
msg: "Please make sure to configure gitaly storage paths yourself in gitaly['configuration']"
46+
2247
- name: "Copy GitLab Configuration File."
2348
become: true
2449
ansible.builtin.template:

roles/gitlab/templates/gitlab.rb.j2

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,25 @@ 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-
git_data_dirs({"default" => {"path" => "{{ gitlab_git_data_dir }}"} })
34+
{% if not __gitaly_configuration_exists %}
35+
gitaly['configuration'] = {
36+
"storage": [
37+
{
38+
"name": "default",
39+
"path": "{{ (gitlab_git_data_dir, 'repositories') | path_join }}",
40+
},
41+
],
42+
}
43+
{% endif %}
3544
{% else %}
3645
gitaly['enable'] = false
3746
gitlab_rails['gitaly_token'] = "{{ gitlab_gitaly_token }}"
3847
gitlab_shell['secret_token'] = "{{ gitlab_secret_token }}"
39-
git_data_dirs({
40-
'default' => { 'gitaly_address' => 'tcp://{{ gitlab_gitaly_instance_ip }}:{{ gitlab_gitaly_instance_port }}' },
41-
})
48+
gitlab_rails['repositories_storages'] = {
49+
"default" => {
50+
"gitaly_address" => "tcp://{{ gitlab_gitaly_instance_ip }}:{{ gitlab_gitaly_instance_port }}"
51+
}
52+
}
4253
{% endif %}
4354

4455
gitlab_rails['gitlab_email_enabled'] = {{ gitlab_email_enabled }}

0 commit comments

Comments
 (0)