From 8f23dc4b9e0cd86385d5c864dbac0e1ef550c700 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 25 Jan 2013 16:05:43 -0200 Subject: Switching to parametrized class and hiera --- manifests/init.pp | 13 ++++++++----- templates/my.cnf.erb | 2 +- templates/setmysqlpass.sh.erb | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 16904fe..cbb57e0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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'], diff --git a/templates/my.cnf.erb b/templates/my.cnf.erb index c56c89f..06e7e43 100644 --- a/templates/my.cnf.erb +++ b/templates/my.cnf.erb @@ -1,4 +1,4 @@ [client] user=root host=localhost -password=<%= mysql_passwd %> +password=<%= @passwd %> diff --git a/templates/setmysqlpass.sh.erb b/templates/setmysqlpass.sh.erb index b3b14b3..372b513 100644 --- a/templates/setmysqlpass.sh.erb +++ b/templates/setmysqlpass.sh.erb @@ -4,7 +4,7 @@ # # Config -PASSWORD="<%= mysql_rootpw %>" +PASSWORD="<%= @rootpw %>" DEFAULTS="/etc/mysql/debian.cnf" # Run -- cgit v1.2.3