]> gitweb.fluxo.info Git - puppet-mysql.git/commitdiff
Switching to parametrized class and hiera
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 25 Jan 2013 18:05:43 +0000 (16:05 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 25 Jan 2013 18:05:43 +0000 (16:05 -0200)
manifests/init.pp
templates/my.cnf.erb
templates/setmysqlpass.sh.erb

index 16904fe2c6e1393095ecfb974f73e1acd9b6257b..cbb57e0c6890e40547bcad6054fc7898f54567b7 100644 (file)
@@ -18,7 +18,11 @@ class mysql {
   }
 }
 
-class mysql::server inherits mysql {
+class mysql::server(
+  $rootpw => hiera('mysql::server::rootpw', '')
+){
+  include mysql
+
   package { "mysql-server":
     ensure => installed,
   }
@@ -31,8 +35,8 @@ class mysql::server inherits mysql {
     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") }
+  case $rootpw {
+    '': { fail("You need to define a mysql root password! Please set mysql::server::rootpw config") }
   }
 
   file { '/usr/local/sbin/setmysqlpass.sh':
@@ -52,11 +56,10 @@ class mysql::server inherits mysql {
 
   mysql::cnf { "root":
     home   => "/root",
-    passwd => $mysql_rootpw,
+    passwd => $rootpw,
   }
 
   define mysql::cnf($home, $passwd) {
-    $mysql_passwd = $passwd
     file { "$home/.my.cnf":
       content => template('mysql/my.cnf.erb'),
       require => Service['mysql'],
index c56c89fa925367b5fd94eb0cbf9ad8bf978b4bf0..06e7e439955431c124995d6bee0de3239fbe3074 100644 (file)
@@ -1,4 +1,4 @@
 [client]
 user=root
 host=localhost
-password=<%= mysql_passwd %>
+password=<%= @passwd %>
index b3b14b36585520e744f90a34805f6c44a7877851..372b513143141bb247527a9fb9ec5c2b0f8c3da4 100644 (file)
@@ -4,7 +4,7 @@
 #
 
 # Config
-PASSWORD="<%= mysql_rootpw %>"
+PASSWORD="<%= @rootpw %>"
 DEFAULTS="/etc/mysql/debian.cnf"
 
 # Run