summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2009-12-10 14:52:50 -0500
committerJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2009-12-10 14:52:50 -0500
commit9ec0ef766c210ac6ca26a725701a89031a56fbab (patch)
treeb4164616ac1558a790f33ff6e3bdbe89915da7c0
parent4a24fffe14abc4ac89322c2707ec6b16d46c0917 (diff)
make backup and optimize cron jobs optional; introduce $mysql_backup_cron, $mysql_backup_dir and$mysql_optimize_cron; use a module_dir for scripts
-rw-r--r--files/backup/mysql_backup.cron1
-rw-r--r--files/scripts/CentOS/setmysqlpass.sh (renamed from files/config/CentOS/setmysqlpass.sh)0
-rw-r--r--files/scripts/Debian/setmysqlpass.sh (renamed from files/config/Debian/setmysqlpass.sh)0
-rw-r--r--files/scripts/optimize_tables.rb (renamed from files/optimize/optimize_tables.rb)0
-rw-r--r--manifests/server.pp6
-rw-r--r--manifests/server/base.pp45
-rw-r--r--manifests/server/clientpackage.pp3
-rw-r--r--manifests/server/cron.pp2
-rw-r--r--manifests/server/cron/backup.pp22
-rw-r--r--manifests/server/cron/optimize.pp18
10 files changed, 67 insertions, 30 deletions
diff --git a/files/backup/mysql_backup.cron b/files/backup/mysql_backup.cron
deleted file mode 100644
index 1cb21ff..0000000
--- a/files/backup/mysql_backup.cron
+++ /dev/null
@@ -1 +0,0 @@
-00 01 * * * root /usr/bin/mysqldump --default-character-set=utf8 --all-databases --all --flush-logs --lock-tables --single-transaction | gzip > /var/lib/mysql/data/mysqldump.sql.gz && chmod 600 /var/lib/mysql/data/mysqldump.sql.gz
diff --git a/files/config/CentOS/setmysqlpass.sh b/files/scripts/CentOS/setmysqlpass.sh
index d762a20..d762a20 100644
--- a/files/config/CentOS/setmysqlpass.sh
+++ b/files/scripts/CentOS/setmysqlpass.sh
diff --git a/files/config/Debian/setmysqlpass.sh b/files/scripts/Debian/setmysqlpass.sh
index 5bd63e2..5bd63e2 100644
--- a/files/config/Debian/setmysqlpass.sh
+++ b/files/scripts/Debian/setmysqlpass.sh
diff --git a/files/optimize/optimize_tables.rb b/files/scripts/optimize_tables.rb
index 52e726e..52e726e 100644
--- a/files/optimize/optimize_tables.rb
+++ b/files/scripts/optimize_tables.rb
diff --git a/manifests/server.pp b/manifests/server.pp
index eb4daa7..d3916a7 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -1,13 +1,19 @@
class mysql::server {
+
+ $mysql_moduledir = "${module_dir_path}/mysql"
+ module_dir { ['mysql', 'mysql/server']: }
+
case $operatingsystem {
gentoo: { include mysql::server::gentoo }
centos: { include mysql::server::centos }
debian: { include mysql::server::debian }
default: { include mysql::server::base }
}
+
if $use_munin {
include mysql::munin
}
+
if $use_shorewall {
include shorewall::rules::mysql
}
diff --git a/manifests/server/base.pp b/manifests/server/base.pp
index 3f1b75b..480eda9 100644
--- a/manifests/server/base.pp
+++ b/manifests/server/base.pp
@@ -37,8 +37,8 @@ class mysql::server::base {
}
file { 'mysql_setmysqlpass.sh':
- path => '/usr/local/sbin/setmysqlpass.sh',
- source => "puppet://$server/modules/mysql/config/${operatingsystem}/setmysqlpass.sh",
+ path => "${mysql_moduledir}/server/setmysqlpass.sh",
+ source => "puppet://${server}/modules/mysql/scripts/${operatingsystem}/setmysqlpass.sh",
require => Package['mysql-server'],
owner => root, group => 0, mode => 0500;
}
@@ -52,36 +52,29 @@ class mysql::server::base {
}
exec { 'mysql_set_rootpw':
- command => "/usr/local/sbin/setmysqlpass.sh $mysql_rootpw",
+ command => "${mysql_moduledir}/server/setmysqlpass.sh ${mysql_rootpw}",
unless => "mysqladmin -uroot status > /dev/null",
require => [ File['mysql_setmysqlpass.sh'], Package['mysql-server'] ],
refreshonly => true,
}
- file { 'mysql_backup_cron':
- path => '/etc/cron.d/mysql_backup.cron',
- source => [ "puppet://$server/modules/mysql/backup/mysql_backup.cron.${operatingsystem}",
- "puppet://$server/modules/mysql/backup/mysql_backup.cron" ],
- require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'] ],
- owner => root, group => 0, mode => 0600;
- }
-
- file { 'mysql_optimize_cron':
- path => '/etc/cron.weekly/mysql_optimize_tables.rb',
- source => "puppet://$server/modules/mysql/optimize/optimize_tables.rb",
- require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'] ],
- owner => root, group => 0, mode => 0700;
- }
+ if ($mysql_backup_cron) {
+ include mysql::server::cron::backup
+ }
+
+ if ($mysql_optimize_cron) {
+ include mysql::server::cron::optimize
+ }
- service { 'mysql':
- ensure => running,
- enable => true,
- hasstatus => true,
- require => Package['mysql-client'],
+ service { 'mysql':
+ ensure => running,
+ enable => true,
+ hasstatus => true,
+ require => Package['mysql-client'],
}
- # Collect all databases and users
- Mysql_database<<| tag == "mysql_${fqdn}" |>>
- Mysql_user<<| tag == "mysql_${fqdn}" |>>
- Mysql_grant<<| tag == "mysql_${fqdn}" |>>
+ # Collect all databases and users
+ Mysql_database<<| tag == "mysql_${fqdn}" |>>
+ Mysql_user<<| tag == "mysql_${fqdn}" |>>
+ Mysql_grant<<| tag == "mysql_${fqdn}" |>>
}
diff --git a/manifests/server/clientpackage.pp b/manifests/server/clientpackage.pp
index 038f7c9..8f317c1 100644
--- a/manifests/server/clientpackage.pp
+++ b/manifests/server/clientpackage.pp
@@ -9,7 +9,4 @@ class mysql::server::clientpackage inherits mysql::server::base {
Exec['mysql_set_rootpw']{
require +> Package['mysql-client'],
}
- File['mysql_backup_cron']{
- require +> Package['mysql-client'],
- }
}
diff --git a/manifests/server/cron.pp b/manifests/server/cron.pp
new file mode 100644
index 0000000..36a7a1f
--- /dev/null
+++ b/manifests/server/cron.pp
@@ -0,0 +1,2 @@
+class mysql::server::cron {
+}
diff --git a/manifests/server/cron/backup.pp b/manifests/server/cron/backup.pp
new file mode 100644
index 0000000..33b8f0f
--- /dev/null
+++ b/manifests/server/cron/backup.pp
@@ -0,0 +1,22 @@
+class mysql::server::cron::backup {
+
+ $real_mysql_backup_dir = $mysql_backup_dir ? {
+ '' => '/var/backups/mysql',
+ default => $mysql_backup_dir,
+ }
+
+ file { 'mysql_backup_dir':
+ path => $real_mysql_backup_dir,
+ source => "puppet://${server}/modules/common/empty",
+ ensure => directory,
+ owner => root, group => 0, mode => 0700,
+ }
+
+ cron { 'mysql_backup_cron':
+ command => '/usr/bin/mysqldump --default-character-set=utf8 --all-databases --all --flush-logs --lock-tables --single-transaction | gzip > ${real_mysql_backup_dir}/mysqldump.sql.gz && chmod 600 ${real_mysql_backup_dir}/mysqldump.sql.gz',
+ user => 'root',
+ minute => 0,
+ hour => 1,
+ require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'], File['mysql_backup_dir'] ],
+ }
+}
diff --git a/manifests/server/cron/optimize.pp b/manifests/server/cron/optimize.pp
new file mode 100644
index 0000000..29ee66e
--- /dev/null
+++ b/manifests/server/cron/optimize.pp
@@ -0,0 +1,18 @@
+class mysql::server::cron::optimize {
+
+ file { 'mysql_optimize_script':
+ path => "${mysql_moduledir}/server/optimize_tables.rb",
+ source => "puppet://${server}/modules/mysql/scripts/optimize_tables.rb",
+ owner => root, group => 0, mode => 0700;
+ }
+
+ cron { 'mysql_optimize_cron':
+ command => "${mysql_moduledir}/server/optimize_tables.rb",
+ user => 'root',
+ minute => 40,
+ hour => 6,
+ weekday => 7,
+ require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'], File['mysql_optimize_script'] ],
+ }
+
+}