2013-09-09 17:34:39 +02:00
|
|
|
#
|
|
|
|
class mysql::server::service {
|
2015-02-27 18:54:00 +01:00
|
|
|
$options = $mysql::server::options
|
2013-09-09 17:34:39 +02:00
|
|
|
|
2013-09-13 19:04:42 +02:00
|
|
|
if $mysql::server::real_service_manage {
|
2014-08-21 17:44:27 +02:00
|
|
|
if $mysql::server::real_service_enabled {
|
|
|
|
$service_ensure = 'running'
|
|
|
|
} else {
|
|
|
|
$service_ensure = 'stopped'
|
2013-09-09 17:34:39 +02:00
|
|
|
}
|
2015-03-16 12:14:27 +01:00
|
|
|
} else {
|
|
|
|
$service_ensure = undef
|
2013-09-09 17:34:39 +02:00
|
|
|
}
|
|
|
|
|
2015-06-23 19:04:39 +02:00
|
|
|
if $mysql::server::override_options and $mysql::server::override_options['mysqld'] and $mysql::server::override_options['mysqld']['user'] {
|
2014-09-15 00:15:24 +02:00
|
|
|
$mysqluser = $mysql::server::override_options['mysqld']['user']
|
|
|
|
} else {
|
|
|
|
$mysqluser = $options['mysqld']['user']
|
|
|
|
}
|
|
|
|
|
2015-04-13 23:45:22 +02:00
|
|
|
if $options['mysqld']['log-error'] {
|
|
|
|
file { $options['mysqld']['log-error']:
|
|
|
|
ensure => present,
|
|
|
|
owner => $mysqluser,
|
|
|
|
group => $::mysql::server::mysql_group,
|
|
|
|
}
|
2014-08-21 17:44:27 +02:00
|
|
|
}
|
|
|
|
|
2015-12-14 22:52:37 +01:00
|
|
|
if $mysql::server::real_service_manage {
|
|
|
|
service { 'mysqld':
|
|
|
|
ensure => $service_ensure,
|
|
|
|
name => $mysql::server::service_name,
|
|
|
|
enable => $mysql::server::real_service_enabled,
|
|
|
|
provider => $mysql::server::service_provider,
|
|
|
|
}
|
2015-05-09 01:50:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# only establish ordering between service and package if
|
|
|
|
# we're managing the package.
|
|
|
|
if $mysql::server::package_manage {
|
|
|
|
Service['mysqld'] {
|
2015-08-10 23:03:49 +02:00
|
|
|
require => Package['mysql-server'],
|
2015-05-09 01:50:45 +02:00
|
|
|
}
|
2015-02-12 19:37:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# only establish ordering between config file and service if
|
|
|
|
# we're managing the config file.
|
|
|
|
if $mysql::server::manage_config_file {
|
|
|
|
File['mysql-config-file'] -> Service['mysqld']
|
2014-08-21 17:44:27 +02:00
|
|
|
}
|
|
|
|
|
2015-11-30 19:27:51 +01:00
|
|
|
if $mysql::server::override_options and $mysql::server::override_options['mysqld'] and $mysql::server::override_options['mysqld']['socket'] {
|
|
|
|
$mysqlsocket = $mysql::server::override_options['mysqld']['socket']
|
|
|
|
} else {
|
|
|
|
$mysqlsocket = $options['mysqld']['socket']
|
|
|
|
}
|
|
|
|
|
|
|
|
exec { 'wait_for_mysql_socket_to_open':
|
|
|
|
command => "test -S ${mysqlsocket}",
|
|
|
|
unless => "test -S ${mysqlsocket}",
|
|
|
|
tries => '3',
|
|
|
|
try_sleep => '10',
|
|
|
|
require => Service['mysqld'],
|
|
|
|
path => '/bin:/usr/bin',
|
|
|
|
}
|
2013-09-09 17:34:39 +02:00
|
|
|
}
|