Skip to content

Commit

Permalink
Merge pull request #129 from shaheed121/redis-ha-feature
Browse files Browse the repository at this point in the history
Adding support to configure redis HA
  • Loading branch information
tobru authored Apr 12, 2017
2 parents f6fc3ce + a197850 commit 6e6e24e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) }
Expand Down
36 changes: 36 additions & 0 deletions templates/gitlab.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>

#####################
Expand Down Expand Up @@ -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 -%>

0 comments on commit 6e6e24e

Please sign in to comment.