From 1d8d6a303747542ce9b6fbe89abda38cf30ffedb Mon Sep 17 00:00:00 2001 From: aj1099 Date: Wed, 3 Jun 2020 08:13:18 +0530 Subject: [PATCH 1/2] Handle cron package from different module based on this https://github.com/puppetlabs/puppetlabs-mysql/pull/1269 --- manifests/backup/mysqldump.pp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/manifests/backup/mysqldump.pp b/manifests/backup/mysqldump.pp index 0fb07b298..68f9c6074 100644 --- a/manifests/backup/mysqldump.pp +++ b/manifests/backup/mysqldump.pp @@ -59,19 +59,13 @@ } if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '5' { - package {'crontabs': - ensure => present, - } + ensure_packages('crontabs') } elsif $::osfamily == 'RedHat' { - package {'cronie': - ensure => present, - } + ensure_packages('cronie') } elsif $::osfamily != 'FreeBSD' { - package {'cron': - ensure => present, - } + ensure_packages('cron') } - + cron { 'mysql-backup': ensure => $ensure, command => '/usr/local/sbin/mysqlbackup.sh', From f545e2013e583f85d4bc5ce24f2491fc347967e7 Mon Sep 17 00:00:00 2001 From: Ashish Jaiswal Date: Wed, 3 Jun 2020 04:59:03 +0200 Subject: [PATCH 2/2] Handle cron package installation --- manifests/backup/mysqlbackup.pp | 15 +++++++++------ manifests/backup/mysqldump.pp | 17 ++++++++++------- manifests/backup/xtrabackup.pp | 13 ++++++++++++- manifests/server/backup.pp | 4 ++++ 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/manifests/backup/mysqlbackup.pp b/manifests/backup/mysqlbackup.pp index 730264952..c0bf98b12 100644 --- a/manifests/backup/mysqlbackup.pp +++ b/manifests/backup/mysqlbackup.pp @@ -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": @@ -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') + } } cron { 'mysqlbackup-weekly': diff --git a/manifests/backup/mysqldump.pp b/manifests/backup/mysqldump.pp index 68f9c6074..c7d842e4b 100644 --- a/manifests/backup/mysqldump.pp +++ b/manifests/backup/mysqldump.pp @@ -29,6 +29,7 @@ $mysqlbackupdir_ensure = 'directory', $mysqlbackupdir_target = undef, $incremental_backups = false, + $install_cron = true, ) inherits mysql::params { unless $::osfamily == 'FreeBSD' { @@ -58,14 +59,16 @@ 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') + } } - + cron { 'mysql-backup': ensure => $ensure, command => '/usr/local/sbin/mysqlbackup.sh', diff --git a/manifests/backup/xtrabackup.pp b/manifests/backup/xtrabackup.pp index 305e891d2..f76112bd6 100644 --- a/manifests/backup/xtrabackup.pp +++ b/manifests/backup/xtrabackup.pp @@ -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) @@ -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. diff --git a/manifests/server/backup.pp b/manifests/server/backup.pp index 5cc780fe9..cb7fdea71 100644 --- a/manifests/server/backup.pp +++ b/manifests/server/backup.pp @@ -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, @@ -91,6 +93,7 @@ $maxallowedpacket = '1M', $optional_args = [], $incremental_backups = true, + $install_cron = true, ) inherits mysql::params { if $prescript and $provider =~ /(mysqldump|mysqlbackup)/ { @@ -124,6 +127,7 @@ 'maxallowedpacket' => $maxallowedpacket, 'optional_args' => $optional_args, 'incremental_backups' => $incremental_backups, + 'install_cron' => $install_cron, } }) }