From 76a2a2f0dcf9180c33beacae94ec62f67f4f2c12 Mon Sep 17 00:00:00 2001 From: danielg Date: Fri, 10 Nov 2023 08:42:18 +0100 Subject: [PATCH] Update to support Praefect Stolen from https://github.com/voxpupuli/puppet-gitlab/pull/372 --- REFERENCE.md | 9 +++++++++ manifests/init.pp | 2 ++ manifests/omnibus_config.pp | 1 + spec/classes/init_spec.rb | 28 ++++++++++++++++++++++++++++ templates/gitlab.rb.erb | 10 ++++++++++ 5 files changed, 50 insertions(+) diff --git a/REFERENCE.md b/REFERENCE.md index 6b8d0a0..fb45bd5 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -90,6 +90,7 @@ The following parameters are available in the `gitlab` class: * [`pages_external_url`](#-gitlab--pages_external_url) * [`pages_nginx`](#-gitlab--pages_nginx) * [`pages_nginx_eq_nginx`](#-gitlab--pages_nginx_eq_nginx) +* [`praefect`](#-gitlab--praefect) * [`postgresql`](#-gitlab--postgresql) * [`prometheus`](#-gitlab--prometheus) * [`prometheus_monitoring_enable`](#-gitlab--prometheus_monitoring_enable) @@ -584,6 +585,14 @@ Hash of 'postgresql' config parameters. Default value: `undef` +##### `praefect` + +Data type: `Optional[Hash]` + +Hash of 'praefect' config parameters. + +Default value: `undef` + ##### `prometheus` Data type: `Optional[Hash]` diff --git a/manifests/init.pp b/manifests/init.pp index 3e0b1d4..6cac04a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -55,6 +55,7 @@ # @param pages_external_url External URL of Gitlab Pages. # @param pages_nginx Hash of 'pages_nginx' config parameters. # @param pages_nginx_eq_nginx Replicate the Pages Nginx config from the Gitlab Nginx config. +# @param praefect Hash of 'praefect' config parameters. # @param postgresql Hash of 'postgresql' config parameters. # @param prometheus Hash of 'prometheus' config parameters. # @param prometheus_monitoring_enable Enable/disable prometheus support. @@ -163,6 +164,7 @@ Boolean $pages_nginx_eq_nginx = false, Optional[Hash] $pgbouncer = undef, Optional[Hash] $postgresql = undef, + Optional[Hash] $praefect = undef, Optional[Hash] $prometheus = undef, Optional[Boolean] $prometheus_monitoring_enable = undef, Optional[Hash] $redis = undef, diff --git a/manifests/omnibus_config.pp b/manifests/omnibus_config.pp index 0b877cd..bcef084 100644 --- a/manifests/omnibus_config.pp +++ b/manifests/omnibus_config.pp @@ -50,6 +50,7 @@ $pages_nginx = $gitlab::pages_nginx $pages_nginx_eq_nginx = $gitlab::pages_nginx_eq_nginx $pgbouncer = $gitlab::pgbouncer + $praefect = $gitlab::praefect $postgresql = $gitlab::postgresql $prometheus = $gitlab::prometheus $prometheus_monitoring_enable = $gitlab::prometheus_monitoring_enable diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 3033f22..511c643 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -178,6 +178,34 @@ with_content(%r{^\s*pgbouncer\['enable'\] = true$}) } end + describe 'praefect' do + let(:params) do + { + praefect: { + 'enable' => true, + 'listen_addr' => '0.0.0.0:2305', + 'virtual_storage' => { + 'default' => { + 'host01' => {'address' => 'tcp://host01:8075', 'token' => 'xxx-xxx-xxx'}, + 'host02' => {'address' => 'tcp://host02:8075', 'token' => 'xxx-xxx-xxx'}, + } + } + } + } + end + it { + is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ + with_content(%r{^\s*praefect\['enable'\] = true$}) + } + it { + is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ + with_content(%r{^\s*praefect\['listen_addr'\] = "0\.0\.0\.0:2305"$}) + } + it { + is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ + with_content(%r{^\s*praefect\['virtual_storage'\] = \{"default"=>\{"host01"=>\{"address"=>"tcp://host01:8075", "token"=>"xxx-xxx-xxx"\}, "host02"=>\{"address"=>"tcp://host02:8075", "token"=>"xxx-xxx-xxx"\}\}\}$}) + } + end describe 'repmgr' do let(:params) do { repmgr: { diff --git a/templates/gitlab.rb.erb b/templates/gitlab.rb.erb index 953148c..6b6bd31 100644 --- a/templates/gitlab.rb.erb +++ b/templates/gitlab.rb.erb @@ -147,6 +147,16 @@ gitlab_sshd['<%= k -%>'] = <%= decorate(@gitlab_sshd[k]) %> <%- @postgresql.keys.sort.each do |k| -%> postgresql['<%= k -%>'] = <%= decorate(@postgresql[k]) %> <%- end end -%> +<%- if @praefect -%> + +################################################################################ +# Praefect +################################################################################ +# See [Gitlab Praefect documentation](https://docs.gitlab.com/ee/administration/gitaly/praefect.html) + +<%- @praefect.keys.sort.each do |k| -%> +praefect['<%= k -%>'] = <%= decorate(@praefect[k]) %> +<%- end end -%> <%- if @redis -%> ################