make trocla an optional dependency

This commit is contained in:
mh 2013-01-02 18:48:49 +01:00
parent 2e57128b06
commit c1c3b11245
5 changed files with 34 additions and 23 deletions

20
README
View file

@ -32,11 +32,13 @@ On a node where you wish to have a mysql server installed, you should include
mysql::server, for example:
node foo {
include mysql::server
class{'mysql::server':
root_password => 'foo',
}
}
This will manage the necessary directories and configuration files, it will
install the mysql client program and set the root password taken from trocla,
install the mysql client program and set the root password to 'foo',
along with setting a /root/.my.cnf for various module operations. It will also
make sure the mysql service is running, and setup all the databases, users and
grant tables.
@ -67,17 +69,19 @@ hiera, before you include mysql::server. This will be used to
setup a mysql user for munin, with reduced privileges to allow for the various
munin graphs to be setup and queried. The munin graphs are: mysql_bytes,
mysql_queries, mysql_slowqueries and mysql_threads. NOTE: The
munin_mysql_password will be taken from trocla, but it is not necessary on
Debian systems as it will handled with Debian's /etc/mysql/debian.cnf.
munin_mysql_password will be taken from what you passed to the mysql::server
class, but it is not necessary on Debian systems as it will handled with
Debian's /etc/mysql/debian.cnf.
Nagios
------
If you wish nagios to check mysql, you should set the variable "use_nagios" to
"true" in hiera along with the "nagios_check_mysql" variable to "true". A
password for the nagios mysql user which will be automatically created via trocla
for you with reduced privileges used only for nagios checks. These should be
set before you include mysql::server.
password for the nagios mysql user will be created for you with reduced privileges
used only for nagios checks. This will be what you passed as nagios_password_hash
to mysql::server and should be a mysql md5 hash. These should be set before you
include mysql::server.
Unless you specify otherwise, the default nagios check which will be performed
is the basic 'check_mysql' nagios plugin which simply tests connectivity to a
@ -106,4 +110,4 @@ mysql::client' in the node definition. This will install the appropriate
package.
You can also 'include mysql::client::ruby' if you want the 'libmysql-ruby'
libraries installed.
libraries installed.

View file

@ -1,13 +1,16 @@
# manage a mysql server
class mysql::server (
$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
$root_password,
$manage_shorewall = false,
$manage_munin = false,
$munin_password = 'absent',
$manage_nagios = false,
$nagios_password_hash = 'absent',
$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 }
@ -17,6 +20,9 @@ class mysql::server (
}
if $manage_munin and $::mysql_exists == 'true' {
if $munin_password == 'absent' {
fail("need to set the munin password")
}
case $::operatingsystem {
debian: { include mysql::server::munin::debian }
default: { include mysql::server::munin::default }
@ -24,6 +30,8 @@ class mysql::server (
}
if $manage_nagios and $::mysql_exists == 'true' {
if $nagios_password_hash == 'absent' {
fail("need to set the nagios password hash")
include mysql::server::nagios
}

View file

@ -1,7 +1,7 @@
# manage plugins
class mysql::server::munin::default {
mysql_user{'munin@localhost':
password_hash => trocla("mysql_munin_${::fqdn}",'mysql','length: 32'),
password_hash => mysql_password($mysql::server::munin_password),
require => Exec['mysql_set_rootpw'],
}
@ -10,18 +10,17 @@ class mysql::server::munin::default {
require => Mysql_user['munin@localhost'],
}
$munin_mysql_password = trocla("mysql_munin_${::fqdn}",'plain', 'length: 32')
munin::plugin {
[mysql_queries, mysql_slowqueries]:
config => "env.mysqlopts --user=munin --password='${munin_mysql_password}' -h localhost",
config => "env.mysqlopts --user=munin --password='${mysql::server::munin_password}' -h localhost",
require => Mysql_grant['munin@localhost'];
[mysql_bytes, mysql_threads]:
config => "env.mysqlopts --user=munin --password=${munin_mysql_password} -h localhost",
config => "env.mysqlopts --user=munin --password=${mysql::server::munin_password} -h localhost",
require => Mysql_grant['munin@localhost'];
}
Munin::Plugin::Deploy{
config => "env.mysqlopts --user=munin --password='${munin_mysql_password}' -h localhost",
config => "env.mysqlopts --user=munin --password='${mysql::server::munin_password}' -h localhost",
require => Mysql_grant['munin@localhost'],
}
munin::plugin::deploy{

View file

@ -13,7 +13,7 @@ class mysql::server::nagios {
}
mysql_user{$nagios_mysql_user:
password_hash => trocla("mysql_nagios_${::fqdn}",'mysql','length: 32'),
password_hash => $mysql::server::nagios_password_hash,
require => Package['mysql'],
}

View file

@ -1,4 +1,4 @@
[client]
user=root
host=localhost
password=<%= Puppet::Parser::Functions.function('trocla');'' %><%= scope.function_trocla("mysql_root_#{scope.lookupvar('::fqdn')}",'plain', 'length' => 32) %>
password=<%= scope.lookupvar('mysql::server::root_password') %>