diff options
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/conf.pp | 37 | ||||
-rw-r--r-- | manifests/server.pp | 5 | ||||
-rw-r--r-- | manifests/server/cron/optimize.pp | 12 | ||||
-rw-r--r-- | manifests/server/munin/debian.pp | 56 |
4 files changed, 72 insertions, 38 deletions
diff --git a/manifests/conf.pp b/manifests/conf.pp new file mode 100644 index 0000000..f9cbeb3 --- /dev/null +++ b/manifests/conf.pp @@ -0,0 +1,37 @@ +# $config needs to be a hash of key => value pairs. +# +# values in config are output as key = value, except when the value is empty; +# then just key is output. if you need to output an empty value in the form +# key = value, then you can specify empty quotes as the value (see example). +# +# mysql::conf { 'test': +# ensure => present, +# section => 'mysqld', +# config => { +# table_cache => '15000', +# skip_slave => '', +# something => '""', +# } +# } +# +# This will generate the following contents: +# [mysqld] +# skip_slave +# something = "" +# table_cache = 15000 +# +define mysql::conf ( + $section, + $config, + $ensure = present +) { + + include mysql::server::base + + file { "/etc/mysql/conf.d/${name}.cnf": + ensure => $ensure, + content => template('mysql/conf.erb'), + notify => Service['mysql'], + } + +} diff --git a/manifests/server.pp b/manifests/server.pp index a03dd7b..5a34b1c 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -8,6 +8,9 @@ class mysql::server ( $nagios_password_hash = 'absent', $backup_cron = false, $optimize_cron = false, + $optimize_hour = fqdn_rand(7), + $optimize_minute = fqdn_rand(60), + $optimize_day = fqdn_rand(7), $backup_dir = '/var/backups/mysql', $manage_backup_dir = true, $nagios_notcp = false @@ -20,7 +23,7 @@ class mysql::server ( } if $manage_munin and $::mysql_exists == 'true' { - if $munin_password == 'absent' { + if $munin_password == 'absent' and $::operatingsystem != debian { fail('need to set the munin password') } case $::operatingsystem { diff --git a/manifests/server/cron/optimize.pp b/manifests/server/cron/optimize.pp index d1d0257..5d4fa98 100644 --- a/manifests/server/cron/optimize.pp +++ b/manifests/server/cron/optimize.pp @@ -1,5 +1,9 @@ # optimize mysql databases regurarely -class mysql::server::cron::optimize { +class mysql::server::cron::optimize ( + $optimize_hour, + $optimize_minute, + $optimize_day +) { file { 'mysql_optimize_script': path => '/usr/local/sbin/optimize_mysql_tables.rb', @@ -12,9 +16,9 @@ class mysql::server::cron::optimize { cron { 'mysql_optimize_cron': command => '/usr/local/sbin/optimize_mysql_tables.rb', user => 'root', - minute => 40, - hour => 6, - weekday => 7, + minute => $optimize_minute, + hour => $optimize_hour, + weekday => $optimize_day, require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'], File['mysql_optimize_script'] ], diff --git a/manifests/server/munin/debian.pp b/manifests/server/munin/debian.pp index 9ff7863..c7ae961 100644 --- a/manifests/server/munin/debian.pp +++ b/manifests/server/munin/debian.pp @@ -1,35 +1,25 @@ # debian way of calling plugins -class mysql::server::munin::debian inherits mysql::server::munin::default { - Munin::Plugin['mysql_bytes']{ - config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", - require => Package['mysql'], - } - Munin::Plugin['mysql_queries']{ - config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", - require => Package['mysql'], - } - Munin::Plugin['mysql_slowqueries']{ - config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", - require => Package['mysql'], - } - Munin::Plugin['mysql_threads']{ - config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", - require => Package['mysql'], - } - Munin::Plugin::Deploy['mysql_connections']{ - config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", - require => Package['mysql'], - } - Munin::Plugin::Deploy['mysql_qcache']{ - config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", - require => Package['mysql'], - } - Munin::Plugin::Deploy['mysql_cache_mem']{ - config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", - require => Package['mysql'], - } - Munin::Plugin::Deploy['mysql_size_all']{ - config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", - require => Package['mysql'], - } +class mysql::server::munin::debian { + + munin::plugin { + [mysql_queries, mysql_slowqueries, mysql_bytes, mysql_threads]: + config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", + } + + munin::plugin::deploy{ + 'mysql_connections': + source => 'mysql/munin/mysql_connections'; + 'mysql_qcache': + source => 'mysql/munin/mysql_qcache'; + 'mysql_qcache_mem': + source => 'mysql/munin/mysql_qcache_mem'; + 'mysql_size_all': + source => 'mysql/munin/mysql_size_all'; + } + + Munin::Plugin::Deploy[ [ 'mysql_connections', 'mysql_qcache', 'mysql_qcache_mem', 'mysql_size_all' ] ] { + config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", + require => Package['mysql'], + } + } |