2009-10-03 15:19:11 +02:00
|
|
|
class mysql::server::base {
|
|
|
|
package { mysql-server:
|
|
|
|
ensure => present,
|
|
|
|
}
|
2009-12-10 18:22:25 +01:00
|
|
|
file { 'mysql_main_cnf':
|
|
|
|
path => '/etc/mysql/my.cnf',
|
2009-10-03 15:19:11 +02:00
|
|
|
source => [
|
2010-09-22 19:12:51 +02:00
|
|
|
"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"
|
2009-10-03 15:19:11 +02:00
|
|
|
],
|
|
|
|
ensure => file,
|
2009-12-10 19:10:06 +01:00
|
|
|
require => Package['mysql-server'],
|
|
|
|
notify => Service['mysql'],
|
2009-10-03 15:19:11 +02:00
|
|
|
owner => root, group => 0, mode => 0644;
|
|
|
|
}
|
2009-12-10 19:10:06 +01:00
|
|
|
|
2009-12-10 18:22:25 +01:00
|
|
|
file { 'mysql_data_dir':
|
|
|
|
path => '/var/lib/mysql/data',
|
2009-10-03 15:19:11 +02:00
|
|
|
ensure => directory,
|
2009-12-10 19:10:06 +01:00
|
|
|
require => Package['mysql-server'],
|
2009-12-10 18:22:25 +01:00
|
|
|
before => File['mysql_main_cnf'],
|
2009-10-03 15:19:11 +02:00
|
|
|
owner => mysql, group => mysql, mode => 0755;
|
|
|
|
}
|
|
|
|
|
2009-12-10 18:22:25 +01:00
|
|
|
file { 'mysql_ibdata1':
|
|
|
|
path => '/var/lib/mysql/data/ibdata1',
|
2009-10-03 15:19:11 +02:00
|
|
|
ensure => file,
|
2009-12-10 19:10:06 +01:00
|
|
|
require => Package['mysql-server'],
|
2009-12-10 18:22:25 +01:00
|
|
|
before => File['mysql_setmysqlpass.sh'],
|
2009-10-03 15:19:11 +02:00
|
|
|
owner => mysql, group => mysql, mode => 0660;
|
|
|
|
}
|
|
|
|
|
|
|
|
case $mysql_rootpw {
|
|
|
|
'': { fail("You need to define a mysql root password! Please set \$mysql_rootpw in your site.pp or host config") }
|
|
|
|
}
|
2009-12-10 19:10:06 +01:00
|
|
|
|
2009-12-10 18:22:25 +01:00
|
|
|
file { 'mysql_setmysqlpass.sh':
|
2010-04-02 17:48:13 +02:00
|
|
|
path => '/usr/local/sbin/setmysqlpass.sh',
|
2010-08-11 15:57:43 +02:00
|
|
|
source => "puppet:///modules/mysql/scripts/${operatingsystem}/setmysqlpass.sh",
|
2009-12-10 19:10:06 +01:00
|
|
|
require => Package['mysql-server'],
|
2009-10-03 15:19:11 +02:00
|
|
|
owner => root, group => 0, mode => 0500;
|
2009-12-10 19:10:06 +01:00
|
|
|
}
|
|
|
|
|
2009-12-10 18:22:25 +01:00
|
|
|
file { 'mysql_root_cnf':
|
|
|
|
path => '/root/.my.cnf',
|
2009-10-03 15:19:11 +02:00
|
|
|
content => template('mysql/root/my.cnf.erb'),
|
2009-12-10 19:10:06 +01:00
|
|
|
require => [ Package['mysql-server'] ],
|
2009-12-10 18:36:34 +01:00
|
|
|
owner => root, group => 0, mode => 0400,
|
|
|
|
notify => Exec['mysql_set_rootpw'],
|
2009-10-03 15:19:11 +02:00
|
|
|
}
|
2009-12-10 19:10:06 +01:00
|
|
|
|
2009-12-10 18:22:25 +01:00
|
|
|
exec { 'mysql_set_rootpw':
|
2010-09-23 01:31:06 +02:00
|
|
|
command => "/usr/local/sbin/setmysqlpass.sh ${mysql_rootpw}",
|
2009-10-03 15:19:11 +02:00
|
|
|
unless => "mysqladmin -uroot status > /dev/null",
|
2009-12-10 19:10:06 +01:00
|
|
|
require => [ File['mysql_setmysqlpass.sh'], Package['mysql-server'] ],
|
2009-12-10 18:36:34 +01:00
|
|
|
refreshonly => true,
|
2009-10-03 15:19:11 +02:00
|
|
|
}
|
2009-12-10 19:10:06 +01:00
|
|
|
|
2009-12-10 20:52:50 +01:00
|
|
|
if ($mysql_backup_cron) {
|
|
|
|
include mysql::server::cron::backup
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($mysql_optimize_cron) {
|
|
|
|
include mysql::server::cron::optimize
|
|
|
|
}
|
2009-12-10 19:10:06 +01:00
|
|
|
|
2009-12-10 20:52:50 +01:00
|
|
|
service { 'mysql':
|
|
|
|
ensure => running,
|
|
|
|
enable => true,
|
|
|
|
hasstatus => true,
|
2010-09-22 18:37:46 +02:00
|
|
|
require => Package['mysql-server'],
|
2009-10-03 15:19:11 +02:00
|
|
|
}
|
|
|
|
|
2009-12-10 20:52:50 +01:00
|
|
|
# Collect all databases and users
|
|
|
|
Mysql_database<<| tag == "mysql_${fqdn}" |>>
|
|
|
|
Mysql_user<<| tag == "mysql_${fqdn}" |>>
|
|
|
|
Mysql_grant<<| tag == "mysql_${fqdn}" |>>
|
2009-10-03 15:19:11 +02:00
|
|
|
}
|