Skip to content

Commit

Permalink
Update auto migrations file (#234)
Browse files Browse the repository at this point in the history
* updated skip_auto_migrations to skip_auto_reconfigure

* add tests for skip-auto-reconfigure

* fix param name skip_auto_reconfigure

* update rc version

* fix spec syntax

* use hash syntax in spec

* correcting linting errors

* linting fixes

* deprecate skip_auto_migrations

* document preinstall class

* add documentaiton for auto-reconfigure and auto-migrations

* update class ordering and anchoring

* formatting fixes
LongLiveCHIEF authored May 26, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 2643c75 commit 2a3ea7c
Showing 6 changed files with 88 additions and 24 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
14 changes: 0 additions & 14 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -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
@@ -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',
22 changes: 13 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -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
@@ -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 },
# }
#
@@ -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,
@@ -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,
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",
12 changes: 12 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
@@ -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: {

0 comments on commit 2a3ea7c

Please sign in to comment.