Skip to content

Commit

Permalink
Merge pull request #241 from LongLiveCHIEF/refactor-ordering
Browse files Browse the repository at this point in the history
Refactor resource ordering
  • Loading branch information
LongLiveCHIEF authored Jun 6, 2018
2 parents 7d92168 + 90c6199 commit c741b36
Show file tree
Hide file tree
Showing 9 changed files with 287 additions and 282 deletions.
169 changes: 0 additions & 169 deletions manifests/config.pp

This file was deleted.

82 changes: 82 additions & 0 deletions manifests/host_config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# == Class gitlab::host_config
#
# This class is for setting host configurations required for gitlab installation
#
# [*config_dir*]
# Default: '/etc/gitlab'
# The service executable path.
# Provide this variable value only if the service executable path
# would be a subject of change in future GitLab versions for any reason.
class gitlab::host_config (
$config_dir = '/etc/gitlab',
$skip_auto_migrations = $gitlab::skip_auto_migrations,
$skip_auto_reconfigure = $gitlab::skip_auto_reconfigure,
$secrets_file = $gitlab::secrets_file,
$store_git_keys_in_db = $gitlab::store_git_keys_in_db,
) {

file { $config_dir:
ensure => 'directory',
owner => 'root',
group => 'root',
mode => '0775',
}

# 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"
$skip_auto_reconfigure_attributes = {
owner => 'root',
group => 'root',
mode => '0644',
}
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,
* => $skip_auto_reconfigure_attributes,
}
}
file { '/etc/gitlab/skip-auto-reconfigure':
ensure => $skip_auto_reconfigure,
* => $skip_auto_reconfigure_attributes,
}
if $store_git_keys_in_db != undef {
$_store_git_keys_in_db = $store_git_keys_in_db ? {
true => 'file',
default => 'absent',
}
$opt_gitlab_shell_dir = $store_git_keys_in_db ? {
true => 'directory',
default => 'absent'
}
file {'/opt/gitlab-shell':
ensure => $opt_gitlab_shell_dir,
owner => 'root',
group => 'git',
}
file { '/opt/gitlab-shell/authorized_keys':
ensure => $_store_git_keys_in_db,
owner => 'root',
group => 'git',
mode => '0650',
source => 'puppet:///modules/gitlab/gitlab_shell_authorized_keys',
}
}
include gitlab::backup
}
44 changes: 16 additions & 28 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@
# Default: root
# Group of the config file.
#
# [*service_restart/_start/_stop/_status*]
# Default: /usr/bin/gitlab-ctl <command>
# Commands for the service definition.
#
# [*service_hasstatus/_hasrestart*]
# Default: true
# The gitlab service has this commands available.
#
# [*rake_exec*]
# Default: '/usr/bin/gitlab-rake'
# The gitlab-rake executable path.
Expand Down Expand Up @@ -357,26 +349,20 @@
String $package_ensure = $::gitlab::params::package_ensure,
Boolean $package_pin = $::gitlab::params::package_pin,
# system service configuration
Boolean $service_enable = $::gitlab::params::service_enable,
Enum['stopped', 'false', 'running', 'true'] $service_ensure = $::gitlab::params::service_ensure, # lint:ignore:quoted_booleans
String $service_group = $::gitlab::params::service_group,
Boolean $service_hasrestart = $::gitlab::params::service_hasrestart,
Boolean $service_hasstatus = $::gitlab::params::service_hasstatus,
Boolean $service_manage = $::gitlab::params::service_manage,
String $service_name = $::gitlab::params::service_name,
String $service_exec = $::gitlab::params::service_exec,
String $service_restart = $::gitlab::params::service_restart,
String $service_start = $::gitlab::params::service_start,
String $service_status = $::gitlab::params::service_status,
String $service_stop = $::gitlab::params::service_stop,
String $service_user = $::gitlab::params::service_user,
Boolean $service_enable = true,
Enum['stopped', 'false', 'running', 'true'] $service_ensure = 'running', # lint:ignore:quoted_booleans
Boolean $service_manage = true,
String $service_name = 'gitlab-runsvdir',
String $service_exec = '/usr/bin/gitlab-ctl',
String $service_user = 'root',
String $service_group = 'root',
# gitlab specific
String $rake_exec = $::gitlab::params::rake_exec,
Enum['ce', 'ee'] $edition = 'ce',
Optional[Hash] $ci_redis = undef,
Optional[Hash] $ci_unicorn = undef,
Boolean $config_manage = $::gitlab::params::config_manage,
Stdlib::Absolutepath $config_file = $::gitlab::params::config_file,
Boolean $config_manage = true,
Stdlib::Absolutepath $config_file = '/etc/gitlab/gitlab.rb',
Optional[String] $custom_hooks_dir = undef,
Stdlib::Httpurl $external_url = $::gitlab::params::external_url,
Optional[Integer[1, 65565]] $external_port = undef,
Expand Down Expand Up @@ -422,7 +408,7 @@
Boolean $registry_nginx_eq_nginx = false,
Optional[Array] $roles = undef,
Optional[Hash] $secrets = undef,
Stdlib::Absolutepath $secrets_file = $::gitlab::params::secrets_file,
Optional[Stdlib::Absolutepath] $secrets_file = '/etc/gitlab/gitlab-secrets.json',
Optional[Hash] $sentinel = undef,
Optional[Hash] $shell = undef,
Optional[Hash] $sidekiq = undef,
Expand All @@ -443,13 +429,15 @@
Hash $global_hooks = {},
) inherits gitlab::params {

contain gitlab::preinstall
contain gitlab::host_config
contain gitlab::omnibus_config
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']
Class['gitlab::host_config']
-> Class['gitlab::omnibus_config']
-> Class['gitlab::install']
-> Class['gitlab::service']

$custom_hooks.each |$name, $options| {
gitlab::custom_hook { $name:
Expand Down
25 changes: 15 additions & 10 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#
class gitlab::install {

$edition = $::gitlab::edition
$manage_package_repo = $::gitlab::manage_package_repo
$manage_package = $::gitlab::manage_package
$package_ensure = $::gitlab::package_ensure
$edition = $gitlab::edition
$manage_package_repo = $gitlab::manage_package_repo
$manage_package = $gitlab::manage_package
$package_ensure = $gitlab::package_ensure
$package_name = "gitlab-${edition}"
$package_pin = $::gitlab::package_pin
$package_pin = $gitlab::package_pin

# only do repo management when on a Debian-like system
if $manage_package_repo {
Expand All @@ -32,11 +32,13 @@
},
}
if $manage_package {
package { $package_name:
package { 'gitlab-omnibus':
ensure => $package_ensure,
name => $package_name,
require => [
Exec['apt_update'],
Apt::Source["gitlab_official_${edition}"],
Class['gitlab::host_config', 'gitlab::omnibus_config'],
],
}
}
Expand Down Expand Up @@ -68,9 +70,10 @@
}

if $manage_package {
package { $package_name:
package { 'gitlab-omnibus':
ensure => $package_ensure,
require => Yumrepo["gitlab_official_${edition}"],
name => $package_name,
require => [Yumrepo["gitlab_official_${edition}"], Class['gitlab::host_config', 'gitlab::omnibus_config']],
}
}
}
Expand All @@ -79,8 +82,10 @@
}
}
} elsif $manage_package {
package { $package_name:
ensure => $package_ensure,
package { 'gitlab-omnibus':
ensure => $package_ensure,
name => $package_name,
require => Class['gitlab::host_config', 'gitlab::omnibus_config'],
}
}

Expand Down
Loading

0 comments on commit c741b36

Please sign in to comment.