This commit is contained in:
mh 2013-01-02 17:13:45 +01:00
parent dd6c24844b
commit 33241a38d2
14 changed files with 85 additions and 77 deletions

View file

@ -1,3 +1,4 @@
# client package for mysql
class mysql::client (
$manage_shorewall = false
) {

View file

@ -1,8 +1,7 @@
# basic mysql client stuff
class mysql::client::base {
package { 'mysql':
ensure => present,
alias => 'mysql-client',
ensure => present,
alias => 'mysql-client',
}
}

View file

@ -1,7 +1,6 @@
# debian client name
class mysql::client::debian inherits mysql::client::base {
Package['mysql'] {
name => 'mysql-client',
}
}

View file

@ -1,7 +1,6 @@
# mysql client for ruby
class mysql::client::ruby {
case $::operatingsystem {
debian: { include mysql::client::ruby::debian }
}
}

View file

@ -1,7 +1,6 @@
# debian ruby client
class mysql::client::ruby::debian {
package { 'libmysql-ruby':
ensure => present,
}
}

View file

@ -1,3 +1,4 @@
# devel resources for mysql
class mysql::devel{
package{"mysql-devel.${::architecture}":
ensure => present,

View file

@ -1,5 +1,3 @@
# manifests/disable.pp
# class to install mysql-server
# in a disabled way.
class mysql::disable {
@ -8,9 +6,9 @@ class mysql::disable {
}
service {mysql:
ensure => stopped,
enable => false,
ensure => stopped,
enable => false,
hasstatus => true,
require => Package['mysql-server'],
require => Package['mysql-server'],
}
}

View file

@ -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',
}
}

View file

@ -1,14 +1,15 @@
# include client package
class mysql::server::clientpackage inherits mysql::server::base {
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'],
}
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'],
}
}

View file

@ -1,18 +1,21 @@
# setup a basic cronjob to backup mysql database
class mysql::server::cron::backup {
if $mysql::server::manage_backup_dir {
file { 'mysql_backup_dir':
path => $mysql::server::backup_dir,
ensure => directory,
before => Cron['mysql_backup_cron'],
owner => root, group => 0, mode => 0700;
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 --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,
user => 'root',
minute => 0,
hour => 1,
require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'] ],
}
}
}

View file

@ -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'] ],
}
}

View file

@ -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';
}
}

View file

@ -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',
}
}

View file

@ -1,3 +1,4 @@
# 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
@ -6,20 +7,20 @@ class mysql::server::nagios {
} else {
$nagios_mysql_user = 'nagios@%'
nagios::service::mysql { 'connection-time':
check_host => $::fqdn,
require => Mysql_grant[$nagios_mysql_user],
check_host => $::fqdn,
require => Mysql_grant[$nagios_mysql_user],
}
}
mysql_user{$nagios_mysql_user:
password_hash => trocla("mysql_nagios_${::fqdn}",'mysql','length: 32'),
require => Package['mysql'],
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'] ],
privileges => [ 'select_priv', 'repl_client_priv' ],
require => [ Mysql_user[$nagios_mysql_user], Package['mysql'] ],
}
}