Merge pull request #701 from roidelapluie/fixinstalldb
Split package installation and database install
This commit is contained in:
commit
cc5d937b83
3 changed files with 44 additions and 42 deletions
|
@ -51,6 +51,7 @@ class mysql::server (
|
|||
|
||||
include '::mysql::server::install'
|
||||
include '::mysql::server::config'
|
||||
include '::mysql::server::installdb'
|
||||
include '::mysql::server::service'
|
||||
include '::mysql::server::root_password'
|
||||
include '::mysql::server::providers'
|
||||
|
@ -65,24 +66,18 @@ class mysql::server (
|
|||
anchor { 'mysql::server::end': }
|
||||
|
||||
if $restart {
|
||||
Anchor['mysql::server::start'] ->
|
||||
Class['mysql::server::install'] ->
|
||||
# Only difference between the blocks is that we use ~> to restart if
|
||||
# restart is set to true.
|
||||
Class['mysql::server::config'] ~>
|
||||
Class['mysql::server::service'] ->
|
||||
Class['mysql::server::root_password'] ->
|
||||
Class['mysql::server::providers'] ->
|
||||
Anchor['mysql::server::end']
|
||||
} else {
|
||||
Anchor['mysql::server::start'] ->
|
||||
Class['mysql::server::install'] ->
|
||||
Class['mysql::server::config'] ->
|
||||
Class['mysql::server::service'] ->
|
||||
Class['mysql::server::root_password'] ->
|
||||
Class['mysql::server::providers'] ->
|
||||
Anchor['mysql::server::end']
|
||||
Class['mysql::server::service']
|
||||
}
|
||||
|
||||
Anchor['mysql::server::start'] ->
|
||||
Class['mysql::server::install'] ->
|
||||
Class['mysql::server::config'] ->
|
||||
Class['mysql::server::installdb'] ->
|
||||
Class['mysql::server::service'] ->
|
||||
Class['mysql::server::root_password'] ->
|
||||
Class['mysql::server::providers'] ->
|
||||
Anchor['mysql::server::end']
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,32 +8,6 @@ class mysql::server::install {
|
|||
install_options => $mysql::server::install_options,
|
||||
name => $mysql::server::package_name,
|
||||
}
|
||||
|
||||
# Build the initial databases.
|
||||
$mysqluser = $mysql::server::options['mysqld']['user']
|
||||
$datadir = $mysql::server::options['mysqld']['datadir']
|
||||
$basedir = $mysql::server::options['mysqld']['basedir']
|
||||
$config_file = $mysql::server::config_file
|
||||
|
||||
if $mysql::server::manage_config_file {
|
||||
$install_db_args = "--basedir=${basedir} --defaults-extra-file=${config_file} --datadir=${datadir} --user=${mysqluser}"
|
||||
} else {
|
||||
$install_db_args = "--basedir=${basedir} --datadir=${datadir} --user=${mysqluser}"
|
||||
}
|
||||
|
||||
exec { 'mysql_install_db':
|
||||
command => "mysql_install_db ${install_db_args}",
|
||||
creates => "${datadir}/mysql",
|
||||
logoutput => on_failure,
|
||||
path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin',
|
||||
require => Package['mysql-server'],
|
||||
}
|
||||
|
||||
if $mysql::server::restart {
|
||||
Exec['mysql_install_db'] {
|
||||
notify => Class['mysql::server::service'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
33
manifests/server/installdb.pp
Normal file
33
manifests/server/installdb.pp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
class mysql::server::installdb {
|
||||
|
||||
if $mysql::server::package_manage {
|
||||
|
||||
# Build the initial databases.
|
||||
$mysqluser = $mysql::server::options['mysqld']['user']
|
||||
$datadir = $mysql::server::options['mysqld']['datadir']
|
||||
$basedir = $mysql::server::options['mysqld']['basedir']
|
||||
$config_file = $mysql::server::config_file
|
||||
|
||||
if $mysql::server::manage_config_file {
|
||||
$install_db_args = "--basedir=${basedir} --defaults-extra-file=${config_file} --datadir=${datadir} --user=${mysqluser}"
|
||||
} else {
|
||||
$install_db_args = "--basedir=${basedir} --datadir=${datadir} --user=${mysqluser}"
|
||||
}
|
||||
|
||||
exec { 'mysql_install_db':
|
||||
command => "mysql_install_db ${install_db_args}",
|
||||
creates => "${datadir}/mysql",
|
||||
logoutput => on_failure,
|
||||
path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin',
|
||||
require => Package['mysql-server'],
|
||||
}
|
||||
|
||||
if $mysql::server::restart {
|
||||
Exec['mysql_install_db'] {
|
||||
notify => Class['mysql::server::service'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue