Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mysql::globals. #278

Merged
merged 1 commit into from
Sep 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 18 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ longer work with the previous classes and configuration as before. We've
attempted to handle backwards compatibility automatically by adding a
`attempt_compatibility_mode` parameter to the main mysql class. If you set
this to true it will attempt to map your previous parameters into the new
mysql::globals class.
mysql::server class.

###WARNING

Expand All @@ -49,27 +49,24 @@ live. Even if it's just a no-op and a manual comparision. Please be careful!

If you just want a server installing with the default options you can run
include '::mysql::server'. If you need to customize options, such as the root
password or /etc/my.cnf settings then you can also include mysql::globals and
password or /etc/my.cnf settings then you can also include mysql::server and
pass in an override hash as seen below:

```puppet
class { '::mysql::globals':
class { '::mysql::server':
override_options => { 'mysqld' => { 'max_connections' => '1024' } }
}
```

##Usage

The interactions with this module are split between mysql::globals and several
other classes, mysql::server, mysql::client, and mysql::bindings.
All interaction for the server is done via mysql::server. To install the
client you use mysql::client, and to install bindings you can use
mysql::bindings.

###mysql::globals
###Overrides

This class exists as a way to easily share values between the other mysql
classes. You can pass an override_options into this class to replace elements
of the existing default hash.

The hash structure for overrides is as follows:
The hash structure for overrides in mysql::server is as follows:

```puppet
override_options = {
Expand All @@ -91,15 +88,14 @@ care if thing is alone or set to a value, it'll happily accept both.

To add custom mysql configuration you can drop additional files into
/etc/mysql/conf.d/ in order to override settings or add additional ones (if you
choose not to use override_options in mysql::globals). This location is
choose not to use override_options in mysql::server). This location is
hardcoded into the my.cnf template file.

##Reference

###Classes

####Public classes
* mysql::globals: Settings and customizations for MySQL.
* mysql::server: Installs and configures MySQL.
* mysql::server::account_security: Deletes default MySQL accounts.
* mysql::server::monitor: Sets up a monitoring user.
Expand All @@ -121,7 +117,15 @@ hardcoded into the my.cnf template file.

###Parameters

####mysql::globals
####mysql::server

#####`root_password`

What is the MySQL root password. Puppet will attempt to set it to this and update /root/.my.cnf.

#####`old_root_password`

What was the previous root password (REQUIRED if you wish to change the root password via Puppet.)

#####`override_options`

Expand Down Expand Up @@ -158,16 +162,6 @@ Should the service be restarted when things change?

What is the group used for root?

####mysql::server

#####`root_password`

What is the MySQL root password. Puppet will attempt to set it to this and update /root/.my.cnf.

#####`old_root_password`

What was the previous root password (REQUIRED if you wish to change the root password via Puppet.)

#####`package_ensure`

What to set the package to. Can be present, absent, or version.
Expand Down
2 changes: 1 addition & 1 deletion manifests/bindings.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$ruby_package_ensure = $mysql::params::ruby_package_ensure,
$ruby_package_name = $mysql::params::ruby_package_name,
$ruby_package_provider = $mysql::params::ruby_package_provider
) inherits mysql::globals {
) inherits mysql::params {

if $java_enable { include '::mysql::bindings::java' }
if $perl_enable { include '::mysql::bindings::perl' }
Expand Down
2 changes: 1 addition & 1 deletion manifests/client.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
class mysql::client (
$bindings_enable = false,
) inherits mysql::globals {
) inherits mysql::params {

include '::mysql::client::install'

Expand Down
4 changes: 2 additions & 2 deletions manifests/client/install.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class mysql::client::install(
$package_name = $mysql::globals::client_package_name,
$package_ensure = $mysql::globals::client_package_ensure
$package_name = $mysql::params::client_package_name,
$package_ensure = $mysql::params::client_package_ensure
) {

package { 'mysql_client':
Expand Down
70 changes: 0 additions & 70 deletions manifests/globals.pp

This file was deleted.

12 changes: 6 additions & 6 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

if $attempt_compatibility_mode {
notify { "An attempt has been made below to automatically apply your custom
settings to mysql::globals. Please verify this works in a safe test
settings to mysql::server. Please verify this works in a safe test
environment.": }

$override_options = {
Expand Down Expand Up @@ -81,20 +81,20 @@
$filtered_options = mysql_strip_hash($override_options)
validate_hash($filtered_options)
notify { $filtered_options: }
class { 'mysql::globals':
class { 'mysql::server':
override_options => $filtered_options,
}

} else {
fail("ERROR: This class has been deprecated and the functionality moved
into mysql::globals. If you run mysql::server without correctly calling
mysql:: globals with the new override_options hash syntax you will revert
into mysql::server. If you run mysql::server without correctly calling
mysql:: server with the new override_options hash syntax you will revert
your MySQL to the stock settings. Do not proceed without removing this
class and using mysql::globals correctly.
class and using mysql::server correctly.

If you are brave you may set attempt_compatibility_mode in this class which
attempts to automap the previous settings to appropriate calls to
mysql::globals")
mysql::server")
}

}
55 changes: 55 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,59 @@
}
}

case $::operatingsystem {
'Ubuntu': {
$service_provider = upstart
}
default: {
$service_provider = undef
}
}

$default_options = {
'client' => {
'port' => '3306',
'socket' => $mysql::params::socket,
},
'mysqld_safe' => {
'nice' => '0',
'log_error' => $mysql::params::log_error,
'socket' => $mysql::params::socket,
},
'mysqld' => {
'basedir' => $mysql::params::basedir,
'bind_address' => '127.0.0.1',
'datadir' => $mysql::params::datadir,
'expire_logs_days' => '10',
'key_buffer' => '16M',
'log_error' => $mysql::params::log_error,
'max_allowed_packet' => '16M',
'max_binlog_size' => '100M',
'max_connections' => '151',
'myisam_recover' => 'BACKUP',
'pid_file' => $mysql::params::pidfile,
'port' => '3306',
'query_cache_limit' => '1M',
'query_cache_size' => '16M',
'skip-external-locking' => true,
'socket' => $mysql::params::socket,
'ssl' => false,
'ssl-ca' => $mysql::params::ssl_ca,
'ssl-cert' => $mysql::params::ssl_cert,
'ssl-key' => $mysql::params::ssl_key,
'thread_cache_size' => '8',
'thread_stack' => '256K',
'tmpdir' => $mysql::params::tmpdir,
'user' => 'mysql',
},
'mysqldump' => {
'max_allowed_packets' => '16M',
'quick' => true,
'quote-names' => true,
},
'isamchk' => {
'key_buffer' => '16M',
},
}

}
12 changes: 11 additions & 1 deletion manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
$enabled = undef,
$manage_service = undef,
#
$config_file = $mysql::params::config_file,
$manage_config_file = $mysql::params::manage_config_file,
$old_root_password = $mysql::params::old_root_password,
$old_root_password = $mysql::params::old_root_password,
$override_options = {},
$package_ensure = $mysql::params::server_package_ensure,
$package_name = $mysql::params::server_package_name,
$purge_conf_dir = $mysql::params::purge_conf_dir,
$remove_default_accounts = false,
$restart = $mysql::params::restart,
$root_group = $mysql::params::root_group,
$root_password = $mysql::params::root_password,
$service_enabled = $mysql::params::server_service_enabled,
$service_manage = $mysql::params::server_service_manage,
$service_name = $mysql::params::server_service_name,
$service_provider = $mysql::params::server_service_provider
) inherits mysql::globals {
) inherits mysql::params {

# Deprecated parameters.
if $enabled {
Expand All @@ -29,6 +36,9 @@
$real_service_manage = $service_manage
}

# Create a merged together set of options. Rightmost hashes win over left.
$options = merge($mysql::params::default_options, $override_options)

Class['mysql::server::root_password'] -> Mysql::Db <| |>

include '::mysql::server::install'
Expand Down
12 changes: 7 additions & 5 deletions manifests/server/config.pp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# See README.me for options.
class mysql::server::config {

$options = $mysql::server::options

File {
owner => 'root',
group => $mysql::globals::root_group,
group => $mysql::server::root_group,
mode => '0400',
notify => Class['mysql::server::service'],
}
Expand All @@ -16,12 +18,12 @@
file { '/etc/mysql/conf.d':
ensure => directory,
mode => '0755',
recurse => $mysql::globals::purge_conf_dir,
purge => $mysql::globals::purge_conf_dir,
recurse => $mysql::server::purge_conf_dir,
purge => $mysql::server::purge_conf_dir,
}

if $mysql::globals::manage_config_file {
file { $mysql::globals::config_file:
if $mysql::server::manage_config_file {
file { $mysql::server::config_file:
content => template('mysql/my.cnf.erb'),
mode => '0644',
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/server/root_password.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
class mysql::server::root_password {

$options = $mysql::globals::options
$options = $mysql::server::options

# manage root password if it is set
if $mysql::server::root_password != 'UNSET' {
Expand Down
6 changes: 2 additions & 4 deletions spec/system/mysql_backup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
describe 'mysql::server::backup class' do
context 'should work with no errors' do
pp = <<-EOS
class { 'mysql::globals': override_options => { 'root_password' => 'password' } }
class { 'mysql::server': }
class { 'mysql::server': override_options => { 'root_password' => 'password' } }
mysql::db { 'backup1':
user => 'backup',
password => 'secret',
Expand Down Expand Up @@ -43,8 +42,7 @@ class { 'mysql::server::backup':

context 'should create one file per database' do
pp = <<-EOS
class { 'mysql::globals': override_options => { 'root_password' => 'password' } }
class { 'mysql::server': }
class { 'mysql::server': override_options => { 'root_password' => 'password' } }
mysql::db { 'backup1':
user => 'backup',
password => 'secret',
Expand Down