2013-09-09 17:34:39 +02:00
|
|
|
#
|
|
|
|
class mysql::server::install {
|
|
|
|
|
|
|
|
package { 'mysql-server':
|
2014-10-29 20:59:59 +01:00
|
|
|
ensure => $mysql::server::package_ensure,
|
|
|
|
install_options => $mysql::server::install_options,
|
|
|
|
name => $mysql::server::package_name,
|
2013-09-09 17:34:39 +02:00
|
|
|
}
|
|
|
|
|
2014-07-07 22:47:17 +02:00
|
|
|
# Build the initial databases.
|
2014-12-05 10:45:38 +01:00
|
|
|
$mysqluser = $mysql::server::options['mysqld']['user']
|
|
|
|
$datadir = $mysql::server::options['mysqld']['datadir']
|
|
|
|
$basedir = $mysql::server::options['mysqld']['basedir']
|
|
|
|
$config_file = $mysql::server::config_file
|
2013-12-26 22:39:55 +01:00
|
|
|
|
2014-12-05 10:45:38 +01:00
|
|
|
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'],
|
|
|
|
}
|
2014-07-08 19:24:23 +02:00
|
|
|
|
2014-12-05 10:45:38 +01:00
|
|
|
if $mysql::server::restart {
|
|
|
|
Exec['mysql_install_db'] {
|
|
|
|
notify => Class['mysql::server::service'],
|
2014-07-08 19:24:23 +02:00
|
|
|
}
|
2013-12-26 22:39:55 +01:00
|
|
|
}
|
|
|
|
|
2013-09-09 17:34:39 +02:00
|
|
|
}
|