From de7cb43faa01ea83dce6e2ad433694b0d000832c Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 9 Dec 2012 15:52:34 +0100 Subject: fix dependency issues --- manifests/admin_user.pp | 22 +++++++++++++--------- manifests/default_database.pp | 32 ++++++++++++++++---------------- manifests/server/account_security.pp | 10 +++++----- manifests/server/base.pp | 2 +- manifests/server/munin/default.pp | 11 ++++------- 5 files changed, 39 insertions(+), 38 deletions(-) (limited to 'manifests') diff --git a/manifests/admin_user.pp b/manifests/admin_user.pp index 52d01fc..66e0cc1 100644 --- a/manifests/admin_user.pp +++ b/manifests/admin_user.pp @@ -1,17 +1,21 @@ +# add an admin user that has +# access to all databases define mysql::admin_user( + $password, $ensure = present, - $host = '127.0.0.1', - $password + $host = '127.0.0.1' ){ + $password_hash = $password ? { + 'trocla' => trocla("mysql_admin-user_${name}",'mysql'), + default => $password, + } mysql_user{"${name}@${host}": - ensure => $ensure, - password_hash => $password ? { - 'trocla' => trocla("mysql_admin-user_${name}",'mysql'), - default => $password, - }, + ensure => $ensure, + password_hash => $password_hash, + require => Exec['mysql_set_rootpw'], } mysql_grant{"${name}@${host}": - privileges => 'all', - require => Mysql_user["${name}@${host}"], + privileges => 'all', + require => Mysql_user["${name}@${host}"], } } diff --git a/manifests/default_database.pp b/manifests/default_database.pp index cfa1132..0afc542 100644 --- a/manifests/default_database.pp +++ b/manifests/default_database.pp @@ -12,38 +12,38 @@ define mysql::default_database( default => $username } mysql_database{$name: - ensure => $ensure + ensure => $ensure } if $password == 'absent' and $ensure != 'absent' { info("we don't create the user for database: ${name}") - $grant_require = Mysql_database[$name] + $grant_require = [ Mysql_database[$name], Exec['mysql_set_rootpw'] ] } else { mysql_user{"${real_username}@${host}": - ensure => $ensure, - require => [ - Mysql_database[$name] - ], + ensure => $ensure, + require => Mysql_database[$name], } $grant_require = [ Mysql_database[$name], - Mysql_user["${real_username}@${host}"] + Mysql_user["${real_username}@${host}"], + Exec['mysql_set_rootpw'] ] if $ensure == 'present' { - Mysql_user["${real_username}@${host}"]{ - password_hash => $password ? { - 'trocla' => trocla("mysql_${real_username}",'mysql'), - default => $password_is_encrypted ? { - true => $password, - default => mysql_password("$password") + $password_hash = $password ? { + 'trocla' => trocla("mysql_${real_username}",'mysql'), + default => $password_is_encrypted ? { + true => $password, + default => mysql_password($password) }, - }, + } + Mysql_user["${real_username}@${host}"]{ + password_hash => $password_hash } } } if $ensure == 'present' { mysql_grant{"${real_username}@${host}/${name}": - privileges => $privileges, - require => $grant_require, + privileges => $privileges, + require => $grant_require, } } } diff --git a/manifests/server/account_security.pp b/manifests/server/account_security.pp index b5d75ca..a17f0b3 100644 --- a/manifests/server/account_security.pp +++ b/manifests/server/account_security.pp @@ -1,8 +1,8 @@ +# some installations have some default users which are not required. +# We remove them here. You can subclass this class to overwrite this behavior. class mysql::server::account_security { - # some installations have some default users which are not required. - # We remove them here. You can subclass this class to overwrite this behavior. - mysql_user{ [ "root@${::fqdn}", "root@127.0.0.1", "@${::fqdn}", "@localhost", "@%" ]: - ensure => 'absent', - require => Service['mysql'], + mysql_user{ [ "root@${::fqdn}", 'root@127.0.0.1', "@${::fqdn}", '@localhost', '@%' ]: + ensure => 'absent', + require => Exec['mysql_set_rootpw'], } } diff --git a/manifests/server/base.pp b/manifests/server/base.pp index 0709a54..23d2f35 100644 --- a/manifests/server/base.pp +++ b/manifests/server/base.pp @@ -58,7 +58,7 @@ class mysql::server::base { exec { 'mysql_set_rootpw': command => '/usr/local/sbin/setmysqlpass.sh', unless => 'mysqladmin -uroot status > /dev/null', - require => [ File['mysql_setmysqlpass.sh'], Package['mysql-server'] ], + require => [ File['mysql_setmysqlpass.sh'], Service['mysql'] ], refreshonly => true, } diff --git a/manifests/server/munin/default.pp b/manifests/server/munin/default.pp index 04902b2..acdaabb 100644 --- a/manifests/server/munin/default.pp +++ b/manifests/server/munin/default.pp @@ -2,27 +2,24 @@ class mysql::server::munin::default { mysql_user{'munin@localhost': password_hash => trocla("mysql_munin_${::fqdn}",'mysql','length: 32'), - require => Package['mysql'], + require => Exec['mysql_set_rootpw'], } mysql_grant{'munin@localhost': privileges => 'select_priv', - require => [ Mysql_user['munin@localhost'], Package['mysql'] ], + require => Mysql_user['munin@localhost'], } $munin_mysql_password = trocla("mysql_munin_${::fqdn}",'plain', 'length: 32') 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'], Package['mysql'] ] + require => Mysql_grant['munin@localhost'], } Munin::Plugin::Deploy{ config => "env.mysqlopts --user=munin --password='${munin_mysql_password}' -h localhost", - require => - [ Mysql_grant['munin@localhost'], - Mysql_user['munin@localhost'], - Package['mysql'] ] + require => Mysql_grant['munin@localhost'], } munin::plugin::deploy{ 'mysql_connections': -- cgit v1.2.3