diff options
-rw-r--r-- | files/config/my.cnf.Debian | 32 | ||||
-rw-r--r-- | manifests/admin_user.pp | 22 | ||||
-rw-r--r-- | manifests/client.pp | 9 | ||||
-rw-r--r-- | manifests/client/base.pp | 7 | ||||
-rw-r--r-- | manifests/client/debian.pp | 3 | ||||
-rw-r--r-- | manifests/client/perl.pp | 5 | ||||
-rw-r--r-- | manifests/client/perl/debian.pp | 2 | ||||
-rw-r--r-- | manifests/client/ruby.pp | 5 | ||||
-rw-r--r-- | manifests/client/ruby/debian.pp | 3 | ||||
-rw-r--r-- | manifests/default_database.pp | 37 | ||||
-rw-r--r-- | manifests/devel.pp | 7 | ||||
-rw-r--r-- | manifests/disable.pp | 20 | ||||
-rw-r--r-- | manifests/server.pp | 51 | ||||
-rw-r--r-- | manifests/server/account_security.pp | 12 | ||||
-rw-r--r-- | manifests/server/base.pp | 150 | ||||
-rw-r--r-- | manifests/server/centos.pp | 14 | ||||
-rw-r--r-- | manifests/server/clientpackage.pp | 23 | ||||
-rw-r--r-- | manifests/server/cron/backup.pp | 41 | ||||
-rw-r--r-- | manifests/server/cron/optimize.pp | 32 | ||||
-rw-r--r-- | manifests/server/debian.pp | 26 | ||||
-rw-r--r-- | manifests/server/gentoo.pp | 9 | ||||
-rw-r--r-- | manifests/server/munin/base.pp | 20 | ||||
-rw-r--r-- | manifests/server/munin/debian.pp | 45 | ||||
-rw-r--r-- | manifests/server/munin/default.pp | 29 | ||||
-rw-r--r-- | manifests/server/nagios.pp | 50 |
25 files changed, 324 insertions, 330 deletions
diff --git a/files/config/my.cnf.Debian b/files/config/my.cnf.Debian index e2f1559..069949c 100644 --- a/files/config/my.cnf.Debian +++ b/files/config/my.cnf.Debian @@ -50,27 +50,29 @@ bind-address = 127.0.0.1 # key_buffer = 16M max_allowed_packet = 16M -thread_stack = 128K -thread_cache_size = 8 +thread_stack = 192K +thread_cache_size = 8 # This replaces the startup script and checks MyISAM tables if needed # the first time they are touched -myisam-recover = BACKUP +myisam-recover = BACKUP #max_connections = 100 #table_cache = 64 #thread_concurrency = 10 # # * Query Cache Configuration # -query_cache_limit = 1M +query_cache_limit = 1M query_cache_size = 16M # # * Logging and Replication # # Both location gets rotated by the cronjob. # Be aware that this log type is a performance killer. -#log = /var/log/mysql/mysql.log +# As of 5.1 you can enable the log at runtime! +#general_log_file = /var/log/mysql/mysql.log +#general_log = 1 # -# Error logging goes to syslog. This is a Debian improvement :) +# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf. # # Here you can see queries with especially long duration #log_slow_queries = /var/log/mysql/mysql-slow.log @@ -87,11 +89,6 @@ max_binlog_size = 100M #binlog_do_db = include_database_name #binlog_ignore_db = include_database_name # -# * BerkeleyDB -# -# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. -skip-bdb -# # * InnoDB # # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. @@ -127,20 +124,7 @@ max_allowed_packet = 16M key_buffer = 16M # -# * NDB Cluster -# -# See /usr/share/doc/mysql-server-*/README.Debian for more information. -# -# The following configuration is read by the NDB Data Nodes (ndbd processes) -# not from the NDB Management Nodes (ndb_mgmd processes). -# -# [MYSQL_CLUSTER] -# ndb-connectstring=127.0.0.1 - - -# # * IMPORTANT: Additional settings that can override those from this file! # The files must end with '.cnf', otherwise they'll be ignored. # !includedir /etc/mysql/conf.d/ - diff --git a/manifests/admin_user.pp b/manifests/admin_user.pp index 52d01fc..66e0cc1 100644 --- a/manifests/admin_user.pp +++ b/manifests/admin_user.pp @@ -1,17 +1,21 @@ +# add an admin user that has +# access to all databases define mysql::admin_user( + $password, $ensure = present, - $host = '127.0.0.1', - $password + $host = '127.0.0.1' ){ + $password_hash = $password ? { + 'trocla' => trocla("mysql_admin-user_${name}",'mysql'), + default => $password, + } mysql_user{"${name}@${host}": - ensure => $ensure, - password_hash => $password ? { - 'trocla' => trocla("mysql_admin-user_${name}",'mysql'), - default => $password, - }, + ensure => $ensure, + password_hash => $password_hash, + require => Exec['mysql_set_rootpw'], } mysql_grant{"${name}@${host}": - privileges => 'all', - require => Mysql_user["${name}@${host}"], + privileges => 'all', + require => Mysql_user["${name}@${host}"], } } diff --git a/manifests/client.pp b/manifests/client.pp index 47f522f..c76e906 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -1,12 +1,13 @@ -class mysql::client ( $use_shorewall = hiera('use_shorewall',false) ) { - +# client package for mysql +class mysql::client ( + $manage_shorewall = false +) { case $::operatingsystem { debian: { include mysql::client::debian } default: { include mysql::client::base } } - if $use_shorewall { + if $manage_shorewall { include shorewall::rules::out::mysql } - } diff --git a/manifests/client/base.pp b/manifests/client/base.pp index d992b0f..b09b90e 100644 --- a/manifests/client/base.pp +++ b/manifests/client/base.pp @@ -1,8 +1,7 @@ +# basic mysql client stuff class mysql::client::base { - package { 'mysql': - ensure => present, - alias => 'mysql-client', + ensure => present, + alias => 'mysql-client', } - } diff --git a/manifests/client/debian.pp b/manifests/client/debian.pp index b400c4a..fffea50 100644 --- a/manifests/client/debian.pp +++ b/manifests/client/debian.pp @@ -1,7 +1,6 @@ +# debian client name class mysql::client::debian inherits mysql::client::base { - Package['mysql'] { name => 'mysql-client', } - } diff --git a/manifests/client/perl.pp b/manifests/client/perl.pp index 09a790b..f11d06f 100644 --- a/manifests/client/perl.pp +++ b/manifests/client/perl.pp @@ -1,7 +1,6 @@ +# mysql perl config class mysql::client::perl { - - case $operatingsystem { + case $::operatingsystem { debian: { include mysql::client::perl::debian } } - } diff --git a/manifests/client/perl/debian.pp b/manifests/client/perl/debian.pp index 790eaff..f4acfb4 100644 --- a/manifests/client/perl/debian.pp +++ b/manifests/client/perl/debian.pp @@ -1,5 +1,5 @@ +# perl package name on debian class mysql::client::perl::debian { - package { 'libdbd-mysql-perl': ensure => present, } diff --git a/manifests/client/ruby.pp b/manifests/client/ruby.pp index 726f63d..b14ecd8 100644 --- a/manifests/client/ruby.pp +++ b/manifests/client/ruby.pp @@ -1,7 +1,6 @@ +# mysql client for ruby class mysql::client::ruby { - - case $operatingsystem { + case $::operatingsystem { debian: { include mysql::client::ruby::debian } } - } diff --git a/manifests/client/ruby/debian.pp b/manifests/client/ruby/debian.pp index 3cfa846..554984b 100644 --- a/manifests/client/ruby/debian.pp +++ b/manifests/client/ruby/debian.pp @@ -1,7 +1,6 @@ +# debian ruby client class mysql::client::ruby::debian { - package { 'libmysql-ruby': ensure => present, } - } diff --git a/manifests/default_database.pp b/manifests/default_database.pp index 7465eaf..8f0ddca 100644 --- a/manifests/default_database.pp +++ b/manifests/default_database.pp @@ -11,39 +11,36 @@ define mysql::default_database( 'absent' => $name, default => $username } - mysql_database{"$name": - ensure => $ensure + mysql_database{$name: + ensure => $ensure, + require => Exec['mysql_set_rootpw'], } if $password == 'absent' and $ensure != 'absent' { info("we don't create the user for database: ${name}") - $grant_require = Mysql_database["$name"] + $grant_require = Mysql_database[$name] } else { mysql_user{"${real_username}@${host}": - ensure => $ensure, - require => [ - Mysql_database["$name"] - ], + ensure => $ensure, + require => Mysql_database[$name], } - $grant_require = [ - Mysql_database["$name"], - Mysql_user["${real_username}@${host}"] - ] + $grant_require = Mysql_user["${real_username}@${host}"] if $ensure == 'present' { - Mysql_user["${real_username}@${host}"]{ - password_hash => $password ? { - 'trocla' => trocla("mysql_${real_username}",'mysql'), - default => $password_is_encrypted ? { - true => "$password", - default => mysql_password("$password") + $password_hash = $password ? { + 'trocla' => trocla("mysql_${real_username}",'mysql'), + default => $password_is_encrypted ? { + true => $password, + default => mysql_password($password) }, - }, + } + Mysql_user["${real_username}@${host}"]{ + password_hash => $password_hash } } } if $ensure == 'present' { mysql_grant{"${real_username}@${host}/${name}": - privileges => "$privileges", - require => $grant_require, + privileges => $privileges, + require => $grant_require, } } } diff --git a/manifests/devel.pp b/manifests/devel.pp index 9c2d9bc..e32b331 100644 --- a/manifests/devel.pp +++ b/manifests/devel.pp @@ -1,5 +1,6 @@ +# devel resources for mysql class mysql::devel{ - package{"mysql-devel.${architecture}": - ensure => present, - } + package{"mysql-devel.${::architecture}": + ensure => present, + } } diff --git a/manifests/disable.pp b/manifests/disable.pp index 9207d23..55b5ba1 100644 --- a/manifests/disable.pp +++ b/manifests/disable.pp @@ -1,16 +1,14 @@ -# manifests/disable.pp - # class to install mysql-server # in a disabled way. class mysql::disable { - package{'mysql-server': - ensure => installed, - } + package{'mysql-server': + ensure => installed, + } - service {mysql: - ensure => stopped, - enable => false, - hasstatus => true, - require => Package['mysql-server'], - } + service {mysql: + ensure => stopped, + enable => false, + hasstatus => true, + require => Package['mysql-server'], + } } diff --git a/manifests/server.pp b/manifests/server.pp index 4245ef7..bc49100 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -1,30 +1,33 @@ +# manage a mysql server class mysql::server ( - $use_munin = hiera('use_munin',false), - $use_nagios = hiera('use_nagios',false), - $use_shorewall = hiera('use_shorewall',false) + $manage_shorewall = false, + $manage_munin = false, + $manage_nagios = false, + $backup_cron = false, + $optimize_cron = false, + $backup_dir = '/var/backups/mysql', + $manage_backup_dir = true, + $nagios_notcp = false ) { - case $::operatingsystem { - gentoo: { include mysql::server::gentoo } - centos: { include mysql::server::centos } - debian: { include mysql::server::debian } - default: { include mysql::server::base } - } + 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 { - case $::operatingsystem { - debian: { include mysql::server::munin::debian } - default: { include mysql::server::munin::default } - } - } + if $manage_munin and $::mysql_exists == 'true' { + case $::operatingsystem { + debian: { include mysql::server::munin::debian } + default: { include mysql::server::munin::default } + } + } - if $use_nagios { - case $nagios_check_mysql { - false: { info("We don't do nagioschecks for mysql on ${::fqdn}" ) } - default: { include mysql::server::nagios } - } - } + if $manage_nagios and $::mysql_exists == 'true' { + include mysql::server::nagios + } - if $use_shorewall { - include shorewall::rules::mysql - } + if $manage_shorewall { + include shorewall::rules::mysql + } } diff --git a/manifests/server/account_security.pp b/manifests/server/account_security.pp index 23d1cb7..a17f0b3 100644 --- a/manifests/server/account_security.pp +++ b/manifests/server/account_security.pp @@ -1,8 +1,8 @@ +# some installations have some default users which are not required. +# We remove them here. You can subclass this class to overwrite this behavior. class mysql::server::account_security { - # some installations have some default users which are not required. - # We remove them here. You can subclass this class to overwrite this behavior. - mysql_user{ [ "root@${fqdn}", "root@127.0.0.1", "@${fqdn}", "@localhost", "@%" ]: - ensure => 'absent', - require => Service['mysql'], - } + mysql_user{ [ "root@${::fqdn}", 'root@127.0.0.1', "@${::fqdn}", '@localhost', '@%' ]: + ensure => 'absent', + require => Exec['mysql_set_rootpw'], + } } diff --git a/manifests/server/base.pp b/manifests/server/base.pp index 82d4b6a..8bdd865 100644 --- a/manifests/server/base.pp +++ b/manifests/server/base.pp @@ -1,84 +1,90 @@ -class mysql::server::base( - $mysql_backup_cron = hiera('mysql_backup_cron', false), - $mysql_optimize_cron = hiera('mysql_optimize_cron', false) -) { - package { mysql-server: - ensure => present, - } - file { 'mysql_main_cnf': - path => '/etc/mysql/my.cnf', - source => [ - "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'], - notify => Service['mysql'], - owner => root, group => 0, mode => 0644; - } +# manage the common things of +# a mysql server +class mysql::server::base { + package {'mysql-server': + ensure => present, + } + file { 'mysql_main_cnf': + path => '/etc/mysql/my.cnf', + source => [ + "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' + ], + require => Package['mysql-server'], + notify => Service['mysql'], + owner => root, + group => 0, + mode => '0644'; + } - file { 'mysql_data_dir': - path => '/var/lib/mysql/data', - ensure => directory, - require => Package['mysql-server'], - before => File['mysql_main_cnf'], - owner => mysql, group => mysql, mode => 0755; - } + file { + 'mysql_data_dir': + ensure => directory, + path => '/var/lib/mysql/data', + require => Package['mysql-server'], + before => File['mysql_main_cnf'], + owner => mysql, + group => mysql, + mode => '0755'; + 'mysql_ibdata1': + path => '/var/lib/mysql/data/ibdata1', + require => Package['mysql-server'], + before => File['mysql_setmysqlpass.sh'], + owner => mysql, + group => mysql, + mode => '0660'; + 'mysql_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'; + 'mysql_root_cnf': + path => '/root/.my.cnf', + content => template('mysql/root/my.cnf.erb'), + require => [ Package['mysql-server'] ], + notify => Exec['mysql_set_rootpw'], + owner => root, + group => 0, + mode => '0400'; + } - file { 'mysql_ibdata1': - path => '/var/lib/mysql/data/ibdata1', - ensure => file, - require => Package['mysql-server'], - before => File['mysql_setmysqlpass.sh'], - owner => mysql, group => mysql, mode => 0660; - } + exec { 'mysql_set_rootpw': + command => '/usr/local/sbin/setmysqlpass.sh', + unless => 'mysqladmin -uroot status > /dev/null', + require => [ File['mysql_setmysqlpass.sh'], Service['mysql'] ], + # this is for security so that we only change the password + # if the password file itself has changed + refreshonly => true, + } - file { 'mysql_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; - } + if $mysql::server::backup_cron { + include mysql::server::cron::backup + } - file { 'mysql_root_cnf': - path => '/root/.my.cnf', - content => template('mysql/root/my.cnf.erb'), - require => [ Package['mysql-server'] ], - owner => root, group => 0, mode => 0400, - notify => Exec['mysql_set_rootpw'], - } + if $mysql::server::optimize_cron { + include mysql::server::cron::optimize + } - exec { 'mysql_set_rootpw': - command => '/usr/local/sbin/setmysqlpass.sh', - unless => '/usr/bin/mysqladmin -uroot status > /dev/null', - require => [ File['mysql_setmysqlpass.sh'], Package['mysql-server'] ], - refreshonly => true, - } + service { 'mysql': + ensure => running, + enable => true, + hasstatus => true, + require => Package['mysql-server'], + } - 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-server'], - } - - include mysql::server::account_security + if $::mysql_exists == 'true' { + include mysql::server::account_security # 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/centos.pp b/manifests/server/centos.pp index 445aeba..a55a57f 100644 --- a/manifests/server/centos.pp +++ b/manifests/server/centos.pp @@ -1,9 +1,9 @@ +# centos specific things class mysql::server::centos inherits mysql::server::clientpackage { - Service['mysql']{ - name => 'mysqld', - } - File['mysql_main_cnf']{ - path => '/etc/my.cnf', - } - + Service['mysql']{ + name => 'mysqld', + } + File['mysql_main_cnf']{ + path => '/etc/my.cnf', + } } diff --git a/manifests/server/clientpackage.pp b/manifests/server/clientpackage.pp index 8f317c1..2c89165 100644 --- a/manifests/server/clientpackage.pp +++ b/manifests/server/clientpackage.pp @@ -1,12 +1,15 @@ +# include client package class mysql::server::clientpackage inherits mysql::server::base { - include mysql::client - File['mysql_setmysqlpass.sh']{ - require +> Package['mysql-client'], - } - File['mysql_root_cnf']{ - require +> Package['mysql-client'], - } - Exec['mysql_set_rootpw']{ - require +> Package['mysql-client'], - } + class { 'mysql::client': + manage_shorewall => $mysql::server::manage_shorewall + } + File['mysql_setmysqlpass.sh']{ + require +> Package['mysql-client'], + } + File['mysql_root_cnf']{ + require +> Package['mysql-client'], + } + Exec['mysql_set_rootpw']{ + require +> Package['mysql-client'], + } } diff --git a/manifests/server/cron/backup.pp b/manifests/server/cron/backup.pp index b105f1b..671ad9c 100644 --- a/manifests/server/cron/backup.pp +++ b/manifests/server/cron/backup.pp @@ -1,24 +1,21 @@ -class mysql::server::cron::backup ( - $mysql_backup_dir = hiera('mysql_backup_dir','/var/backups/mysql'), - $mysql_manage_backup_dir = hiera('mysql_manage_backup_dir',true) -) { - case $mysql_manage_backup_dir { - false: { info("We don't manage the mysql_backup_dir") } - default: { - file { 'mysql_backup_dir': - path => $mysql_backup_dir, - ensure => directory, - before => Cron['mysql_backup_cron'], - owner => root, group => 0, mode => 0700; - } - } - } +# setup a basic cronjob to backup mysql database +class mysql::server::cron::backup { + if $mysql::server::manage_backup_dir { + file { 'mysql_backup_dir': + ensure => directory, + path => $mysql::server::backup_dir, + 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 > ${mysql_backup_dir}/mysqldump.sql.gz && chmod 600 ${mysql_backup_dir}/mysqldump.sql.gz", - user => 'root', - minute => 0, - hour => 1, - require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'] ], - } + cron { 'mysql_backup_cron': + 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, + hour => 1, + require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'] ], + } } diff --git a/manifests/server/cron/optimize.pp b/manifests/server/cron/optimize.pp index c238930..d1d0257 100644 --- a/manifests/server/cron/optimize.pp +++ b/manifests/server/cron/optimize.pp @@ -1,18 +1,22 @@ +# optimize mysql databases regurarely class mysql::server::cron::optimize { - 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; - } - - cron { 'mysql_optimize_cron': - command => '/usr/local/sbin/optimize_mysql_tables.rb', - user => 'root', - minute => 40, - hour => 6, - weekday => 7, - require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'], File['mysql_optimize_script'] ], - } + 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'; + } + cron { 'mysql_optimize_cron': + command => '/usr/local/sbin/optimize_mysql_tables.rb', + user => 'root', + minute => 40, + hour => 6, + weekday => 7, + require => [ Exec['mysql_set_rootpw'], + File['mysql_root_cnf'], + File['mysql_optimize_script'] ], + } } diff --git a/manifests/server/debian.pp b/manifests/server/debian.pp index 44f61ed..d950a34 100644 --- a/manifests/server/debian.pp +++ b/manifests/server/debian.pp @@ -1,14 +1,16 @@ +# debian specific stuff class mysql::server::debian inherits mysql::server::clientpackage { - File['mysql_data_dir'] { - path => '/var/lib/mysql', - } - File['mysql_ibdata1'] { - path => '/var/lib/mysql/ibdata1', - } - file { 'mysql_debian_cnf': - path => '/etc/mysql/debian.cnf', - ensure => file, - notify => Service['mysql'], - owner => root, group => 0, mode => 0600; - } + File['mysql_data_dir'] { + path => '/var/lib/mysql', + } + File['mysql_ibdata1'] { + path => '/var/lib/mysql/ibdata1', + } + file { 'mysql_debian_cnf': + path => '/etc/mysql/debian.cnf', + notify => Service['mysql'], + owner => root, + group => 0, + mode => '0600'; + } } diff --git a/manifests/server/gentoo.pp b/manifests/server/gentoo.pp index 0294b11..bff86ca 100644 --- a/manifests/server/gentoo.pp +++ b/manifests/server/gentoo.pp @@ -1,6 +1,7 @@ +# gentoo specific things class mysql::server::gentoo inherits mysql::server::base { - Package['mysql-server'] { - alias => 'mysql', - category => 'dev-db', - } + Package['mysql-server'] { + alias => 'mysql', + category => 'dev-db', + } } diff --git a/manifests/server/munin/base.pp b/manifests/server/munin/base.pp deleted file mode 100644 index ad4bb8a..0000000 --- a/manifests/server/munin/base.pp +++ /dev/null @@ -1,20 +0,0 @@ -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 d1636d5..9ff7863 100644 --- a/manifests/server/munin/debian.pp +++ b/manifests/server/munin/debian.pp @@ -1,14 +1,35 @@ -# manifests/server/munin/debian.pp - -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']; +# 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'], } } diff --git a/manifests/server/munin/default.pp b/manifests/server/munin/default.pp index ad43dc3..11609d2 100644 --- a/manifests/server/munin/default.pp +++ b/manifests/server/munin/default.pp @@ -1,36 +1,37 @@ -# manifests/server/munin/default.pp - +# manage plugins class mysql::server::munin::default { mysql_user{'munin@localhost': password_hash => trocla("mysql_munin_${::fqdn}",'mysql','length: 32'), - require => Package['mysql'], + require => Exec['mysql_set_rootpw'], } mysql_grant{'munin@localhost': - privileges => 'select_priv', - require => [ Mysql_user['munin@localhost'], Package['mysql'] ], + privileges => 'select_priv', + require => Mysql_user['munin@localhost'], } $munin_mysql_password = trocla("mysql_munin_${::fqdn}",'plain', 'length: 32') 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_queries, mysql_slowqueries]: + config => "env.mysqlopts --user=munin --password='${munin_mysql_password}' -h localhost", + require => Mysql_grant['munin@localhost']; + [mysql_bytes, mysql_threads]: + config => "env.mysqlopts --user=munin --password=${munin_mysql_password} -h localhost", + require => Mysql_grant['munin@localhost']; } Munin::Plugin::Deploy{ - config => "env.mysqlopts --user=munin --password=${munin_mysql_password} -h localhost", - require => - [ Mysql_grant['munin@localhost'], - Mysql_user['munin@localhost'], - Package['mysql'] ] + config => "env.mysqlopts --user=munin --password='${munin_mysql_password}' -h localhost", + require => Mysql_grant['munin@localhost'], } munin::plugin::deploy{ 'mysql_connections': source => 'mysql/munin/mysql_connections'; - 'mysql_qcache': + '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'; } } diff --git a/manifests/server/nagios.pp b/manifests/server/nagios.pp index 40bd0ee..944e0dd 100644 --- a/manifests/server/nagios.pp +++ b/manifests/server/nagios.pp @@ -1,30 +1,26 @@ -# manifests/server/nagios.pp +# setup nagios check for mysql +class mysql::server::nagios { + # 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 $mysql::server::nagios_notcp { + $nagios_mysql_user = 'nagios@localhost' + } else { + $nagios_mysql_user = 'nagios@%' + nagios::service::mysql { 'connection-time': + check_host => $::fqdn, + require => Mysql_grant[$nagios_mysql_user], + } + } -class mysql::server::nagios ( - $nagios_mysql_notcp = hiera('nagios_mysql_notcp',false) -) { - # 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 => trocla("mysql_nagios_${::fqdn}",'mysql','length: 32'), + require => Package['mysql'], + } - mysql_user{$nagios_mysql_user: - password_hash => trocla("mysql_nagios_${::fqdn}",'mysql','length: 32'), - 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'] ], - } + # 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'] ], + } } |