diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2010-01-19 12:18:41 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2010-01-19 12:18:41 -0200 |
commit | 2bcf643cfbce93ff0a6ee3f39695fc9cc9cb63d9 (patch) | |
tree | 1a07d8d5e1df155e19716e70b419702b503cc453 | |
parent | 39758c6344d2e0a70871f5e47f8c124cb49849b8 (diff) | |
download | puppet-mysql-2bcf643cfbce93ff0a6ee3f39695fc9cc9cb63d9.tar.gz puppet-mysql-2bcf643cfbce93ff0a6ee3f39695fc9cc9cb63d9.tar.bz2 |
Changing root password
-rw-r--r-- | manifests/init.pp | 91 |
1 files 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'], + } + } } |