refactor things for >2.7

This commit is contained in:
mh 2012-06-08 13:04:06 -03:00
parent 7f4ae6753f
commit e4ca510b7c
7 changed files with 113 additions and 113 deletions

View file

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

View file

@ -11,21 +11,21 @@ define mysql::default_database(
'absent' => $name, 'absent' => $name,
default => $username default => $username
} }
mysql_database{"$name": mysql_database{$name:
ensure => $ensure ensure => $ensure
} }
if $password == 'absent' and $ensure != 'absent' { if $password == 'absent' and $ensure != 'absent' {
info("we don't create the user for database: ${name}") info("we don't create the user for database: ${name}")
$grant_require = Mysql_database["$name"] $grant_require = Mysql_database[$name]
} else { } else {
mysql_user{"${real_username}@${host}": mysql_user{"${real_username}@${host}":
ensure => $ensure, ensure => $ensure,
require => [ require => [
Mysql_database["$name"] Mysql_database[$name]
], ],
} }
$grant_require = [ $grant_require = [
Mysql_database["$name"], Mysql_database[$name],
Mysql_user["${real_username}@${host}"] Mysql_user["${real_username}@${host}"]
] ]
if $ensure == 'present' { if $ensure == 'present' {
@ -33,7 +33,7 @@ define mysql::default_database(
password_hash => $password ? { password_hash => $password ? {
'trocla' => trocla("mysql_${real_username}",'mysql'), 'trocla' => trocla("mysql_${real_username}",'mysql'),
default => $password_is_encrypted ? { default => $password_is_encrypted ? {
true => "$password", true => $password,
default => mysql_password("$password") default => mysql_password("$password")
}, },
}, },
@ -42,7 +42,7 @@ define mysql::default_database(
} }
if $ensure == 'present' { if $ensure == 'present' {
mysql_grant{"${real_username}@${host}/${name}": mysql_grant{"${real_username}@${host}/${name}":
privileges => "$privileges", privileges => $privileges,
require => $grant_require, require => $grant_require,
} }
} }

View file

@ -1,5 +1,5 @@
class mysql::devel{ class mysql::devel{
package{"mysql-devel.${architecture}": package{"mysql-devel.${::architecture}":
ensure => present, ensure => present,
} }
} }

View file

@ -3,14 +3,14 @@
# class to install mysql-server # class to install mysql-server
# in a disabled way. # in a disabled way.
class mysql::disable { class mysql::disable {
package{'mysql-server': package{'mysql-server':
ensure => installed, ensure => installed,
} }
service {mysql: service {mysql:
ensure => stopped, ensure => stopped,
enable => false, enable => false,
hasstatus => true, hasstatus => true,
require => Package['mysql-server'], require => Package['mysql-server'],
} }
} }

View file

@ -1,27 +1,27 @@
class mysql::server { class mysql::server {
case $::operatingsystem {
gentoo: { include mysql::server::gentoo }
centos: { include mysql::server::centos }
debian: { include mysql::server::debian }
default: { include mysql::server::base }
}
if hiera('use_munin',false) {
case $::operatingsystem { case $::operatingsystem {
gentoo: { include mysql::server::gentoo } debian: { include mysql::server::munin::debian }
centos: { include mysql::server::centos } default: { include mysql::server::munin::default }
debian: { include mysql::server::debian }
default: { include mysql::server::base }
} }
}
if hiera('use_munin',false) { if hiera('use_nagios',false) {
case $::operatingsystem { case hiera('nagios_check_mysql',false) {
debian: { include mysql::server::munin::debian } false: { info("We don't do nagioschecks for mysql on ${::fqdn}" ) }
default: { include mysql::server::munin::default } default: { include mysql::server::nagios }
}
} }
}
if hiera('use_nagios',false) { if hiera('use_shorewall',false) {
case hiera('nagios_check_mysql',false) { include shorewall::rules::mysql
false: { info("We don't do nagioschecks for mysql on ${::fqdn}" ) } }
default: { include mysql::server::nagios }
}
}
if hiera('use_shorewall',false) {
include shorewall::rules::mysql
}
} }

View file

@ -1,8 +1,8 @@
class mysql::server::account_security { class mysql::server::account_security {
# some installations have some default users which are not required. # some installations have some default users which are not required.
# We remove them here. You can subclass this class to overwrite this behavior. # We remove them here. You can subclass this class to overwrite this behavior.
mysql_user{ [ "root@${fqdn}", "root@127.0.0.1", "@${fqdn}", "@localhost", "@%" ]: mysql_user{ [ "root@${::fqdn}", "root@127.0.0.1", "@${::fqdn}", "@localhost", "@%" ]:
ensure => 'absent', ensure => 'absent',
require => Service['mysql'], require => Service['mysql'],
} }
} }

View file

@ -1,81 +1,81 @@
class mysql::server::base { class mysql::server::base {
package { mysql-server: package { mysql-server:
ensure => present, ensure => present,
} }
file { 'mysql_main_cnf': file { 'mysql_main_cnf':
path => '/etc/mysql/my.cnf', path => '/etc/mysql/my.cnf',
source => [ source => [
"puppet:///modules/site-mysql/${::fqdn}/my.cnf", "puppet:///modules/site_mysql/${::fqdn}/my.cnf",
"puppet:///modules/site-mysql/my.cnf.${::operatingsystem}.{lsbdistcodename}", "puppet:///modules/site_mysql/my.cnf.${::operatingsystem}.{lsbdistcodename}",
"puppet:///modules/site-mysql/my.cnf.${::operatingsystem}", "puppet:///modules/site_mysql/my.cnf.${::operatingsystem}",
"puppet:///modules/site-mysql/my.cnf", "puppet:///modules/site_mysql/my.cnf",
"puppet:///modules/mysql/config/my.cnf.${::operatingsystem}.{lsbdistcodename}", "puppet:///modules/mysql/config/my.cnf.${::operatingsystem}.{lsbdistcodename}",
"puppet:///modules/mysql/config/my.cnf.${::operatingsystem}", "puppet:///modules/mysql/config/my.cnf.${::operatingsystem}",
"puppet:///modules/mysql/config/my.cnf" "puppet:///modules/mysql/config/my.cnf"
], ],
ensure => file, ensure => file,
require => Package['mysql-server'], require => Package['mysql-server'],
notify => Service['mysql'], notify => Service['mysql'],
owner => root, group => 0, mode => 0644; owner => root, group => 0, mode => 0644;
} }
file { 'mysql_data_dir': file { 'mysql_data_dir':
path => '/var/lib/mysql/data', path => '/var/lib/mysql/data',
ensure => directory, ensure => directory,
require => Package['mysql-server'], require => Package['mysql-server'],
before => File['mysql_main_cnf'], before => File['mysql_main_cnf'],
owner => mysql, group => mysql, mode => 0755; owner => mysql, group => mysql, mode => 0755;
} }
file { 'mysql_ibdata1': file { 'mysql_ibdata1':
path => '/var/lib/mysql/data/ibdata1', path => '/var/lib/mysql/data/ibdata1',
ensure => file, ensure => file,
require => Package['mysql-server'], require => Package['mysql-server'],
before => File['mysql_setmysqlpass.sh'], before => File['mysql_setmysqlpass.sh'],
owner => mysql, group => mysql, mode => 0660; owner => mysql, group => mysql, mode => 0660;
} }
file { 'mysql_setmysqlpass.sh': file { 'mysql_setmysqlpass.sh':
path => '/usr/local/sbin/setmysqlpass.sh', path => '/usr/local/sbin/setmysqlpass.sh',
source => "puppet:///modules/mysql/scripts/${::operatingsystem}/setmysqlpass.sh", source => "puppet:///modules/mysql/scripts/${::operatingsystem}/setmysqlpass.sh",
require => Package['mysql-server'], require => Package['mysql-server'],
owner => root, group => 0, mode => 0500; owner => root, group => 0, mode => 0500;
} }
file { 'mysql_root_cnf': file { 'mysql_root_cnf':
path => '/root/.my.cnf', path => '/root/.my.cnf',
content => template('mysql/root/my.cnf.erb'), content => template('mysql/root/my.cnf.erb'),
require => [ Package['mysql-server'] ], require => [ Package['mysql-server'] ],
owner => root, group => 0, mode => 0400, owner => root, group => 0, mode => 0400,
notify => Exec['mysql_set_rootpw'], notify => Exec['mysql_set_rootpw'],
} }
exec { 'mysql_set_rootpw': exec { 'mysql_set_rootpw':
command => '/usr/local/sbin/setmysqlpass.sh', command => '/usr/local/sbin/setmysqlpass.sh',
unless => "mysqladmin -uroot status > /dev/null", unless => "mysqladmin -uroot status > /dev/null",
require => [ File['mysql_setmysqlpass.sh'], Package['mysql-server'] ], require => [ File['mysql_setmysqlpass.sh'], Package['mysql-server'] ],
refreshonly => true, refreshonly => true,
} }
if hiera('mysql_backup_cron',false) { if hiera('mysql_backup_cron',false) {
include mysql::server::cron::backup include mysql::server::cron::backup
} }
if hiera('mysql_optimize_cron',false) { if hiera('mysql_optimize_cron',false) {
include mysql::server::cron::optimize include mysql::server::cron::optimize
} }
service { 'mysql': service { 'mysql':
ensure => running, ensure => running,
enable => true, enable => true,
hasstatus => true, hasstatus => true,
require => Package['mysql-server'], require => Package['mysql-server'],
} }
include mysql::server::account_security include mysql::server::account_security
# Collect all databases and users # Collect all databases and users
Mysql_database<<| tag == "mysql_${::fqdn}" |>> Mysql_database<<| tag == "mysql_${::fqdn}" |>>
Mysql_user<<| tag == "mysql_${::fqdn}" |>> Mysql_user<<| tag == "mysql_${::fqdn}" |>>
Mysql_grant<<| tag == "mysql_${::fqdn}" |>> Mysql_grant<<| tag == "mysql_${::fqdn}" |>>
} }