Skip to content

Commit

Permalink
add a cron job
Browse files Browse the repository at this point in the history
  • Loading branch information
fraenki committed Nov 30, 2023
1 parent be2855e commit b65ae1d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
13 changes: 13 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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']`
Expand Down
5 changes: 5 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -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: ~
11 changes: 9 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
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}=",
match_for_absence => true,
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}\'",
Expand All @@ -37,4 +37,11 @@
}
}
}

# Setup cronjob.
if $f_upgrade::manage_cronjob {
cron { 'Run f-upgrade':
* => $cronjob_options,
}
}
}
9 changes: 9 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -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.
#
Expand All @@ -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,
Expand Down

0 comments on commit b65ae1d

Please sign in to comment.