summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'manifests')
-rw-r--r--manifests/default_database.pp45
-rw-r--r--manifests/server.pp9
-rw-r--r--manifests/server/base.pp20
-rw-r--r--manifests/server/cron.pp2
-rw-r--r--manifests/server/cron/backup.pp19
-rw-r--r--manifests/server/cron/optimize.pp6
6 files changed, 74 insertions, 27 deletions
diff --git a/manifests/default_database.pp b/manifests/default_database.pp
new file mode 100644
index 0000000..1c99af5
--- /dev/null
+++ b/manifests/default_database.pp
@@ -0,0 +1,45 @@
+# create default database
+# generate hashed password with:
+# ruby -r'digest/sha1' -e 'puts "*" + Digest::SHA1.hexdigest(Digest::SHA1.digest(ARGV[0])).upcase' PASSWORD
+define mysql::default_database(
+ $username = 'absent',
+ $password,
+ $password_is_encrypted = true,
+ $privileges = 'all',
+ $host = '127.0.0.1',
+ $ensure = 'present'
+) {
+ $real_username = $username ? {
+ 'absent' => $name,
+ default => $username
+ }
+ mysql_database{"$name":
+ ensure => $ensure
+ }
+ case $password {
+ 'absent': {
+ info("we don't create the user for database: ${name}")
+ $grant_require = Mysql_database["$name"]
+ }
+ default: {
+ mysql_user{"${real_username}@${host}":
+ password_hash => $password_is_encrypted ? {
+ true => "$password",
+ default => mysql_password("$password")
+ },
+ ensure => $ensure,
+ require => [
+ Mysql_database["$name"]
+ ],
+ }
+ $grant_require = [
+ Mysql_database["$name"],
+ Mysql_user["${real_username}@${host}"]
+ ]
+ }
+ }
+ mysql_grant{"${real_username}@${host}/${name}":
+ privileges => "$privileges",
+ require => $grant_require,
+ }
+}
diff --git a/manifests/server.pp b/manifests/server.pp
index 51324b5..e6e5fac 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -1,9 +1,5 @@
class mysql::server {
- include common::moduledir
- $mysql_moduledir = "${common::moduledir::module_dir_path}/mysql"
- module_dir { ['mysql', 'mysql/server']: }
-
case $operatingsystem {
gentoo: { include mysql::server::gentoo }
centos: { include mysql::server::centos }
@@ -19,7 +15,10 @@ class mysql::server {
}
if $use_nagios {
- include mysql::server::nagios
+ case $nagios_check_mysql {
+ false: { info("We don't do nagioschecks for mysql on ${fqdn}" ) }
+ default: { include mysql::server::nagios }
+ }
}
if $use_shorewall {
diff --git a/manifests/server/base.pp b/manifests/server/base.pp
index 43ce158..b14fa86 100644
--- a/manifests/server/base.pp
+++ b/manifests/server/base.pp
@@ -5,13 +5,13 @@ class mysql::server::base {
file { 'mysql_main_cnf':
path => '/etc/mysql/my.cnf',
source => [
- "puppet://$server/modules/site-mysql/${fqdn}/my.cnf",
- "puppet://$server/modules/site-mysql/my.cnf.${operatingsystem}.{lsbdistcodename}",
- "puppet://$server/modules/site-mysql/my.cnf.${operatingsystem}",
- "puppet://$server/modules/site-mysql/my.cnf",
- "puppet://$server/modules/mysql/config/my.cnf.${operatingsystem}.{lsbdistcodename}",
- "puppet://$server/modules/mysql/config/my.cnf.${operatingsystem}",
- "puppet://$server/modules/mysql/config/my.cnf"
+ "puppet://modules/site-mysql/${fqdn}/my.cnf",
+ "puppet://modules/site-mysql/my.cnf.${operatingsystem}.{lsbdistcodename}",
+ "puppet://modules/site-mysql/my.cnf.${operatingsystem}",
+ "puppet://modules/site-mysql/my.cnf",
+ "puppet://modules/mysql/config/my.cnf.${operatingsystem}.{lsbdistcodename}",
+ "puppet://modules/mysql/config/my.cnf.${operatingsystem}",
+ "puppet://modules/mysql/config/my.cnf"
],
ensure => file,
require => Package['mysql-server'],
@@ -40,8 +40,8 @@ class mysql::server::base {
}
file { 'mysql_setmysqlpass.sh':
- path => "${mysql_moduledir}/server/setmysqlpass.sh",
- source => "puppet://${server}/modules/mysql/scripts/${operatingsystem}/setmysqlpass.sh",
+ path => '/usr/local/sbin/setmysqlpass.sh',
+ source => "puppet:///modules/mysql/scripts/${operatingsystem}/setmysqlpass.sh",
require => Package['mysql-server'],
owner => root, group => 0, mode => 0500;
}
@@ -55,7 +55,7 @@ class mysql::server::base {
}
exec { 'mysql_set_rootpw':
- command => "${mysql_moduledir}/server/setmysqlpass.sh ${mysql_rootpw}",
+ command => "/user/local/sbin/setmysqlpass.sh ${mysql_rootpw}",
unless => "mysqladmin -uroot status > /dev/null",
require => [ File['mysql_setmysqlpass.sh'], Package['mysql-server'] ],
refreshonly => true,
diff --git a/manifests/server/cron.pp b/manifests/server/cron.pp
deleted file mode 100644
index 36a7a1f..0000000
--- a/manifests/server/cron.pp
+++ /dev/null
@@ -1,2 +0,0 @@
-class mysql::server::cron {
-}
diff --git a/manifests/server/cron/backup.pp b/manifests/server/cron/backup.pp
index 33b8f0f..c1e84d1 100644
--- a/manifests/server/cron/backup.pp
+++ b/manifests/server/cron/backup.pp
@@ -5,18 +5,23 @@ class mysql::server::cron::backup {
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,
+ case $mysql_manage_backup_dir {
+ false: { info("We don't manage \$mysql_backup_dir ($mysql_backup_dir)") }
+ default: {
+ file { 'mysql_backup_dir':
+ path => $real_mysql_backup_dir,
+ ensure => directory,
+ before => Cron['mysql_backup_cron'],
+ 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',
+ 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'] ],
+ require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'] ],
}
}
diff --git a/manifests/server/cron/optimize.pp b/manifests/server/cron/optimize.pp
index 29ee66e..c238930 100644
--- a/manifests/server/cron/optimize.pp
+++ b/manifests/server/cron/optimize.pp
@@ -1,13 +1,13 @@
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",
+ 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':
- command => "${mysql_moduledir}/server/optimize_tables.rb",
+ command => '/usr/local/sbin/optimize_mysql_tables.rb',
user => 'root',
minute => 40,
hour => 6,