72da2c5838
On Ubuntu, mysql should use upstart provider instead of init.d. This change overrides the init provider until the issue with init provider can be addressed.
96 lines
2.6 KiB
Puppet
96 lines
2.6 KiB
Puppet
# Class: mysql::config
|
|
#
|
|
# Parameters:
|
|
#
|
|
# [*root_password*] - root user password.
|
|
# [*old_root_password*] - previous root user password,
|
|
# [*bind_address*] - address to bind service.
|
|
# [*port*] - port to bind service.
|
|
# [*etc_root_password*] - whether to save /etc/.my.cnf.
|
|
# [*service_name*] - mysql service name.
|
|
# [*config_file*] - my.cnf configuration file path.
|
|
# [*socket*] - mysql socket.
|
|
#
|
|
# Actions:
|
|
#
|
|
# Requires:
|
|
#
|
|
# class mysql::server
|
|
#
|
|
# Usage:
|
|
#
|
|
# class { 'mysql::config':
|
|
# root_password => 'changeme',
|
|
# bind_address => $::ipaddress,
|
|
# }
|
|
#
|
|
class mysql::config(
|
|
$root_password = 'UNSET',
|
|
$old_root_password = '',
|
|
$bind_address = $mysql::params::bind_address,
|
|
$port = $mysql::params::port,
|
|
$etc_root_password = $mysql::params::etc_root_password,
|
|
$service_name = $mysql::params::service_name,
|
|
$config_file = $mysql::params::config_file,
|
|
$socket = $mysql::params::socket
|
|
) inherits mysql::params {
|
|
|
|
File {
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0400',
|
|
notify => Exec['mysqld-restart'],
|
|
}
|
|
|
|
# This kind of sucks, that I have to specify a difference resource for
|
|
# restart. the reason is that I need the service to be started before mods
|
|
# to the config file which can cause a refresh
|
|
exec { 'mysqld-restart':
|
|
command => "service ${service_name} restart",
|
|
logoutput => on_failure,
|
|
refreshonly => true,
|
|
path => '/sbin/:/usr/sbin/:/usr/bin/:/bin/',
|
|
}
|
|
|
|
# manage root password if it is set
|
|
if $root_password != 'UNSET' {
|
|
case $old_root_password {
|
|
'': { $old_pw='' }
|
|
default: { $old_pw="-p${old_root_password}" }
|
|
}
|
|
|
|
exec { 'set_mysql_rootpw':
|
|
command => "mysqladmin -u root ${old_pw} password ${root_password}",
|
|
logoutput => true,
|
|
unless => "mysqladmin -u root -p${root_password} status > /dev/null",
|
|
path => '/usr/local/sbin:/usr/bin',
|
|
notify => Exec['mysqld-restart']
|
|
}
|
|
|
|
file { '/root/.my.cnf':
|
|
content => template('mysql/my.cnf.pass.erb'),
|
|
require => Exec['set_mysql_rootpw'],
|
|
}
|
|
|
|
if $etc_root_password {
|
|
file{ '/etc/my.cnf':
|
|
content => template('mysql/my.cnf.pass.erb'),
|
|
require => Exec['set_mysql_rootpw'],
|
|
}
|
|
}
|
|
}
|
|
|
|
file { '/etc/mysql':
|
|
ensure => directory,
|
|
mode => '0755',
|
|
}
|
|
file { '/etc/mysql/conf.d':
|
|
ensure => directory,
|
|
mode => '0755',
|
|
}
|
|
file { $config_file:
|
|
content => template('mysql/my.cnf.erb'),
|
|
mode => '0644',
|
|
}
|
|
|
|
}
|