summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2010-01-19 12:09:01 -0200
committerSilvio Rhatto <rhatto@riseup.net>2010-01-19 12:09:01 -0200
commit39758c6344d2e0a70871f5e47f8c124cb49849b8 (patch)
tree2d3ec1a87895f5fe88c85bb7372770bd68965867 /manifests
parent6dbd3aa79b7fcd3dfa4682d1e5a8ad2f9fc87cbd (diff)
downloadpuppet-mysql-39758c6344d2e0a70871f5e47f8c124cb49849b8.tar.gz
puppet-mysql-39758c6344d2e0a70871f5e47f8c124cb49849b8.tar.bz2
Setting root password
Diffstat (limited to 'manifests')
-rw-r--r--manifests/init.pp33
1 files changed, 33 insertions, 0 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index 58adab1..d498152 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,5 +1,6 @@
# Using recipe from
# from http://reductivelabs.com/trac/puppet/wiki/Recipes/MySQLStoredConfiguration
+# and snippets from git://git.puppet.immerda.ch/module-mysql.git
class mysql {
package { "mysql-client":
@@ -18,4 +19,36 @@ class mysql::server inherits mysql {
hasstatus => true,
require => Package["mysql-server"],
}
+
+ case $mysql_rootpw {
+ '': { fail("You need to define a mysql root password! Please set \$mysql_rootpw in your site.pp or host config") }
+ }
+
+ file{ '/usr/local/sbin/setmysqlpass.sh':
+ source => "puppet://$server/modules/mysql/setmysqlpass.sh",
+ require => Package[mysql-server],
+ owner => root, group => 0, mode => 0500;
+ }
+
+ exec{'set_mysql_rootpw':
+ command => "/usr/local/sbin/setmysqlpass.sh",
+ unless => "mysqladmin -uroot status > /dev/null",
+ require => [ File['/usr/local/sbin/setmysqlpass.sh'], Package[mysql-server] ],
+ }
+
+ mysql::cnf { "root":
+ home => "/root",
+ passwd => $mysql_rootpw,
+ }
+
+ define mysql::cnf($home, $passwd) {
+ $mysql_passwd = $passwd
+ file { "$home/.my.cnf":
+ content => template('mysql/my.cnf.erb'),
+ require => [ Package[mysql-server] ],
+ owner => root,
+ group => 0,
+ mode => 0400,
+ }
+ }
}