Cron jobs are not removed when unused.
Currently, if you have the bad idea of setting backup_cron or optimize_cron to true in the main class and later to change it back to false, the associated cronjob will stay in place even though you don't want it. To make this option more consistant, let's remove cron jobs (and backup helper scripts) when the appropriate option is set to false. Signed-off-by: Gabriel Filion <gabster@lelutin.ca>
This commit is contained in:
parent
9b327191c7
commit
35c351f926
4 changed files with 37 additions and 21 deletions
|
@ -1,11 +1,14 @@
|
|||
# Helpers for mysql servers
|
||||
# In a dedicated class so they can
|
||||
# also be pulled in somewhere else
|
||||
class mysql::server::backup_helpers{
|
||||
class mysql::server::backup_helpers (
|
||||
$ensure = present
|
||||
) {
|
||||
file{'/usr/local/bin/mysql_extract_from_backup':
|
||||
source => 'puppet:///modules/mysql/backup_helpers/mysql_extract_from_backup.sh',
|
||||
owner => root,
|
||||
group => 0,
|
||||
mode => '0555';
|
||||
ensure => $ensure,
|
||||
source => 'puppet:///modules/mysql/backup_helpers/mysql_extract_from_backup.sh',
|
||||
owner => root,
|
||||
group => 0,
|
||||
mode => '0555';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,17 +64,24 @@ class mysql::server::base {
|
|||
refreshonly => true,
|
||||
}
|
||||
|
||||
if $mysql::server::backup_cron {
|
||||
include mysql::server::cron::backup
|
||||
include mysql::server::backup_helpers
|
||||
$backup_ensure = $mysql::server::backup_cron ? {
|
||||
true => present,
|
||||
false => absent,
|
||||
}
|
||||
|
||||
if $mysql::server::optimize_cron {
|
||||
class { 'mysql::server::cron::optimize':
|
||||
optimize_hour => $mysql::server::optimize_hour,
|
||||
optimize_minute => $mysql::server::optimize_minute,
|
||||
optimize_day => $mysql::server::optimize_day,
|
||||
}
|
||||
class { 'mysql::server::cron::backup': ensure => $backup_ensure }
|
||||
class { 'mysql::server::backup_helpers': ensure => $backup_ensure }
|
||||
|
||||
$cron_ensure = $mysql::server::optimize_cron ? {
|
||||
true => present,
|
||||
false => absent,
|
||||
}
|
||||
|
||||
class { 'mysql::server::cron::optimize':
|
||||
ensure => $cron_ensure,
|
||||
optimize_hour => $mysql::server::optimize_hour,
|
||||
optimize_minute => $mysql::server::optimize_minute,
|
||||
optimize_day => $mysql::server::optimize_day,
|
||||
}
|
||||
|
||||
service { 'mysql':
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# setup a basic cronjob to backup mysql database
|
||||
class mysql::server::cron::backup {
|
||||
class mysql::server::cron::backup (
|
||||
$ensure = present,
|
||||
) {
|
||||
if $mysql::server::manage_backup_dir {
|
||||
file { 'mysql_backup_dir':
|
||||
ensure => directory,
|
||||
|
@ -12,6 +14,7 @@ class mysql::server::cron::backup {
|
|||
}
|
||||
|
||||
cron { 'mysql_backup_cron':
|
||||
ensure => $ensure,
|
||||
command => "/usr/bin/mysqldump --default-character-set=utf8 --all-databases --create-options --flush-logs --lock-tables --single-transaction | gzip > ${mysql::server::backup_dir}/mysqldump.sql.gz && chmod 600 ${mysql::server::backup_dir}/mysqldump.sql.gz",
|
||||
user => 'root',
|
||||
minute => 0,
|
||||
|
|
|
@ -2,18 +2,21 @@
|
|||
class mysql::server::cron::optimize (
|
||||
$optimize_hour,
|
||||
$optimize_minute,
|
||||
$optimize_day
|
||||
$optimize_day,
|
||||
$ensure = present,
|
||||
) {
|
||||
|
||||
file { 'mysql_optimize_script':
|
||||
path => '/usr/local/sbin/optimize_mysql_tables.rb',
|
||||
source => 'puppet:///modules/mysql/scripts/optimize_tables.rb',
|
||||
owner => root,
|
||||
group => 0,
|
||||
mode => '0700';
|
||||
ensure => $ensure,
|
||||
path => '/usr/local/sbin/optimize_mysql_tables.rb',
|
||||
source => 'puppet:///modules/mysql/scripts/optimize_tables.rb',
|
||||
owner => root,
|
||||
group => 0,
|
||||
mode => '0700';
|
||||
}
|
||||
|
||||
cron { 'mysql_optimize_cron':
|
||||
ensure => $ensure,
|
||||
command => '/usr/local/sbin/optimize_mysql_tables.rb',
|
||||
user => 'root',
|
||||
minute => $optimize_minute,
|
||||
|
|
Loading…
Reference in a new issue