From a197850bf1763c899224286ed041d30f05790147 Mon Sep 17 00:00:00 2001 From: Abdul Shaheed Date: Tue, 11 Apr 2017 15:27:25 +0200 Subject: [PATCH] Adding support to confifure redis HA while using omnibus package --- manifests/config.pp | 4 ++++ manifests/init.pp | 24 ++++++++++++++++++++++++ templates/gitlab.rb.erb | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/manifests/config.pp b/manifests/config.pp index aef14838..770075dc 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -37,12 +37,16 @@ $postgresql = $::gitlab::postgresql $prometheus = $::gitlab::prometheus $redis = $::gitlab::redis + $redis_master_role = $::gitlab::redis_master_role + $redis_slave_role = $::gitlab::redis_slave_role + $redis_sentinel_role = $::gitlab::redis_sentinel_role $registry = $::gitlab::registry $registry_nginx = $::gitlab::registry_nginx $registry_nginx_eq_nginx = $::gitlab::registry_nginx_eq_nginx $registry_external_url = $::gitlab::registry_external_url $secrets = $::gitlab::secrets $secrets_file = $::gitlab::secrets_file + $sentinel = $::gitlab::sentinel $service_group = $::gitlab::service_group $service_manage = $::gitlab::service_manage $service_user = $::gitlab::service_user diff --git a/manifests/init.pp b/manifests/init.pp index 6bd93981..3327bf22 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -202,6 +202,18 @@ # Default: undef # Hash of 'redis' config parameters. # +# [*redis_master_role*] +# Default: undef +# To enable Redis master role for the node. +# +# [*redis_slave_role*] +# Default: undef +# To enable Redis slave role for the node. +# +# [*redis_sentinel_role*] +# Default: undef +# To enable sentinel role for the node. +# # [*registry*] # Default: undef # Hash of 'registry' config parameters. @@ -227,6 +239,10 @@ # Default: /etc/gitlab/gitlab-secrets.json # Full path to secrets JSON file. # +# [*sentinel*] +# Default: undef +# Hash of 'sentinel' config parameters. +# # [*shell*] # Default: undef # Hash of 'gitlab_shell' config parameters. @@ -327,12 +343,16 @@ $postgresql = undef, $prometheus = undef, $redis = undef, + $redis_master_role = undef, + $redis_slave_role = undef, + $redis_sentinel_role = undef, $registry = undef, $registry_external_url = undef, $registry_nginx = undef, $registry_nginx_eq_nginx = false, $secrets = undef, $secrets_file = $::gitlab::params::secrets_file, + $sentinel = undef, $shell = undef, $sidekiq = undef, $source_config_file = undef, @@ -379,11 +399,15 @@ validate_bool($pages_nginx_eq_nginx) if $postgresql { validate_hash($postgresql) } if $redis { validate_hash($redis) } + if $redis_master_role { validate_bool($redis_master_role) } + if $redis_slave_role { validate_bool($redis_slave_role) } + if $redis_sentinel_role { validate_bool($redis_sentinel_role) } if $registry { validate_hash($registry) } if $registry_nginx { validate_hash($registry_nginx) } validate_bool($registry_nginx_eq_nginx) if $registry_external_url { validate_string($registry_external_url) } if $secrets { validate_hash($secrets) } + if $sentinel { validate_hash($sentinel) } if $shell { validate_hash($shell) } if $sidekiq { validate_hash($sidekiq) } if $unicorn { validate_hash($unicorn) } diff --git a/templates/gitlab.rb.erb b/templates/gitlab.rb.erb index 3d5f05d0..2f53ef6b 100644 --- a/templates/gitlab.rb.erb +++ b/templates/gitlab.rb.erb @@ -116,6 +116,24 @@ postgresql['<%= k -%>'] = <%= decorate(@postgresql[k]) %> <%- @redis.keys.sort.each do |k| -%> redis['<%= k -%>'] = <%= decorate(@redis[k]) %> <%- end end -%> +<%- if @redis_master_role -%> +####################### +# Gitlab Redis Master # +####################### +## see https://docs.gitlab.com/omnibus/settings/redis.html +## see https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L667 + +redis_master_role['enable'] = true +<%- end -%> +<%- if @redis_slave_role -%> +####################### +# Gitlab Redis Slave # +####################### +## see https://docs.gitlab.com/omnibus/settings/redis.html +## see https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L668 + +redis_slave_role['enable'] = true +<%- end -%> <%- if @web_server -%> ##################### @@ -379,3 +397,21 @@ registry_nginx['<%= k -%>'] = <%= decorate(@_real_registry_nginx[k]) %> <%- @manage_accounts.keys.sort.each do |k| -%> manage_accounts['<%= k -%>'] = <%= decorate(@manage_accounts[k]) %> <%- end end -%> +<%- if @redis_sentinel_role -%> + +################## +# Redis Sentinel # +################## + +sentinel['enable'] = true +<%- end -%> +<%- if @sentinel -%> + +################### +# GitLab Sentinel # +################### +## To enable Sentinel and disable all other services in this machine, enable below section. +## https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L1406-1453 +<%- @sentinel.keys.sort.each do |k| -%> +redis['<%= k -%>'] = <%= decorate(@sentinel[k]) %> +<%- end end -%>