Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #12 from bodepd/feauture/master/expand_config

Created config class and extended params.
  • Loading branch information...
commit aaffc471c18c204472c22cc686ca9bf791720517 2 parents dbcdaf9 + a24881a
Dan Bode authored
View
2  Modulefile
@@ -6,3 +6,5 @@ license 'Apache'
summary 'Mysql module'
description 'Mysql module'
project_page 'http://github.com/puppetlabs/puppetlabs-mysql'
+
+dependency 'puppetlasb/create_resources', '>= 1.2.0'
View
41 manifests/config.pp
@@ -0,0 +1,41 @@
+class mysql::config(
+ $root_password = 'UNSET',
+ $old_root_password = '',
+ $bind_address = '127.0.0.1',
+ $port = 3306
+) {
+
+ # manage root password if it is set
+ if ! $root_password == 'UNSET' {
+ $root_password = $config_hash['root_password']
+ 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 => on_failure,
+ logoutput => true,
+ unless => "mysqladmin -u root -p${root_password} status > /dev/null",
+ path => '/usr/local/sbin:/usr/bin',
+ require => [Package['mysql-server'], Service['mysqld']],
+ before => File['/root/.my.cnf', '/etc/my.cnf'],
+ notify => Exec['mysqld-restart'],
+ }
+ }
+ File {
+ owner => 'root',
+ group => 'root',
+ notify => Exec['mysqld-restart'],
+ require => Package['mysql-server']
+ }
+ file{'/root/.my.cnf':
+ mode => '0400',
+ content => template('mysql/my.cnf.pass.erb'),
+ }
+
+ file { '/etc/mysql/my.cnf':
+ mode => '0400',
+ content => template('mysql/my.cnf.erb'),
+ }
+}
View
20 manifests/server.pp
@@ -17,22 +17,16 @@
#
class mysql::server(
$service_name = $mysql::params::service_name,
- $root_password = undef,
- $old_root_password = undef,
+ $config_hash = {},
$package_name = 'mysql-server'
) inherits mysql::params {
- case $operatingsystem {
- 'centos', 'redhat', 'fedora': {
- class { 'mysql::server::redhat':
- root_password => $root_password,
- old_root_password => $old_root_password,
- }
- }
- 'ubuntu', 'debian': {
- # there is not any debian specific config yet
- }
+ # automatically create a class to deal with
+ # configuration
+ $hash = {
+ "mysql::config" => $config_hash
}
+ create_resources("class", $hash)
package{'mysql-server':
name => $package_name,
@@ -57,4 +51,4 @@
group => 'mysql',
require => Package['mysql-server'],
}
-}
+}
View
27 manifests/server/redhat.pp
@@ -1,27 +0,0 @@
-class mysql::server::redhat(
- $root_password,
- $old_root_password = ''
-) {
- 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 => on_failure,
- logoutput => true,
- unless => "mysqladmin -u root -p${root_password} status > /dev/null",
- path => '/usr/local/sbin:/usr/bin',
- require => [Package['mysql-server'], Service['mysqld']],
- before => File['/root/.my.cnf', '/etc/my.cnf'],
- notify => Exec['mysqld-restart'],
- }
- file{['/root/.my.cnf', '/etc/my.cnf']:
- owner => 'root',
- group => 'root',
- mode => '0400',
- content => template('mysql/my.cnf.erb'),
- notify => Exec['mysqld-restart'],
- require => Package['mysql-server'],
- }
-}
View
35 templates/my.cnf.erb
@@ -1,4 +1,33 @@
[client]
-user=root
-host=localhost
-password=<%= root_password -%>
+port = <%= port %>
+socket = /var/run/mysqld/mysqld.sock
+[mysqld_safe]
+socket = /var/run/mysqld/mysqld.sock
+nice = 0
+[mysqld]
+user = mysql
+socket = /var/run/mysqld/mysqld.sock
+port = <%= port %>
+basedir = /usr
+datadir = /var/lib/mysql
+tmpdir = /tmp
+skip-external-locking
+bind-address = <%= bind_address %>
+key_buffer = 16M
+max_allowed_packet = 16M
+thread_stack = 192K
+thread_cache_size = 8
+myisam-recover = BACKUP
+query_cache_limit = 1M
+query_cache_size = 16M
+log_error = /var/log/mysql/error.log
+expire_logs_days = 10
+max_binlog_size = 100M
+[mysqldump]
+quick
+quote-names
+max_allowed_packet = 16M
+[mysql]
+[isamchk]
+key_buffer = 16M
+!includedir /etc/mysql/conf.d/
View
6 templates/my.cnf.pass.erb
@@ -0,0 +1,6 @@
+[client]
+user=root
+host=localhost
+<% unless root_password == 'UNSET' -%>
+password=<%= root_password %>
+<% end -%>
Please sign in to comment.
Something went wrong with that request. Please try again.