diff options
Diffstat (limited to 'manifests/server')
-rw-r--r-- | manifests/server/base.pp | 21 | ||||
-rw-r--r-- | manifests/server/cron.pp | 2 | ||||
-rw-r--r-- | manifests/server/cron/backup.pp | 19 | ||||
-rw-r--r-- | manifests/server/cron/optimize.pp | 6 | ||||
-rw-r--r-- | manifests/server/munin/base.pp | 20 | ||||
-rw-r--r-- | manifests/server/munin/debian.pp | 17 | ||||
-rw-r--r-- | manifests/server/munin/default.pp | 13 | ||||
-rw-r--r-- | manifests/server/nagios.pp | 55 |
8 files changed, 94 insertions, 59 deletions
diff --git a/manifests/server/base.pp b/manifests/server/base.pp index 480eda9..7ddff38 100644 --- a/manifests/server/base.pp +++ b/manifests/server/base.pp @@ -5,10 +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", - "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'], @@ -37,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; } @@ -52,8 +55,8 @@ class mysql::server::base { } exec { 'mysql_set_rootpw': - command => "${mysql_moduledir}/server/setmysqlpass.sh ${mysql_rootpw}", - unless => "mysqladmin -uroot status > /dev/null", + command => "/usr/local/sbin/setmysqlpass.sh ${mysql_rootpw}", + unless => "/usr/bin/mysqladmin -uroot status > /dev/null", require => [ File['mysql_setmysqlpass.sh'], Package['mysql-server'] ], refreshonly => true, } @@ -70,7 +73,7 @@ class mysql::server::base { ensure => running, enable => true, hasstatus => true, - require => Package['mysql-client'], + require => Package['mysql-server'], } # Collect all databases and users 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, diff --git a/manifests/server/munin/base.pp b/manifests/server/munin/base.pp new file mode 100644 index 0000000..ad4bb8a --- /dev/null +++ b/manifests/server/munin/base.pp @@ -0,0 +1,20 @@ +class mysql::server::munin::base { + + file { + "/usr/local/share/munin-plugins/mysql_connections": + source => "puppet:///modules/mysql/munin/mysql_connections", + mode => 0755, owner => root, group => root; + + "/usr/local/share/munin-plugins/mysql_qcache": + source => "puppet:///modules/mysql/munin/mysql_qcache", + mode => 0755, owner => root, group => root; + + "/usr/local/share/munin-plugins/mysql_qcache_mem": + source => "puppet:///modules/mysql/munin/mysql_qcache_mem", + mode => 0755, owner => root, group => root; + + "/usr/local/share/munin-plugins/mysql_size_all": + source => "puppet:///modules/mysql/munin/mysql_size_all", + mode => 0755, owner => root, group => root; + } +} diff --git a/manifests/server/munin/debian.pp b/manifests/server/munin/debian.pp index 2b2acb4..d1636d5 100644 --- a/manifests/server/munin/debian.pp +++ b/manifests/server/munin/debian.pp @@ -1,9 +1,14 @@ # manifests/server/munin/debian.pp -class mysql::server::munin::debian { - munin::plugin { - [mysql_bytes, mysql_queries, mysql_slowqueries, mysql_threads]: - config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", - require => Package['mysql'], - } +class mysql::server::munin::debian inherits mysql::server::munin::base { + munin::plugin { + [ mysql_bytes, mysql_queries, mysql_slowqueries, mysql_threads ]: + config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", + require => Package['mysql']; + + [ mysql_connections, mysql_qcache, mysql_cache_mem, mysql_size_all ]: + config => "user root\nenv.mysqlopts --defaults-file=/etc/mysql/debian.cnf", + script_path_in => "/usr/local/share/munin-plugins", + require => Package['mysql']; + } } diff --git a/manifests/server/munin/default.pp b/manifests/server/munin/default.pp index b60ff0d..2660ea0 100644 --- a/manifests/server/munin/default.pp +++ b/manifests/server/munin/default.pp @@ -1,6 +1,6 @@ # manifests/server/munin/default.pp -class mysql::server::munin::default { +class mysql::server::munin::default inherits mysql::server::munin::base { case $munin_mysql_password { '': { fail("please specify \$munin_mysql_password to enable mysql munin plugin")} } @@ -16,8 +16,13 @@ class mysql::server::munin::default { } munin::plugin { - [mysql_bytes, mysql_queries, mysql_slowqueries, mysql_threads]: - config => "env.mysqlopts --user=munin --password=${munin_mysql_password} -h localhost", - require => [ Mysql_grant['munin@localhost'], Mysql_user['munin@localhost'], Package['mysql'] ] + [ mysql_bytes, mysql_queries, mysql_slowqueries, mysql_threads ]: + config => "env.mysqlopts --user=munin --password=${munin_mysql_password} -h localhost", + require => [ Mysql_grant['munin@localhost'], Mysql_user['munin@localhost'], Package['mysql'] ]; + + [ mysql_connections, mysql_qcache, mysql_cache_mem, mysql_size_all ]: + script_path_in => "/usr/local/share/munin-plugins", + config => "env.mysqlopts --user=munin --password=${munin_mysql_password} -h localhost", + require => [ Mysql_grant['munin@localhost'], Mysql_user['munin@localhost'], Package['mysql'] ]; } } diff --git a/manifests/server/nagios.pp b/manifests/server/nagios.pp index 4c1c153..4e2b8b8 100644 --- a/manifests/server/nagios.pp +++ b/manifests/server/nagios.pp @@ -1,33 +1,32 @@ # manifests/server/nagios.pp class mysql::server::nagios { - case $nagios_mysql_password { - '': { fail("please specify \$nagios_mysql_password to enable nagios mysql check")} - } - - # Flip this variable if you need to check MySQL through check_ssh or check_nrpe, - # in that case you will have to manually define nagios::service::mysql - if ($nagios_mysql_notcp != true) { - $nagios_mysql_user = 'nagios@%' - nagios::service::mysql { 'mysql': - check_hostname => $fqdn, - check_username => 'nagios', - check_password => $nagios_mysql_password, - check_mode => 'tcp', - require => Mysql_grant[$nagios_mysql_user], - } - } - else { - $nagios_mysql_user = 'nagios@localhost' - } - - mysql_user{$nagios_mysql_user: - password_hash => mysql_password("${nagios_mysql_password}"), - require => Package['mysql'], - } - - mysql_grant{$nagios_mysql_user: - privileges => 'select_priv', - require => [ Mysql_user[$nagios_mysql_user], Package['mysql'] ], + case $nagios_mysql_password { + '': { fail("please specify \$nagios_mysql_password to enable nagios mysql check")} + } + + # Flip this variable if you need to check MySQL through check_ssh or check_nrpe, + # in that case you will have to manually define nagios::service::mysql + if ($nagios_mysql_notcp != true) { + $nagios_mysql_user = 'nagios@%' + nagios::service::mysql { 'connection-time': + check_hostname => $fqdn, + require => Mysql_grant[$nagios_mysql_user], } + } + else { + $nagios_mysql_user = 'nagios@localhost' + } + + mysql_user{$nagios_mysql_user: + password_hash => mysql_password("${nagios_mysql_password}"), + require => Package['mysql'], + } + + # repl_client_priv is needed to check the replication slave status + # modes: slave-lag, slave-io-running and slave-sql-running + mysql_grant{$nagios_mysql_user: + privileges => [ 'select_priv', 'repl_client_priv' ], + require => [ Mysql_user[$nagios_mysql_user], Package['mysql'] ], + } } |