Merge pull request #536 from apenney/mysql_install

Handle changing the datadir properly.
This commit is contained in:
Hunter Haugen 2014-07-08 14:55:11 -07:00
commit 52d44be30f
3 changed files with 37 additions and 0 deletions

View file

@ -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'],
}
}
}
}

View file

@ -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

View file

@ -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