Merge pull request #5 from bodepd/feature/master/no_root_debian
Debian should not manage root password
This commit is contained in:
commit
3c1793ac73
2 changed files with 42 additions and 25 deletions
|
@ -16,11 +16,24 @@
|
|||
# Sample Usage:
|
||||
#
|
||||
class mysql::server(
|
||||
$root_password,
|
||||
$old_root_password = '',
|
||||
$service_name = $mysql::params::service_name,
|
||||
$root_password = undef,
|
||||
$old_root_password = undef,
|
||||
$package_name = 'mysql-server'
|
||||
) inherits mysql::params {
|
||||
|
||||
case $operatingsystem {
|
||||
'centos', 'redhat', 'fedora': {
|
||||
class { 'mysql::server::redhat':
|
||||
root_password => $root_password,
|
||||
old_root_password => $old_root_password,
|
||||
}
|
||||
}
|
||||
'ubuntu', 'debian': {
|
||||
# there is not any debian specific config yet
|
||||
}
|
||||
}
|
||||
|
||||
package{'mysql-server':
|
||||
name => $package_name,
|
||||
ensure => present,
|
||||
|
@ -43,27 +56,4 @@ class mysql::server(
|
|||
group => 'mysql',
|
||||
require => Package['mysql-server'],
|
||||
}
|
||||
# use the previous password for the case where its not configured in /root/.my.cnf
|
||||
case $old_root_password {
|
||||
'': {$old_pw=''}
|
||||
default: {$old_pw="-p${old_root_password}"}
|
||||
}
|
||||
exec{ 'set_mysql_rootpw':
|
||||
command => "mysqladmin -u root ${old_pw} password ${root_password}",
|
||||
#logoutput => on_failure,
|
||||
logoutput => true,
|
||||
unless => "mysqladmin -u root -p${root_password} status > /dev/null",
|
||||
path => '/usr/local/sbin:/usr/bin',
|
||||
require => [Package['mysql-server'], Service['mysqld']],
|
||||
before => File['/root/.my.cnf'],
|
||||
notify => Exec['mysqld-restart'],
|
||||
}
|
||||
|
||||
file{['/root/.my.cnf', '/etc/my.cnf']:
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0400',
|
||||
content => template('mysql/my.cnf.erb'),
|
||||
notify => Exec['mysqld-restart'],
|
||||
}
|
||||
}
|
||||
|
|
27
manifests/server/redhat.pp
Normal file
27
manifests/server/redhat.pp
Normal file
|
@ -0,0 +1,27 @@
|
|||
class mysql::server::redhat(
|
||||
$root_password,
|
||||
$old_root_password = ''
|
||||
) {
|
||||
case $old_root_password {
|
||||
'': {$old_pw=''}
|
||||
default: {$old_pw="-p${old_root_password}"}
|
||||
}
|
||||
exec{ 'set_mysql_rootpw':
|
||||
command => "mysqladmin -u root ${old_pw} password ${root_password}",
|
||||
#logoutput => on_failure,
|
||||
logoutput => true,
|
||||
unless => "mysqladmin -u root -p${root_password} status > /dev/null",
|
||||
path => '/usr/local/sbin:/usr/bin',
|
||||
require => [Package['mysql-server'], Service['mysqld']],
|
||||
before => File['/root/.my.cnf'],
|
||||
notify => Exec['mysqld-restart'],
|
||||
}
|
||||
file{['/root/.my.cnf', '/etc/my.cnf']:
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0400',
|
||||
content => template('mysql/my.cnf.erb'),
|
||||
notify => Exec['mysqld-restart'],
|
||||
require => Package['mysql-server'],
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue