diff --git a/manifests/config.pp b/manifests/config.pp index c416e229..5d398afc 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -62,6 +62,7 @@ $service_group = $::gitlab::service_group $service_manage = $::gitlab::service_manage $service_user = $::gitlab::service_user + $rake_exec = $::gitlab::rake_exec $shell = $::gitlab::shell $sidekiq = $::gitlab::sidekiq $sidekiq_cluster = $::gitlab::sidekiq_cluster @@ -71,6 +72,15 @@ $gitlab_workhorse = $::gitlab::gitlab_workhorse $user = $::gitlab::user $web_server = $::gitlab::web_server + $backup_cron_enable = $::gitlab::backup_cron_enable + $backup_cron_minute = $::gitlab::backup_cron_minute + $backup_cron_hour = $::gitlab::backup_cron_hour + if empty($::gitlab::backup_cron_hour) { + $backup_cron_skips = '' + } else { + $_backup_cron_skips = join($::gitlab::backup_cron_skips, ',') + $backup_cron_skips = "SKIP:${_backup_cron_skips}" + } # replicate $nginx to $mattermost_nginx if $mattermost_nginx_eq_nginx true if $mattermost_nginx_eq_nginx { @@ -144,7 +154,7 @@ if is_hash($postgresql) { unless $postgresql[enable] { exec { 'gitlab_setup': - command => '/bin/echo yes | /usr/bin/gitlab-rake gitlab:setup', + command => "/bin/echo yes | ${rake_exec} gitlab:setup", refreshonly => true, timeout => 1800, require => Exec['gitlab_reconfigure'], @@ -170,4 +180,12 @@ mode => '0644', } } + + if $backup_cron_enable { + cron {'gitlab backup': + command => "${rake_exec} gitlab:backup:create CRON=1 ${backup_cron_skips}", + hour => $backup_cron_hour, + minute => $backup_cron_minute, + } + } } diff --git a/manifests/init.pp b/manifests/init.pp index 65453abf..d595a1cd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -58,6 +58,11 @@ # Default: true # The gitlab service has this commands available. # +# [*rake_exec*] +# Default: '/usr/bin/gitlab-rake' +# The gitlab-rake executable path. +# You should not need to change this path. +# # [*edition*] # Default: ce # Gitlab edition to install. ce or ee. @@ -291,6 +296,24 @@ # Default: undef # Hash of 'high_availability' config parameters. # +# [*backup_cron_enable*] +# Default: false +# Boolean to enable the daily backup cron job +# +# [*backup_cron_minute*] +# Default: 0 +# The minute when to run the daily backup cron job +# +# [*backup_cron_hour*] +# Default: 2 +# The hour when to run the daily backup cron job +# +# [*backup_cron_skips*] +# Default: [] +# Array of items to skip +# valid values: db, uploads, repositories, builds, +# artifacts, lfs, registry, pages +# # === Examples # # class { 'gitlab': @@ -328,6 +351,7 @@ $service_stop = $::gitlab::params::service_stop, $service_user = $::gitlab::params::service_user, # gitlab specific + $rake_exec = $::gitlab::params::rake_exec, $edition = 'ce', $ci_redis = undef, $ci_unicorn = undef, @@ -387,6 +411,10 @@ $gitlab_workhorse = undef, $user = undef, $web_server = undef, + $backup_cron_enable = false, + $backup_cron_minute = 0, + $backup_cron_hour = 2, + $backup_cron_skips = [], $custom_hooks = {}, ) inherits ::gitlab::params { @@ -451,6 +479,10 @@ if $web_server { validate_hash($web_server) } if $high_availability { validate_hash($high_availability) } if $manage_accounts { validate_hash($manage_accounts) } + validate_bool($backup_cron_enable) + validate_integer($backup_cron_minute,59) + validate_integer($backup_cron_hour,23) + validate_array($backup_cron_skips) validate_hash($custom_hooks) class { '::gitlab::install': } -> @@ -460,7 +492,7 @@ contain gitlab::install contain gitlab::config contain gitlab::service - + create_resources(gitlab::custom_hook, $custom_hooks) } diff --git a/manifests/params.pp b/manifests/params.pp index 8b82851e..121788a4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -11,6 +11,8 @@ $manage_package_repo = true $manage_package = true + $rake_exec = '/usr/bin/gitlab-rake' + $service_exec = '/usr/bin/gitlab-ctl' $service_restart = "${service_exec} restart" $service_start = "${service_exec} start"