Skip to content

Commit

Permalink
Add support to manage backup cron job
Browse files Browse the repository at this point in the history
  • Loading branch information
b4ldr committed Sep 4, 2017
1 parent a0cd33d commit 3e33f83
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
14 changes: 13 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -71,6 +72,9 @@
$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

# replicate $nginx to $mattermost_nginx if $mattermost_nginx_eq_nginx true
if $mattermost_nginx_eq_nginx {
Expand Down Expand Up @@ -144,7 +148,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'],
Expand All @@ -170,4 +174,12 @@
mode => '0644',
}
}

if $backup_cron_enable {
cron {'gitlab backup':
command => "${rake_exec} gitlab:backup:create CRON=1",
hour => $backup_cron_hour,
minute => $backup_cron_minute,
}
}
}
26 changes: 25 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -291,6 +296,18 @@
# 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
#
# === Examples
#
# class { 'gitlab':
Expand Down Expand Up @@ -328,6 +345,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,
Expand Down Expand Up @@ -387,6 +405,9 @@
$gitlab_workhorse = undef,
$user = undef,
$web_server = undef,
$backup_cron_enable = false,
$backup_cron_minute = 0,
$backup_cron_hour = 2,
$custom_hooks = {},
) inherits ::gitlab::params {

Expand Down Expand Up @@ -451,6 +472,9 @@
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_minutei,59)
validate_integer($backup_cron_hour,23)
validate_hash($custom_hooks)

class { '::gitlab::install': } ->
Expand All @@ -460,7 +484,7 @@
contain gitlab::install
contain gitlab::config
contain gitlab::service

create_resources(gitlab::custom_hook, $custom_hooks)

}
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3e33f83

Please sign in to comment.