Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update auto migrations file #234

Merged
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,29 @@ class { 'gitlab':
}
```

### Skip Auto Reconfigure (formerly Skip Auto Migrations)

In order to achieve [Zero Downtime Upgrades](https://docs.gitlab.com/omnibus/update/README.html#zero-downtime-updates)
of your GitLab instance, GitLab will need to skip the post-install step of the omnibus package that automatically calls
`gitlab-ctl reconfigure` for you. In GitLab < 10.5, GitLab check for the presence of a file at `/etc/gitlab/skip-auto-migrations`.
As of GitLab `10.6`, this is deprecated, and you are warned to use `/etc/gitlab/skip-auto-reconfigure` going forward.

Both of these are currently supported in this module, and you should be aware of which option is right for you
based on the version of GitLab Omnibus you are running. You will be presented with a deprecation notice in you
puppet client if using the deprecated form.

```puppet
# use 'absent' or 'present' for the skip_auto_reconfigure param
class { 'gitlab':
skip_auto_reconfigure => 'present'
}

# use true/false for the skip_auto_migrations param
class { 'gitlab':
skip_auto_migrations => true
}
```

### Gitlab Custom Hooks

Manage custom hook files within a GitLab project. Custom hooks can be created
Expand Down
14 changes: 0 additions & 14 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
$shell = $::gitlab::shell
$sidekiq = $::gitlab::sidekiq
$sidekiq_cluster = $::gitlab::sidekiq_cluster
$skip_auto_migrations = $::gitlab::skip_auto_migrations
$store_git_keys_in_db = $::gitlab::store_git_keys_in_db
$source_config_file = $::gitlab::source_config_file
$unicorn = $::gitlab::unicorn
Expand Down Expand Up @@ -142,19 +141,6 @@
}
}

if $skip_auto_migrations != undef {
$_skip_auto_migrations_ensure = $skip_auto_migrations ? {
true => 'present',
default => 'absent',
}
file { '/etc/gitlab/skip-auto-migrations':
ensure => $_skip_auto_migrations_ensure,
owner => 'root',
group => 'root',
mode => '0644',
}
}

if $store_git_keys_in_db != undef {
$_store_git_keys_in_db = $store_git_keys_in_db ? {
true => 'file',
Expand Down
22 changes: 13 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@
#
# [*skip_auto_migrations*]
# Default: undef
# Enable or disable auto migrations. undef keeps the current state on the system.
# Deprecated if using Gitlab > 10.6.4 and < 11.0.0, unsupported by gitlab omnibus using gitlab 11+
# Use skip_auto_reconfigure
#
# [*skip_auto_reconfigure*]
# Default: undef
# Utilized for Zero Downtime Updates, See: https://docs.gitlab.com/omnibus/update/README.html#zero-downtime-updates
#
# [*store_git_keys_in_db*]
# Default: false
Expand Down Expand Up @@ -332,8 +337,8 @@
# === Examples
#
# class { 'gitlab':
# edition => 'ee',
# external_url => 'https://gitlab.mydomain.tld',
# edition => 'ee',
# external_url => 'https://gitlab.mydomain.tld',
# nginx => { redirect_http_to_https => true },
# }
#
Expand Down Expand Up @@ -422,7 +427,8 @@
Optional[Hash] $shell = undef,
Optional[Hash] $sidekiq = undef,
Optional[Hash] $sidekiq_cluster = undef,
Optional[Boolean] $skip_auto_migrations = undef,
Enum['present', 'absent'] $skip_auto_reconfigure = 'absent',
Optional $skip_auto_migrations = undef,
Optional[Stdlib::Absolutepath] $source_config_file = undef,
Boolean $store_git_keys_in_db = false,
Optional[Hash] $unicorn = undef,
Expand All @@ -437,16 +443,14 @@
Hash $global_hooks = {},
) inherits gitlab::params {

class { '::gitlab::install': }
-> class { '::gitlab::config': }
~> class { '::gitlab::service': }
-> class { '::gitlab::backup': }

contain gitlab::preinstall
contain gitlab::install
contain gitlab::config
contain gitlab::service
contain gitlab::backup

Class['gitlab::preinstall'] -> Class['gitlab::install'] -> Class['gitlab::config'] ~> Class['gitlab::service'] -> Class['gitlab::backup']

$custom_hooks.each |$name, $options| {
gitlab::custom_hook { $name:
* => $options,
Expand Down
39 changes: 39 additions & 0 deletions manifests/preinstall.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# == Class gitlab::config
#
# This class is for setting pre-install configurations
#
class gitlab::preinstall (
$skip_auto_migrations = $gitlab::skip_auto_migrations,
$skip_auto_reconfigure = $gitlab::skip_auto_reconfigure
) {

####
# Deprecation notice:
# skip_auto_migrations is deprecated and will be removed at some point after
# GitLab 11.0 is released
$skip_auto_migrations_deprecation_msg = "DEPRECTATION: 'skip_auto_migrations' is deprecated if using GitLab 10.6 or greater. Set skip_auto_reconfigure instead"

if $skip_auto_migrations != undef {

notify { $skip_auto_migrations_deprecation_msg: }

$_skip_auto_migrations_ensure = $skip_auto_migrations ? {
true => 'present',
default => 'absent',
}

file { '/etc/gitlab/skip-auto-migrations':
ensure => $_skip_auto_migrations_ensure,
owner => 'root',
group => 'root',
mode => '0644',
}
}

file { '/etc/gitlab/skip-auto-reconfigure':
ensure => $skip_auto_reconfigure,
owner => 'root',
group => 'root',
mode => '0644',
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppet-gitlab",
"version": "2.0.1-rc0",
"version": "3.0.0-rc0",
"author": "Vox Pupuli",
"summary": "Installation and configuration of Gitlab Omnibus",
"license": "BSD-3-Clause",
Expand Down
12 changes: 12 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@
with_content(%r{^\s*letsencrypt\['contact_emails'\] = \["[email protected]"\]$})
}
end
describe 'skip_auto_reconfigure' do
let(:params) { { skip_auto_reconfigure: 'present' } }

it {
is_expected.to contain_file('/etc/gitlab/skip-auto-reconfigure').with(
'ensure' => 'present',
'owner' => 'root',
'group' => 'root',
'mode' => '0644'
)
}
end
describe 'secrets' do
let(:params) do
{ secrets: {
Expand Down