Skip to content

Commit

Permalink
Merge pull request #186 from StateFarmIns/add-ha-roles
Browse files Browse the repository at this point in the history
Add ha roles
  • Loading branch information
LongLiveCHIEF authored Apr 3, 2018
2 parents f8c27ff + 059bcd7 commit 3b2fc6c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
$gitlab_workhorse = $::gitlab::gitlab_workhorse
$user = $::gitlab::user
$web_server = $::gitlab::web_server
$roles = $::gitlab::roles

# replicate $nginx to $mattermost_nginx if $mattermost_nginx_eq_nginx true
if $mattermost_nginx_eq_nginx {
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@
# Default: false
# Replicate the registry Nginx config from the Gitlab Nginx config.
#
# [*roles*]
# Default: undef
# Array of roles when using a HA or Geo enabled GitLab configuration
# See: https://docs.gitlab.com/omnibus/roles/README.html for acceptable values
#
# [*secrets*]
# Default: undef
# Hash of values which will be placed into $secrets_file (by default /etc/gitlab/gitlab-secrets.json)
Expand Down Expand Up @@ -410,6 +415,7 @@
Optional[String] $registry_external_url = undef,
Optional[Hash] $registry_nginx = undef,
Boolean $registry_nginx_eq_nginx = false,
Optional[Array] $roles = undef,
Optional[Hash] $secrets = undef,
Stdlib::Absolutepath $secrets_file = $::gitlab::params::secrets_file,
Optional[Hash] $sentinel = undef,
Expand Down
18 changes: 18 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,24 @@
it { is_expected.not_to contain_package('gitlab-ce') }
it { is_expected.not_to contain_package('gitlab-ee') }
end
describe 'with roles' do
let(:params) do
{
'roles' => %w[redis_sentinel_role redis_master_role]
}
end

let(:expected_content) do
{
roles: %(roles [\"redis_sentinel_role\", \"redis_master_role\"])
}
end

it {
is_expected.to contain_file('/etc/gitlab/gitlab.rb').
with_content(%r{\s*#{Regexp.quote(expected_content[:roles])}}m)
}
end
describe 'with data_dirs' do
let(:params) do
{
Expand Down
12 changes: 12 additions & 0 deletions templates/gitlab.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ external_url '<%= @external_url %>'
<%- if @external_port -%>
external_port '<%= @external_port %>'
<%- end -%>

<%- if @roles -%>

## Roles for multi-instance GitLab
##! The default is to have no roles enabled, which results in GitLab running as an all-in-one instance.
##! Options:
##! redis_sentinel_role redis_master_role redis_slave_role geo_primary_role geo_secondary_role
##! For more deatils on each role, see:
##! https://docs.gitlab.com/omnibus/roles/README.html#roles

roles <%= decorate(@roles) %>
<%- end -%>
<%- if @git_data_dirs -%>

### For setting up different data storing directory
Expand Down

0 comments on commit 3b2fc6c

Please sign in to comment.