Skip to content

Handle cron package from different module #1306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions manifests/backup/mysqlbackup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
$execpath = '/usr/bin:/usr/sbin:/bin:/sbin',
$optional_args = [],
$incremental_backups = false,
$install_cron = true,
) inherits mysql::params {

mysql_user { "${backupuser}@localhost":
Expand Down Expand Up @@ -65,12 +66,14 @@
require => Mysql_user["${backupuser}@localhost"],
}

if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '5' {
ensure_packages('crontabs')
} elsif $::osfamily == 'RedHat' {
ensure_packages('cronie')
} elsif $::osfamily != 'FreeBSD' {
ensure_packages('cron')
if $install_cron {
if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '5' {
ensure_packages('crontabs')
} elsif $::osfamily == 'RedHat' {
ensure_packages('cronie')
} elsif $::osfamily != 'FreeBSD' {
ensure_packages('cron')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this even do on FreeBSD?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @igalic, we don't usually test on FreeBSD, so this can be a mistake. I'll have a look! Thank you for highlighting this, feel free to open a PR if you want! Thanks again! Cheers!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i haven't actually used MySQL since switching to FreeBSD, it's all been SQLite 😅

}
}

cron { 'mysqlbackup-weekly':
Expand Down
19 changes: 8 additions & 11 deletions manifests/backup/mysqldump.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
$mysqlbackupdir_ensure = 'directory',
$mysqlbackupdir_target = undef,
$incremental_backups = false,
$install_cron = true,
) inherits mysql::params {

unless $::osfamily == 'FreeBSD' {
Expand Down Expand Up @@ -58,17 +59,13 @@
require => Mysql_user["${backupuser}@localhost"],
}

if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '5' {
package {'crontabs':
ensure => present,
}
} elsif $::osfamily == 'RedHat' {
package {'cronie':
ensure => present,
}
} elsif $::osfamily != 'FreeBSD' {
package {'cron':
ensure => present,
if $install_cron {
if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '5' {
ensure_packages('crontabs')
} elsif $::osfamily == 'RedHat' {
ensure_packages('cronie')
} elsif $::osfamily != 'FreeBSD' {
ensure_packages('cron')
}
}

Expand Down
13 changes: 12 additions & 1 deletion manifests/backup/xtrabackup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
$execpath = '/usr/bin:/usr/sbin:/bin:/sbin',
$optional_args = [],
$additional_cron_args = '--backup',
$incremental_backups = true
$incremental_backups = true,
$install_cron = true,
) inherits mysql::params {

ensure_packages($xtrabackup_package_name)
Expand All @@ -50,6 +51,16 @@
}
}

if $install_cron {
if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '5' {
ensure_packages('crontabs')
} elsif $::osfamily == 'RedHat' {
ensure_packages('cronie')
} elsif $::osfamily != 'FreeBSD' {
ensure_packages('cron')
}
}

if $incremental_backups {
# Warn if old backups are removed too soon. Incremental backups will fail
# if the full backup is no longer available.
Expand Down
4 changes: 4 additions & 0 deletions manifests/server/backup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
# Defines the maximum SQL statement size for the backup dump script. The default value is 1MB, as this is the default MySQL Server value.
# @param optional_args
# Specifies an array of optional arguments which should be passed through to the backup tool. (Supported by the xtrabackup and mysqldump providers.)
# @param install_cron
# Manage installation of cron package
class mysql::server::backup (
$backupuser = undef,
$backuppassword = undef,
Expand All @@ -91,6 +93,7 @@
$maxallowedpacket = '1M',
$optional_args = [],
$incremental_backups = true,
$install_cron = true,
) inherits mysql::params {

if $prescript and $provider =~ /(mysqldump|mysqlbackup)/ {
Expand Down Expand Up @@ -124,6 +127,7 @@
'maxallowedpacket' => $maxallowedpacket,
'optional_args' => $optional_args,
'incremental_backups' => $incremental_backups,
'install_cron' => $install_cron,
}
})
}