diff options
author | mh <mh@immerda.ch> | 2008-06-13 20:16:32 +0000 |
---|---|---|
committer | mh <mh@immerda.ch> | 2008-06-13 20:16:32 +0000 |
commit | 5c17a7fda8dcc10bee2417da0e0f3918172046b2 (patch) | |
tree | f93e5ab9af6ab008aaefee87239df4276009ad5f /manifests | |
parent | 7aeeced0339255f5cdc614dd631582d1064a4a8a (diff) |
merged with puzzle
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/init.pp | 110 | ||||
-rw-r--r-- | manifests/munin.pp | 22 | ||||
-rw-r--r-- | manifests/selinux.pp | 2 |
3 files changed, 117 insertions, 17 deletions
diff --git a/manifests/init.pp b/manifests/init.pp index d21176a..fee8219 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,57 +1,135 @@ -# mysql.pp +# +# mysql module +# # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at> -# See LICENSE for the full license granted to you. -# changed by immerda project group (admin(at)immerda.ch) +# Copyright 2008, admin(at)immerda.ch +# Copyright 2008, Puzzle ITC GmbH +# Marcel Härry haerry+puppet(at)puzzle.ch +# Simon Josi josi+puppet(at)puzzle.ch +# +# This program is free software; you can redistribute +# it and/or modify it under the terms of the GNU +# General Public License version 3 as published by +# the Free Software Foundation. +# + +# modules_dir { "mysql": } class mysql::server { case $operatingsystem { gentoo: { include mysql::server::gentoo } + centos: { include mysql::server::centos } default: { include mysql::server::base } } if $selinux { include mysql::selinux } + + if $use_munin { + include mysql::munin + } } class mysql::server::base { - package { mysql: + + package { mysql-server: ensure => present, } - file{ - "/etc/mysql/my.cnf": + file{'/etc/mysql/my.cnf': source => [ "puppet://$server/files/mysql/${fqdn}/my.cnf", "puppet://$server/files/mysql/my.cnf", - "puppet://$server/mysql/my.cnf" + "puppet://$server/mysql/config/${operatingsystem}/my.cnf", + "puppet://$server/mysql/config/my.cnf" ], ensure => file, - owner => root, - group => 0, - mode => 0444, - require => Package[mysql], + require => Package[mysql-server], notify => Service[mysql], + owner => root, group => 0, mode => 0644; + } + + case $mysql_rootpw { + '': { fail("You need to define a mysql root password! Please set \$mysql_rootpw in your site.pp or host config") } + } + + file{'/opt/bin/setmysqlpass.sh': + source => "puppet://$server/mysql/config/${operatingsystem}/setmysqlpass.sh", + require => Package[mysql-server], + owner => root, group => 0, mode => 0500; + } + + file {'/root/.my.cnf': + content => template('mysql/root/my.cnf.erb'), + require => [ Package[mysql-server] ], + owner => root, group => 0, mode => 0400; + } + + exec{'set_mysql_rootpw': + command => "/opt/bin/setmysqlpass.sh $mysql_rootpw", + unless => "mysqladmin -uroot status > /dev/null", + require => [ File['/opt/bin/setmysqlpass.sh'], Package[mysql-server] ], } - service { mysql: + file{'/etc/cron.d/mysql_backup.cron': + source => [ "puppet://$server/mysql/backup/${operatingsystem}/mysql_backup.cron", + "puppet://$server/mysql/backup/mysql_backup.cron" ], + require => [ Exec[set_mysql_rootpw], File['/root/.my.cnf'] ], + owner => root, group => 0, mode => 0600; + } + + service {mysql: ensure => running, + enable => true, hasstatus => true, require => Package[mysql], } munin::plugin { [mysql_bytes, mysql_queries, mysql_slowqueries, mysql_threads]: + require => [ Package[mysql-server], Exec['set_mysql_rootpw'] ], } # Collect all databases and users - Mysql_database<<||>> - Mysql_user<<||>> - Mysql_grant<<||>> + Mysql_database<<| tag == "mysql_${fqdn}" |>> + Mysql_user<<| tag == "mysql_${fqdn}" |>> + Mysql_grant<<| tag == "mysql_${fqdn}" |>> } class mysql::server::gentoo inherits mysql::server::base { - Package[mysql] { + Package[mysql-server] { + alias => 'mysql', category => 'dev-db', } } + +class mysql::server::clientpackage inherits mysql::server::base { + package{mysql: + ensure => present, + } + + File['/opt/bin/setmysqlpass.sh']{ + require +> Package[mysql], + } + + File['/root/.my.cnf']{ + require +> Package[mysql], + } + + Exec['set_mysql_rootpw']{ + require +> Package[mysql], + } + File['/etc/cron.d/mysql_backup.cron']{ + require +> Package[mysql], + } +} + +class mysql::server::centos inherits mysql::server::clientpackage { + Service[mysql]{ + name => 'mysqld', + } + File['/etc/mysql/my.cnf']{ + path => '/etc/my.cnf', + } +} diff --git a/manifests/munin.pp b/manifests/munin.pp new file mode 100644 index 0000000..a7a862e --- /dev/null +++ b/manifests/munin.pp @@ -0,0 +1,22 @@ +# manifests/munin.pp + +class mysql::munin { + case $munin_mysql_password { + '': { fail("please specify \$munin_mysql_password to enable mysql munin plugin")} + } + + mysql_user{'munin@localhost': + password_hash => mysql_password("$munin_mysql_password"), + } + + mysql_grant{'munin@localhost': + privileges => 'select_priv', + require => Mysql_user['munin@localhost'], + } + + 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'] ] + } +} diff --git a/manifests/selinux.pp b/manifests/selinux.pp index 14115c7..1ec2e03 100644 --- a/manifests/selinux.pp +++ b/manifests/selinux.pp @@ -12,5 +12,5 @@ class mysql::selinux::gentoo { category => 'sec-policy', require => Package[mysql], } - selinux::loadmodule {"mysql": } + selinux::loadmodule {'mysql': } } |