From 2bcf643cfbce93ff0a6ee3f39695fc9cc9cb63d9 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 19 Jan 2010 12:18:41 -0200 Subject: Changing root password --- manifests/init.pp | 91 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index d498152..2f0fffd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,52 +3,61 @@ # and snippets from git://git.puppet.immerda.ch/module-mysql.git class mysql { - package { "mysql-client": - ensure => installed, - } + package { "mysql-client": + ensure => installed, + } } class mysql::server inherits mysql { - package { "mysql-server": - ensure => installed, - } - service { "mysql": - ensure => running, - enable => true, - hasrestart => true, - hasstatus => true, - require => Package["mysql-server"], - } + package { "mysql-server": + ensure => installed, + } + service { "mysql": + ensure => running, + enable => true, + hasrestart => true, + 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") } - } + 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; - } + file{ '/usr/local/sbin/setmysqlpass.sh': + source => "puppet://$server/modules/mysql/setmysqlpass.sh", + require => Package[mysql-server], + owner => root, + group => root, + 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] ], - } + 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] ], + } + + exec{'change_mysql_rootpw': + command => "/usr/local/sbin/setmysqlpass.sh", + require => [ File['/usr/local/sbin/setmysqlpass.sh'], Package[mysql-server] ], + refreshonly => true, + } - 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, - } - } + 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 => root, + mode => 0400, + notify => Exec['change_mysql_rootpw'], + } + } } -- cgit v1.2.3