diff options
author | mh <mh@immerda.ch> | 2013-01-02 18:48:49 +0100 |
---|---|---|
committer | mh <mh@immerda.ch> | 2013-01-02 18:48:49 +0100 |
commit | c1c3b112459f995afdaae9cc9aa415ea68788596 (patch) | |
tree | f70bea4dc3bb258e5c84d1942dca43515be2fdee | |
parent | 2e57128b061d65e3c54297b4cd7d3759625a3dce (diff) |
make trocla an optional dependency
-rw-r--r-- | README | 20 | ||||
-rw-r--r-- | manifests/server.pp | 24 | ||||
-rw-r--r-- | manifests/server/munin/default.pp | 9 | ||||
-rw-r--r-- | manifests/server/nagios.pp | 2 | ||||
-rw-r--r-- | templates/root/my.cnf.erb | 2 |
5 files changed, 34 insertions, 23 deletions
@@ -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.
\ No newline at end of file +libraries installed. diff --git a/manifests/server.pp b/manifests/server.pp index bc49100..f802935 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -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 } diff --git a/manifests/server/munin/default.pp b/manifests/server/munin/default.pp index 11609d2..91cd5fe 100644 --- a/manifests/server/munin/default.pp +++ b/manifests/server/munin/default.pp @@ -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{ diff --git a/manifests/server/nagios.pp b/manifests/server/nagios.pp index 944e0dd..34bb086 100644 --- a/manifests/server/nagios.pp +++ b/manifests/server/nagios.pp @@ -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'], } diff --git a/templates/root/my.cnf.erb b/templates/root/my.cnf.erb index 26ced1e..86782aa 100644 --- a/templates/root/my.cnf.erb +++ b/templates/root/my.cnf.erb @@ -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') %> |