make trocla an optional dependency
This commit is contained in:
parent
2e57128b06
commit
c1c3b11245
5 changed files with 34 additions and 23 deletions
20
README
20
README
|
@ -32,11 +32,13 @@ On a node where you wish to have a mysql server installed, you should include
|
||||||
mysql::server, for example:
|
mysql::server, for example:
|
||||||
|
|
||||||
node foo {
|
node foo {
|
||||||
include mysql::server
|
class{'mysql::server':
|
||||||
|
root_password => 'foo',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
This will manage the necessary directories and configuration files, it will
|
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
|
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
|
make sure the mysql service is running, and setup all the databases, users and
|
||||||
grant tables.
|
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
|
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,
|
munin graphs to be setup and queried. The munin graphs are: mysql_bytes,
|
||||||
mysql_queries, mysql_slowqueries and mysql_threads. NOTE: The
|
mysql_queries, mysql_slowqueries and mysql_threads. NOTE: The
|
||||||
munin_mysql_password will be taken from trocla, but it is not necessary on
|
munin_mysql_password will be taken from what you passed to the mysql::server
|
||||||
Debian systems as it will handled with Debian's /etc/mysql/debian.cnf.
|
class, but it is not necessary on Debian systems as it will handled with
|
||||||
|
Debian's /etc/mysql/debian.cnf.
|
||||||
|
|
||||||
Nagios
|
Nagios
|
||||||
------
|
------
|
||||||
|
|
||||||
If you wish nagios to check mysql, you should set the variable "use_nagios" to
|
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
|
"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
|
password for the nagios mysql user will be created for you with reduced privileges
|
||||||
for you with reduced privileges used only for nagios checks. These should be
|
used only for nagios checks. This will be what you passed as nagios_password_hash
|
||||||
set before you include mysql::server.
|
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
|
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
|
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.
|
package.
|
||||||
|
|
||||||
You can also 'include mysql::client::ruby' if you want the 'libmysql-ruby'
|
You can also 'include mysql::client::ruby' if you want the 'libmysql-ruby'
|
||||||
libraries installed.
|
libraries installed.
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
# manage a mysql server
|
# manage a mysql server
|
||||||
class mysql::server (
|
class mysql::server (
|
||||||
$manage_shorewall = false,
|
$root_password,
|
||||||
$manage_munin = false,
|
$manage_shorewall = false,
|
||||||
$manage_nagios = false,
|
$manage_munin = false,
|
||||||
$backup_cron = false,
|
$munin_password = 'absent',
|
||||||
$optimize_cron = false,
|
$manage_nagios = false,
|
||||||
$backup_dir = '/var/backups/mysql',
|
$nagios_password_hash = 'absent',
|
||||||
$manage_backup_dir = true,
|
$backup_cron = false,
|
||||||
$nagios_notcp = false
|
$optimize_cron = false,
|
||||||
|
$backup_dir = '/var/backups/mysql',
|
||||||
|
$manage_backup_dir = true,
|
||||||
|
$nagios_notcp = false
|
||||||
) {
|
) {
|
||||||
case $::operatingsystem {
|
case $::operatingsystem {
|
||||||
gentoo: { include mysql::server::gentoo }
|
gentoo: { include mysql::server::gentoo }
|
||||||
|
@ -17,6 +20,9 @@ class mysql::server (
|
||||||
}
|
}
|
||||||
|
|
||||||
if $manage_munin and $::mysql_exists == 'true' {
|
if $manage_munin and $::mysql_exists == 'true' {
|
||||||
|
if $munin_password == 'absent' {
|
||||||
|
fail("need to set the munin password")
|
||||||
|
}
|
||||||
case $::operatingsystem {
|
case $::operatingsystem {
|
||||||
debian: { include mysql::server::munin::debian }
|
debian: { include mysql::server::munin::debian }
|
||||||
default: { include mysql::server::munin::default }
|
default: { include mysql::server::munin::default }
|
||||||
|
@ -24,6 +30,8 @@ class mysql::server (
|
||||||
}
|
}
|
||||||
|
|
||||||
if $manage_nagios and $::mysql_exists == 'true' {
|
if $manage_nagios and $::mysql_exists == 'true' {
|
||||||
|
if $nagios_password_hash == 'absent' {
|
||||||
|
fail("need to set the nagios password hash")
|
||||||
include mysql::server::nagios
|
include mysql::server::nagios
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# manage plugins
|
# manage plugins
|
||||||
class mysql::server::munin::default {
|
class mysql::server::munin::default {
|
||||||
mysql_user{'munin@localhost':
|
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'],
|
require => Exec['mysql_set_rootpw'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,18 +10,17 @@ class mysql::server::munin::default {
|
||||||
require => Mysql_user['munin@localhost'],
|
require => Mysql_user['munin@localhost'],
|
||||||
}
|
}
|
||||||
|
|
||||||
$munin_mysql_password = trocla("mysql_munin_${::fqdn}",'plain', 'length: 32')
|
|
||||||
munin::plugin {
|
munin::plugin {
|
||||||
[mysql_queries, mysql_slowqueries]:
|
[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'];
|
require => Mysql_grant['munin@localhost'];
|
||||||
[mysql_bytes, mysql_threads]:
|
[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'];
|
require => Mysql_grant['munin@localhost'];
|
||||||
}
|
}
|
||||||
|
|
||||||
Munin::Plugin::Deploy{
|
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'],
|
require => Mysql_grant['munin@localhost'],
|
||||||
}
|
}
|
||||||
munin::plugin::deploy{
|
munin::plugin::deploy{
|
||||||
|
|
|
@ -13,7 +13,7 @@ class mysql::server::nagios {
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_user{$nagios_mysql_user:
|
mysql_user{$nagios_mysql_user:
|
||||||
password_hash => trocla("mysql_nagios_${::fqdn}",'mysql','length: 32'),
|
password_hash => $mysql::server::nagios_password_hash,
|
||||||
require => Package['mysql'],
|
require => Package['mysql'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[client]
|
[client]
|
||||||
user=root
|
user=root
|
||||||
host=localhost
|
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') %>
|
||||||
|
|
Loading…
Reference in a new issue