diff --git a/REFERENCE.md b/REFERENCE.md index bf629c1..5333bd2 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -42,6 +42,12 @@ Data type: `Stdlib::Absolutepath` The path to the f-upgrade configuration file. +##### `cronjob_options` + +Data type: `Hash` + +Options for the f-upgrade cron job. + ##### `hook_dir` Data type: `Stdlib::Absolutepath` @@ -56,6 +62,13 @@ A list of hooks. The content may be specified either directly using the "content" parameter or by specifying the "source" parameter – as supported by the file resource. +##### `manage_cronjob` + +Data type: `Boolean` + +Enables the f-upgrade cron job. By default it runs hourly to start or +resume the upgrade process. + ##### `package_ensure` Data type: `Enum['absent', 'installed', 'latest']` diff --git a/data/common.yaml b/data/common.yaml index 4769bf5..a0a3d26 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -1,8 +1,13 @@ --- f_upgrade::config: {} f_upgrade::config_file: '/usr/local/etc/f-upgrade.conf' +f_upgrade::cronjob_options: + command: '/usr/local/sbin/f-upgrade' + user: 'root' + minute: '15' f_upgrade::hook_dir: '/usr/local/etc/f-upgrade.hook.d' f_upgrade::hooks: {} +f_upgrade::manage_cronjob: true f_upgrade::package_ensure: 'installed' f_upgrade::package_name: 'f-upgrade' f_upgrade::upgrade: ~ diff --git a/manifests/config.pp b/manifests/config.pp index 405e600..bc0604c 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -20,7 +20,7 @@ if (($value =~ Undef) or ($value == '')) { # When no $value is set, remove the option from # the configuration files. - file_line { "remove f-upgrade option ${option}": + file_line { "remove f-upgrade option: ${option}": ensure => 'absent', path => $f_upgrade::config_file, match => "^${option}=", @@ -28,7 +28,7 @@ multiple => true, } } else { - file_line { "set f-upgrade option ${option}": + file_line { "set f-upgrade option: ${option}": ensure => 'present', path => $f_upgrade::config_file, line => "${option}=\'${$value}\'", @@ -37,4 +37,11 @@ } } } + + # Setup cronjob. + if $f_upgrade::manage_cronjob { + cron { 'Run f-upgrade': + * => $cronjob_options, + } + } } diff --git a/manifests/init.pp b/manifests/init.pp index 74be84b..c26107f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,6 +9,9 @@ # @param config_file # The path to the f-upgrade configuration file. # +# @param cronjob_options +# Options for the f-upgrade cron job. +# # @param hook_dir # The target directory for hook files. # @@ -17,6 +20,10 @@ # the "content" parameter or by specifying the "source" parameter – as # supported by the file resource. # +# @param manage_cronjob +# Enables the f-upgrade cron job. By default it runs hourly to start or +# resume the upgrade process. +# # @param package_ensure # The desired state for the f-upgrade package. # @@ -30,9 +37,11 @@ # class f_upgrade ( Hash $config, + Hash $cronjob_options, Stdlib::Absolutepath $config_file, Stdlib::Absolutepath $hook_dir, Hash $hooks, + Boolean $manage_cronjob, Enum['absent', 'installed', 'latest'] $package_ensure, String $package_name, Optional[String] $upgrade = undef,