puppetlabs/puppetlabs-mysql — pull request #118 by craigtracey (2012-09-27 19:40:11+00:00)
Title: Allow for the subclassing of the mysql::config class

For many MySQL users, the default configuration templates for MySQL may not be sufficient. MySQL has a plethora of config options and it would be extremely useful to be able to manipulate these as desired.

The current logic for the server class does not lend itself well to subclassing the config class as it hard-codes 'mysql::confg' when calling create_resources(). In our use case we have subclassed mysql::config such that we provide our own erb template - one with all of the configuration items that we require.

Now, when declaring a mysql::server resource we can do so in the following manner:

class our-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,
$pidfile = $mysql::params::pidfile,
$datadir = $mysql::params::datadir,
$ssl = $mysql::params::ssl,
$ssl_ca = $mysql::params::ssl_ca,
$ssl_cert = $mysql::params::ssl_cert,
$ssl_key = $mysql::params::ssl_key,
$log_error = $mysql::params::log_error,
$default_engine = 'UNSET',
$root_group = $mysql::params::root_group,
$restart = $mysql::params::restart
$our_other_settings
...

) inherits mysql::config {

File [ "/etc/my.cnf" ] {
content => template('our-mysql/my.cnf.erb'),
mode => '0644',
}
}

class our-mysql {

class { 'mysql::server':
package_name => "mysql55-server",
config_type => "our-mysql::config",
config_hash => {
'socket' => "/opt/mysql/dbprod/$our_mysql_data_instance.sock",
'datadir' => "/opt/mysql/dbdata1/$our_mysql_data_instance",
#'tmpdir' => "/opt/mysql/dblogs1/$our_mysql_data_instance/tmp",
'pidfile' => "/opt/mysql/dbprod/$our_mysql_data_instance.pid",
'default_engine' => "innodb",
'log_error' => "/opt/mysql/error",
}
}
}