Merge pull request #536 from apenney/mysql_install
Handle changing the datadir properly.
This commit is contained in:
commit
52d44be30f
3 changed files with 37 additions and 0 deletions
|
@ -6,4 +6,24 @@ class mysql::server::install {
|
|||
name => $mysql::server::package_name,
|
||||
}
|
||||
|
||||
# Build the initial databases.
|
||||
if $mysql::server::override_options['mysqld'] and $mysql::server::override_options['mysqld']['datadir'] {
|
||||
$mysqluser = $mysql::server::options['mysqld']['user']
|
||||
$datadir = $mysql::server::override_options['mysqld']['datadir']
|
||||
|
||||
exec { 'mysql_install_db':
|
||||
command => "mysql_install_db --datadir=${datadir} --user=${mysqluser}",
|
||||
creates => "${datadir}/mysql",
|
||||
logoutput => on_failure,
|
||||
path => '/bin:/sbin:/usr/bin:/usr/sbin',
|
||||
require => Package['mysql-server'],
|
||||
}
|
||||
|
||||
if $mysql::server::restart {
|
||||
Exec['mysql_install_db'] {
|
||||
notify => Class['mysql::service'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -285,4 +285,20 @@ describe 'mysql class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatin
|
|||
end
|
||||
end
|
||||
|
||||
describe 'creates the appropriate databases when datadir is set' do
|
||||
tmpdir = default.tmpdir('mysql')
|
||||
it 'sets up mysql' do
|
||||
pp = <<-EOS
|
||||
class { 'mysql::server':
|
||||
override_options => { 'mysqld' => { 'datadir' => '#{tmpdir}/mysql' }},
|
||||
}
|
||||
EOS
|
||||
shell("mkdir -p #{tmpdir}; chown -R mysql:mysql #{tmpdir}")
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file("#{tmpdir}/mysql/mysql") do
|
||||
it { should be_directory }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ HOSTS:
|
|||
centos-64-x64:
|
||||
roles:
|
||||
- master
|
||||
- default
|
||||
platform: el-6-x86_64
|
||||
box : centos-64-x64-vbox4210-nocm
|
||||
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
|
||||
|
|
Loading…
Reference in a new issue