From e3b6de2da2584b7b29d7aa7863a94dc965002802 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Thu, 4 Apr 2013 14:02:58 +0400 Subject: [PATCH 1/7] Implement character_set. You can change the default server and client character set --- manifests/config.pp | 11 +++++++---- templates/my.cnf.erb | 8 +++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 440246a..48c74a2 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -19,6 +19,8 @@ # [*default_engine] - configure a default table engine # [*root_group] - use specified group for root-owned files # [*restart] - whether to restart mysqld (true/false) +# [*character-set] - You can change the default server and +# client character set # # Actions: # @@ -52,15 +54,16 @@ class mysql::config( $default_engine = 'UNSET', $root_group = $mysql::params::root_group, $restart = $mysql::params::restart, - $purge_conf_dir = false + $purge_conf_dir = false, + $character_set = 'UNSET', ) inherits mysql::params { File { owner => 'root', group => $root_group, mode => '0400', - notify => $restart ? { - true => Exec['mysqld-restart'], + notify => $restart ? { + true => Exec['mysqld-restart'], false => undef, }, } @@ -100,7 +103,7 @@ class mysql::config( unless => "mysqladmin -u root -p'${root_password}' status > /dev/null", path => '/usr/local/sbin:/usr/bin:/usr/local/bin', notify => $restart ? { - true => Exec['mysqld-restart'], + true => Exec['mysqld-restart'], false => undef, }, require => File['/etc/mysql/conf.d'], diff --git a/templates/my.cnf.erb b/templates/my.cnf.erb index 8a764bc..be20133 100644 --- a/templates/my.cnf.erb +++ b/templates/my.cnf.erb @@ -1,6 +1,9 @@ [client] -port = <%= port %> +port = <%= port %> socket = <%= socket %> +<% if character_set != 'UNSET' %> +default-character-set = <%= character_set %> +<% end -%> [mysqld_safe] socket = <%= socket %> nice = 0 @@ -36,6 +39,9 @@ max_binlog_size = 100M <% if default_engine != 'UNSET' %> default-storage-engine = <%= default_engine %> <% end %> +<% if character_set != 'UNSET' %> +character-set-server = <%= character_set %> +<% end %> <% if ssl == true %> ssl-ca = <%= ssl_ca %> ssl-cert = <%= ssl_cert %> From 2a1b1e7962c90e51970f6c19dd3b7ffb1cfec41e Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Mon, 8 Apr 2013 00:20:36 +0400 Subject: [PATCH 2/7] * Adding `key_buffer` parameter to `mysql::config` * Adding `thread_stack` parameter to `mysql::config` * Adding `thread_cache_size` parameter to `mysql::config` * Adding `myisam-recover` parameter to `mysql::config` * Adding `query_cache_limit` parameter to `mysql::config` * Adding `query_cache_size` parameter to `mysql::config` * Adding `max_connections` parameter to `mysql::config` * Adding `tmp_table_size` parameter to `mysql::config` * Adding `table_open_cache` parameter to `mysql::config` * Adding `long_query_time` parameter to `mysql::config` * Updating mysql_config spec tests * Fixing lint warnings --- manifests/config.pp | 80 ++++++++++++++++++++------- manifests/params.pp | 8 +++ spec/classes/mysql_config_spec.rb | 90 +++++++++++++++++++++++-------- templates/my.cnf.erb | 45 +++++++++++----- 4 files changed, 166 insertions(+), 57 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 48c74a2..04aa7f9 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -2,25 +2,50 @@ # # 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. -# [*datadir*] - path to datadir. -# [*ssl] - enable ssl -# [*ssl_ca] - path to ssl-ca -# [*ssl_cert] - path to ssl-cert -# [*ssl_key] - path to ssl-key -# [*log_error] - path to mysql error log -# [*default_engine] - configure a default table engine -# [*root_group] - use specified group for root-owned files -# [*restart] - whether to restart mysqld (true/false) -# [*character-set] - You can change the default server and -# client character set +# [*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. +# [*datadir*] - path to datadir. +# [*ssl] - enable ssl +# [*ssl_ca] - path to ssl-ca +# [*ssl_cert] - path to ssl-cert +# [*ssl_key] - path to ssl-key +# [*log_error] - path to mysql error log +# [*default_engine] - configure a default table engine +# [*root_group] - use specified group for root-owned files +# [*restart] - whether to restart mysqld (true/false) +# [*character-set] - You can change the default server and +# client character set +# [*key_buffer] - Index blocks for MyISAM tables are buffered and +# are shared by all threads. key_buffer_size is the +# size of the buffer used for index blocks. +# [*max_allowed_packet] - The maximum size of one packet or any +# generated/intermediate string, or any +# parameter sent by the mysql_stmt_send_long_data() +# C API function. +# [*thread_stack] - The stack size for each thread. +# [*thread_cache_size] - How many threads server should cache for reuse. +# [*myisam-recover] - Set the MyISAM storage engine recovery mode. +# [*query_cache_limit] - Do not cache results that are larger than this +# number of bytes. +# [*query_cache_size] - The amount of memory allocated for caching query +# results. +# [*max_connections] - The maximum permitted number of simultaneous +# client connections. +# [*tmp_table_size] - The maximum size of internal in-memory temporary +# tables. +# [*max_heap_table_size] - This variable sets the maximum size to which +# user-created MEMORY tables are permitted to grow. +# [*table_open_cache] - The number of open tables for all threads. +# [*long_query_time] - If a query takes longer than this many seconds, +# the server increments the Slow_queries status +# variable. +# # # Actions: # @@ -55,7 +80,22 @@ class mysql::config( $root_group = $mysql::params::root_group, $restart = $mysql::params::restart, $purge_conf_dir = false, - $character_set = 'UNSET', + + $key_buffer = $mysql::params::key_buffer, + $max_allowed_packet = $mysql::params::max_allowed_packet, + $thread_stack = $mysql::params::thread_stack, + $thread_cache_size = $mysql::params::thread_cache_size, + $myisam_recover = $mysql::params::myisam_recover, + $query_cache_limit = $mysql::params::query_cache_limit, + $query_cache_size = $mysql::params::query_cache_size, + + $max_connections = 'UNSET', + $tmp_table_size = 'UNSET', + $max_heap_table_size = 'UNSET', + $table_open_cache = 'UNSET', + $long_query_time = 'UNSET', + $character_set = 'UNSET', + ) inherits mysql::params { File { diff --git a/manifests/params.pp b/manifests/params.pp index bcae026..feaf4d5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -17,6 +17,14 @@ class mysql::params { $etc_root_password = false $ssl = false $restart = true + $key_buffer = '16M' + $max_allowed_packet = '16M' + $thread_stack = '256K' + $thread_cache_size = 8 + $myisam_recover = 'BACKUP' + $query_cache_limit = '1M' + $query_cache_size = '16M' + case $::operatingsystem { 'Ubuntu': { diff --git a/spec/classes/mysql_config_spec.rb b/spec/classes/mysql_config_spec.rb index 16f97c4..002fc98 100644 --- a/spec/classes/mysql_config_spec.rb +++ b/spec/classes/mysql_config_spec.rb @@ -3,14 +3,27 @@ describe 'mysql::config' do let :constant_parameter_defaults do { - :root_password => 'UNSET', - :old_root_password => '', - :bind_address => '127.0.0.1', - :port => '3306', - :etc_root_password => false, - :datadir => '/var/lib/mysql', - :default_engine => 'UNSET', - :ssl => false, + :root_password => 'UNSET', + :old_root_password => '', + :bind_address => '127.0.0.1', + :port => '3306', + :etc_root_password => false, + :datadir => '/var/lib/mysql', + :default_engine => 'UNSET', + :ssl => false, + :key_buffer => '16M', + :max_allowed_packet => '16M', + :thread_stack => '256K', + :thread_cache_size => 8, + :myisam_recover => 'BACKUP', + :query_cache_limit => '1M', + :query_cache_size => '16M', + :character_set => 'UNSET', + :max_connections => 'UNSET', + :tmp_table_size => 'UNSET', + :max_heap_table_size => 'UNSET', + :table_open_cache => 'UNSET', + :long_query_time => 'UNSET', } end @@ -92,19 +105,25 @@ describe 'mysql::config' do [ {}, { - :service_name => 'dans_service', - :config_file => '/home/dan/mysql.conf', - :service_name => 'dans_mysql', - :pidfile => '/home/dan/mysql.pid', - :socket => '/home/dan/mysql.sock', - :bind_address => '0.0.0.0', - :port => '3306', - :datadir => '/path/to/datadir', - :default_engine => 'InnoDB', - :ssl => true, - :ssl_ca => '/path/to/cacert.pem', - :ssl_cert => '/path/to/server-cert.pem', - :ssl_key => '/path/to/server-key.pem' + :service_name => 'dans_service', + :config_file => '/home/dan/mysql.conf', + :service_name => 'dans_mysql', + :pidfile => '/home/dan/mysql.pid', + :socket => '/home/dan/mysql.sock', + :bind_address => '0.0.0.0', + :port => '3306', + :datadir => '/path/to/datadir', + :default_engine => 'InnoDB', + :ssl => true, + :ssl_ca => '/path/to/cacert.pem', + :ssl_cert => '/path/to/server-cert.pem', + :ssl_key => '/path/to/server-key.pem', + :character_set => 'utf8', + :max_connections => 1000, + :tmp_table_size => '4096M', + :max_heap_table_size => '4096M', + :table_open_cache => 2048, + :long_query_time => 0.5, } ].each do |passed_params| @@ -155,15 +174,40 @@ describe 'mysql::config' do it 'should have a template with the correct contents' do content = param_value(subject, 'file', param_values[:config_file], 'content') expected_lines = [ - "port = #{param_values[:port]}", + "port = #{param_values[:port]}", "socket = #{param_values[:socket]}", "pid-file = #{param_values[:pidfile]}", "datadir = #{param_values[:datadir]}", - "bind-address = #{param_values[:bind_address]}" + "bind-address = #{param_values[:bind_address]}", + "key_buffer = #{param_values[:key_buffer]}", + "max_allowed_packet = #{param_values[:max_allowed_packet]}", + "thread_stack = #{param_values[:thread_stack]}", + "thread_cache_size = #{param_values[:thread_cache_size]}", + "myisam-recover = #{param_values[:myisam_recover]}", + "query_cache_limit = #{param_values[:query_cache_limit]}", + "query_cache_size = #{param_values[:query_cache_size]}", ] + if param_values[:max_connections] != 'UNSET' + expected_lines = expected_lines | [ "max_connections = #{param_values[:max_connections]}" ] + end + if param_values[:tmp_table_size] != 'UNSET' + expected_lines = expected_lines | [ "tmp_table_size = #{param_values[:tmp_table_size]}" ] + end + if param_values[:max_heap_table_size] != 'UNSET' + expected_lines = expected_lines | [ "max_heap_table_size = #{param_values[:max_heap_table_size]}" ] + end + if param_values[:table_open_cache] != 'UNSET' + expected_lines = expected_lines | [ "table_open_cache = #{param_values[:table_open_cache]}" ] + end + if param_values[:long_query_time] != 'UNSET' + expected_lines = expected_lines | [ "long_query_time = #{param_values[:long_query_time]}" ] + end if param_values[:default_engine] != 'UNSET' expected_lines = expected_lines | [ "default-storage-engine = #{param_values[:default_engine]}" ] end + if param_values[:character_set] != 'UNSET' + expected_lines = expected_lines | [ "character-set-server = #{param_values[:character_set]}" ] + end if param_values[:ssl] expected_lines = expected_lines | [ diff --git a/templates/my.cnf.erb b/templates/my.cnf.erb index be20133..78b50ca 100644 --- a/templates/my.cnf.erb +++ b/templates/my.cnf.erb @@ -1,9 +1,9 @@ [client] port = <%= port %> socket = <%= socket %> -<% if character_set != 'UNSET' %> +<% if character_set != 'UNSET' -%> default-character-set = <%= character_set %> -<% end -%> +<% end %> [mysqld_safe] socket = <%= socket %> nice = 0 @@ -24,13 +24,30 @@ skip-external-locking bind-address = <%= bind_address %> <% end %> -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 +key_buffer = <%= key_buffer %> +max_allowed_packet = <%= max_allowed_packet %> +thread_stack = <%= thread_stack %> +thread_cache_size = <%= thread_cache_size %> +myisam-recover = <%= myisam_recover %> +query_cache_limit = <%= query_cache_limit %> +query_cache_size = <%= query_cache_size %> + +<% if max_connections != 'UNSET' -%> +max_connections = <%= max_connections %> +<% end -%> +<% if tmp_table_size != 'UNSET' -%> +tmp_table_size = <%= tmp_table_size %> +<% end -%> +<% if max_heap_table_size != 'UNSET' -%> +max_heap_table_size = <%= max_heap_table_size %> +<% end -%> +<% if table_open_cache != 'UNSET' -%> +table_open_cache = <%= table_open_cache %> +<% end -%> +<% if long_query_time != 'UNSET' -%> +long_query_time = <%= long_query_time %> +<% end -%> + <% if log_error != 'syslog' -%> log_error = <%= log_error %> <% end -%> @@ -38,15 +55,15 @@ expire_logs_days = 10 max_binlog_size = 100M <% if default_engine != 'UNSET' %> default-storage-engine = <%= default_engine %> -<% end %> -<% if character_set != 'UNSET' %> -character-set-server = <%= character_set %> -<% end %> +<% end -%> +<% if character_set != 'UNSET' -%> +character-set-server = <%= character_set %> +<% end -%> <% if ssl == true %> ssl-ca = <%= ssl_ca %> ssl-cert = <%= ssl_cert %> ssl-key = <%= ssl_key %> -<% end %> +<% end -%> [mysqldump] quick From 5ea8e5f9205c71b5a3719bca5b65a2ad5bc53144 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Mon, 8 Apr 2013 19:23:24 +0400 Subject: [PATCH 3/7] * Adding `server_idparameter to `mysql::config` * Adding `sql_log_bin` parameter to `mysql::config` * Adding `log_bin` parameter to `mysql::config` * Adding `max_binlog_size` parameter to `mysql::config` * Adding `binlog_do_db` parameter to `mysql::config` * Adding `expire_logs_days` parameter to `mysql::config` * Adding `log_bin_trust_function_creators` parameter to `mysql::config` * Adding `replicate_ignore_table` parameter to `mysql::config` * Adding `replicate_wild_do_table` parameter to `mysql::config` * Adding `replicate_wild_ignore_table` parameter to `mysql::config` * Adding `expire_logs_days` parameter to `mysql::params` * Adding `max_binlog_size` parameter to `mysql::params` --- manifests/config.pp | 82 +++++++++++++++++++--------- manifests/params.pp | 3 +- spec/classes/mysql_config_spec.rb | 91 +++++++++++++++++++++---------- templates/my.cnf.erb | 51 ++++++++++++----- 4 files changed, 157 insertions(+), 70 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 04aa7f9..657361a 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -19,15 +19,14 @@ # [*default_engine] - configure a default table engine # [*root_group] - use specified group for root-owned files # [*restart] - whether to restart mysqld (true/false) -# [*character-set] - You can change the default server and -# client character set +# [*character_set] - You can change the default server and +# client character set # [*key_buffer] - Index blocks for MyISAM tables are buffered and -# are shared by all threads. key_buffer_size is the -# size of the buffer used for index blocks. +# are shared by all threads. key_buffer_size is the size of the buffer used +# for index blocks. # [*max_allowed_packet] - The maximum size of one packet or any -# generated/intermediate string, or any -# parameter sent by the mysql_stmt_send_long_data() -# C API function. +# generated/intermediate string, or any parameter sent by the +# mysql_stmt_send_long_data() C API function. # [*thread_stack] - The stack size for each thread. # [*thread_cache_size] - How many threads server should cache for reuse. # [*myisam-recover] - Set the MyISAM storage engine recovery mode. @@ -40,12 +39,35 @@ # [*tmp_table_size] - The maximum size of internal in-memory temporary # tables. # [*max_heap_table_size] - This variable sets the maximum size to which -# user-created MEMORY tables are permitted to grow. +# user-created MEMORY tables are permitted to grow. # [*table_open_cache] - The number of open tables for all threads. # [*long_query_time] - If a query takes longer than this many seconds, -# the server increments the Slow_queries status -# variable. -# +# the server increments the Slow_queries status variable. +# [*server_id] - The server ID, used in replication to give each +# master and slave a unique identity. +# [*sql_log_bin] - This variable controls whether logging to the +# binary log is done. The default value is 1. +# [*log_bin] - Enable binary logging. The server logs all +# statements that change data to the binary log, which is used for backup +# and replication. +# [*max_binlog_size] - If a write to the binary log causes the current +# log file size to exceed the value of this variable, the server rotates +# the binary logs (closes the current file and opens the next one). +# [*binlog_do_db] - This option affects binary logging in a manner +# similar to the way that --replicate-do-db affects replication. +# [*expire_logs_days] - The number of days for automatic binary log file +# removal. +# [*log_bin_trust_function_creators] - It controls whether stored function +# creators can be trusted not to create stored functions that will cause +# unsafe events to be written to the binary log. +# [*replicate_ignore_table] - Tells the slave SQL thread not to +# replicate any statement that updates the specified table, even if any +# other tables might be updated by the same statement. +# [*replicate_wild_do_table] - Tells the slave thread to restrict +# replication to statements where any of the updated tables match the +# specified database and table name patterns. +# [*replicate_wild_ignore_table] - Tells the slave thread not to +# replicate a statement where any table matches the given wildcard pattern. # # Actions: # @@ -81,21 +103,29 @@ class mysql::config( $restart = $mysql::params::restart, $purge_conf_dir = false, - $key_buffer = $mysql::params::key_buffer, - $max_allowed_packet = $mysql::params::max_allowed_packet, - $thread_stack = $mysql::params::thread_stack, - $thread_cache_size = $mysql::params::thread_cache_size, - $myisam_recover = $mysql::params::myisam_recover, - $query_cache_limit = $mysql::params::query_cache_limit, - $query_cache_size = $mysql::params::query_cache_size, - - $max_connections = 'UNSET', - $tmp_table_size = 'UNSET', - $max_heap_table_size = 'UNSET', - $table_open_cache = 'UNSET', - $long_query_time = 'UNSET', - $character_set = 'UNSET', - + $key_buffer = $mysql::params::key_buffer, + $max_allowed_packet = $mysql::params::max_allowed_packet, + $thread_stack = $mysql::params::thread_stack, + $thread_cache_size = $mysql::params::thread_cache_size, + $myisam_recover = $mysql::params::myisam_recover, + $query_cache_limit = $mysql::params::query_cache_limit, + $query_cache_size = $mysql::params::query_cache_size, + $max_binlog_size = $mysql::params::max_binlog_size, + $expire_logs_days = $mysql::params::expire_logs_days, + $max_connections = 'UNSET', + $tmp_table_size = 'UNSET', + $max_heap_table_size = 'UNSET', + $table_open_cache = 'UNSET', + $long_query_time = 'UNSET', + $character_set = 'UNSET', + $server_id = 'UNSET', + $sql_log_bin = 'UNSET', + $log_bin = 'UNSET', + $binlog_do_db = 'UNSET', + $log_bin_trust_function_creators = 'UNSET', + $replicate_ignore_table = 'UNSET', + $replicate_wild_do_table = 'UNSET', + $replicate_wild_ignore_table = 'UNSET', ) inherits mysql::params { File { diff --git a/manifests/params.pp b/manifests/params.pp index feaf4d5..f127fe1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -24,7 +24,8 @@ class mysql::params { $myisam_recover = 'BACKUP' $query_cache_limit = '1M' $query_cache_size = '16M' - + $expire_logs_days = 10 + $max_binlog_size = 100M case $::operatingsystem { 'Ubuntu': { diff --git a/spec/classes/mysql_config_spec.rb b/spec/classes/mysql_config_spec.rb index 002fc98..55726c9 100644 --- a/spec/classes/mysql_config_spec.rb +++ b/spec/classes/mysql_config_spec.rb @@ -3,27 +3,37 @@ describe 'mysql::config' do let :constant_parameter_defaults do { - :root_password => 'UNSET', - :old_root_password => '', - :bind_address => '127.0.0.1', - :port => '3306', - :etc_root_password => false, - :datadir => '/var/lib/mysql', - :default_engine => 'UNSET', - :ssl => false, - :key_buffer => '16M', - :max_allowed_packet => '16M', - :thread_stack => '256K', - :thread_cache_size => 8, - :myisam_recover => 'BACKUP', - :query_cache_limit => '1M', - :query_cache_size => '16M', - :character_set => 'UNSET', - :max_connections => 'UNSET', - :tmp_table_size => 'UNSET', - :max_heap_table_size => 'UNSET', - :table_open_cache => 'UNSET', - :long_query_time => 'UNSET', + :root_password => 'UNSET', + :old_root_password => '', + :bind_address => '127.0.0.1', + :port => '3306', + :etc_root_password => false, + :datadir => '/var/lib/mysql', + :default_engine => 'UNSET', + :ssl => false, + :key_buffer => '16M', + :max_allowed_packet => '16M', + :thread_stack => '256K', + :thread_cache_size => 8, + :myisam_recover => 'BACKUP', + :query_cache_limit => '1M', + :query_cache_size => '16M', + :max_binlog_size => '100M', + :expire_logs_days => 10, + :character_set => 'UNSET', + :max_connections => 'UNSET', + :tmp_table_size => 'UNSET', + :max_heap_table_size => 'UNSET', + :table_open_cache => 'UNSET', + :long_query_time => 'UNSET', + :server_id => 'UNSET', + :sql_log_bin => 'UNSET', + :log_bin => 'UNSET', + :binlog_do_db => 'UNSET', + :log_bin_trust_function_creators => 'UNSET', + :replicate_ignore_table => 'UNSET', + :replicate_wild_do_table => 'UNSET', + :replicate_wild_ignore_table => 'UNSET', } end @@ -178,14 +188,16 @@ describe 'mysql::config' do "socket = #{param_values[:socket]}", "pid-file = #{param_values[:pidfile]}", "datadir = #{param_values[:datadir]}", - "bind-address = #{param_values[:bind_address]}", - "key_buffer = #{param_values[:key_buffer]}", - "max_allowed_packet = #{param_values[:max_allowed_packet]}", - "thread_stack = #{param_values[:thread_stack]}", - "thread_cache_size = #{param_values[:thread_cache_size]}", - "myisam-recover = #{param_values[:myisam_recover]}", - "query_cache_limit = #{param_values[:query_cache_limit]}", - "query_cache_size = #{param_values[:query_cache_size]}", + "bind-address = #{param_values[:bind_address]}", + "key_buffer = #{param_values[:key_buffer]}", + "max_allowed_packet = #{param_values[:max_allowed_packet]}", + "thread_stack = #{param_values[:thread_stack]}", + "thread_cache_size = #{param_values[:thread_cache_size]}", + "myisam-recover = #{param_values[:myisam_recover]}", + "query_cache_limit = #{param_values[:query_cache_limit]}", + "query_cache_size = #{param_values[:query_cache_size]}", + "expire_logs_days = #{param_values[:expire_logs_days]}", + "max_binlog_size = #{param_values[:max_binlog_size]}", ] if param_values[:max_connections] != 'UNSET' expected_lines = expected_lines | [ "max_connections = #{param_values[:max_connections]}" ] @@ -208,6 +220,27 @@ describe 'mysql::config' do if param_values[:character_set] != 'UNSET' expected_lines = expected_lines | [ "character-set-server = #{param_values[:character_set]}" ] end + if param_values[:sql_log_bin] != 'UNSET' + expected_lines = expected_lines | [ "sql_log_bin = #{param_values[:sql_log_bin]}" ] + end + if param_values[:log_bin] != 'UNSET' + expected_lines = expected_lines | [ "log-bin = #{param_values[:log_bin]}" ] + end + if param_values[:binlog_do_db] != 'UNSET' + expected_lines = expected_lines | [ "binlog-do-db = #{param_values[:binlog_do_db]}" ] + end + if param_values[:log_bin_trust_function_creators] != 'UNSET' + expected_lines = expected_lines | [ "log_bin_trust_function_creators = #{param_values[:log_bin_trust_function_creators]}" ] + end + if param_values[:replicate_ignore_table] != 'UNSET' + expected_lines = expected_lines | [ "replicate-ignore-table = #{param_values[:replicate_ignore_table]}" ] + end + if param_values[:replicate_wild_do_table] != 'UNSET' + expected_lines = expected_lines | [ "replicate-wild-do-table = #{param_values[:replicate_wild_do_table]}" ] + end + if param_values[:replicate_wild_ignore_table] != 'UNSET' + expected_lines = expected_lines | [ "replicate-wild-ignore-table = #{param_values[:replicate_wild_ignore_table]}" ] + end if param_values[:ssl] expected_lines = expected_lines | [ diff --git a/templates/my.cnf.erb b/templates/my.cnf.erb index 78b50ca..4569b89 100644 --- a/templates/my.cnf.erb +++ b/templates/my.cnf.erb @@ -20,17 +20,18 @@ datadir = <%= datadir %> tmpdir = /tmp skip-external-locking -<% if bind_address %> -bind-address = <%= bind_address %> -<% end %> - -key_buffer = <%= key_buffer %> -max_allowed_packet = <%= max_allowed_packet %> -thread_stack = <%= thread_stack %> -thread_cache_size = <%= thread_cache_size %> -myisam-recover = <%= myisam_recover %> -query_cache_limit = <%= query_cache_limit %> -query_cache_size = <%= query_cache_size %> +<% if bind_address -%> +bind-address = <%= bind_address %> +<% end -%> +key_buffer = <%= key_buffer %> +max_allowed_packet = <%= max_allowed_packet %> +thread_stack = <%= thread_stack %> +thread_cache_size = <%= thread_cache_size %> +myisam-recover = <%= myisam_recover %> +query_cache_limit = <%= query_cache_limit %> +query_cache_size = <%= query_cache_size %> +expire_logs_days = <%= expire_logs_days %> +max_binlog_size = <%= max_binlog_size %> <% if max_connections != 'UNSET' -%> max_connections = <%= max_connections %> @@ -47,12 +48,34 @@ table_open_cache = <%= table_open_cache %> <% if long_query_time != 'UNSET' -%> long_query_time = <%= long_query_time %> <% end -%> +<% if server_id != 'UNSET' -%> +server-id = <%= server_id %> +<% end -%> +<% if sql_log_bin != 'UNSET' -%> +sql_log_bin = <%= sql_log_bin %> +<% end -%> +<% if log_bin != 'UNSET' -%> +log-bin = <%= log_bin %> +<% end -%> +<% if binlog_do_db != 'UNSET' -%> +binlog-do-db = <%= binlog_do_db %> +<% end -%> +<% if log_bin_trust_function_creators != 'UNSET' -%> +log_bin_trust_function_creators = <%= log_bin_trust_function_creators %> +<% end -%> +<% if replicate_ignore_table != 'UNSET' -%> +replicate-ignore-table = <%= replicate_ignore_table %> +<% end -%> +<% if replicate_wild_do_table != 'UNSET' -%> +replicate-wild-do-table = <%= replicate_wild_do_table %> +<% end -%> +<% if replicate_wild_ignore_table != 'UNSET' -%> +replicate-wild-ignore-table = <%= replicate_wild_ignore_table %> +<% end -%> <% if log_error != 'syslog' -%> -log_error = <%= log_error %> +log_error = <%= log_error %> <% end -%> -expire_logs_days = 10 -max_binlog_size = 100M <% if default_engine != 'UNSET' %> default-storage-engine = <%= default_engine %> <% end -%> From a171c52a8918ad36f28c50018438cc84a75bc761 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Tue, 21 May 2013 01:21:38 +0400 Subject: [PATCH 4/7] * Puppet 2.6 fix --- .fixtures.yml | 1 - manifests/config.pp | 2 +- spec/classes/mysql_config_spec.rb | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 395fdfe..cecf6f5 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,6 +1,5 @@ fixtures: repositories: "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib" - "create_resources": "git://github.com/puppetlabs/puppetlabs-create_resources.git" symlinks: "mysql": "#{source_dir}" diff --git a/manifests/config.pp b/manifests/config.pp index 657361a..84e90ad 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -125,7 +125,7 @@ class mysql::config( $log_bin_trust_function_creators = 'UNSET', $replicate_ignore_table = 'UNSET', $replicate_wild_do_table = 'UNSET', - $replicate_wild_ignore_table = 'UNSET', + $replicate_wild_ignore_table = 'UNSET' ) inherits mysql::params { File { diff --git a/spec/classes/mysql_config_spec.rb b/spec/classes/mysql_config_spec.rb index 55726c9..358df67 100644 --- a/spec/classes/mysql_config_spec.rb +++ b/spec/classes/mysql_config_spec.rb @@ -33,7 +33,7 @@ describe 'mysql::config' do :log_bin_trust_function_creators => 'UNSET', :replicate_ignore_table => 'UNSET', :replicate_wild_do_table => 'UNSET', - :replicate_wild_ignore_table => 'UNSET', + :replicate_wild_ignore_table => 'UNSET' } end @@ -133,7 +133,7 @@ describe 'mysql::config' do :tmp_table_size => '4096M', :max_heap_table_size => '4096M', :table_open_cache => 2048, - :long_query_time => 0.5, + :long_query_time => 0.5 } ].each do |passed_params| @@ -197,7 +197,7 @@ describe 'mysql::config' do "query_cache_limit = #{param_values[:query_cache_limit]}", "query_cache_size = #{param_values[:query_cache_size]}", "expire_logs_days = #{param_values[:expire_logs_days]}", - "max_binlog_size = #{param_values[:max_binlog_size]}", + "max_binlog_size = #{param_values[:max_binlog_size]}" ] if param_values[:max_connections] != 'UNSET' expected_lines = expected_lines | [ "max_connections = #{param_values[:max_connections]}" ] From 6c81ea0d24affb83849f6894f7d1c2808ea5c5a3 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Sun, 16 Jun 2013 19:41:29 +0400 Subject: [PATCH 5/7] * Trying fix unit tests for Travis --- .fixtures.yml | 1 + spec/classes/mysql_config_spec.rb | 5 ++++- templates/my.cnf.erb | 15 ++++++++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index cecf6f5..1ec2306 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,5 +1,6 @@ fixtures: repositories: "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib" + "create_resources": "git://github.com/puppetlabs/puppetlabs-create_resources.git" symlinks: "mysql": "#{source_dir}" diff --git a/spec/classes/mysql_config_spec.rb b/spec/classes/mysql_config_spec.rb index 953c287..3b882ba 100644 --- a/spec/classes/mysql_config_spec.rb +++ b/spec/classes/mysql_config_spec.rb @@ -56,7 +56,7 @@ describe 'mysql::config' do :config_file => '/var/db/mysql/my.cnf', :socket => '/tmp/mysql.sock', :pidfile => '/var/db/mysql/mysql.pid', - :root_group => 'wheel', + :root_group => 'wheel' }, 'Redhat' => { :datadir => '/var/lib/mysql', @@ -128,6 +128,9 @@ describe 'mysql::config' do :ssl_ca => '/path/to/cacert.pem', :ssl_cert => '/path/to/server-cert.pem', :ssl_key => '/path/to/server-key.pem', + :key_buffer => '16M', + :thread_stack => '256K', + :query_cache_size => '16M', :character_set => 'utf8', :max_connections => 1000, :tmp_table_size => '4096M', diff --git a/templates/my.cnf.erb b/templates/my.cnf.erb index d27073a..daec8ea 100644 --- a/templates/my.cnf.erb +++ b/templates/my.cnf.erb @@ -1,9 +1,10 @@ [client] -port = <%= port %> -socket = <%= socket %> +port = <%= @port %> +socket = <%= @socket %> <% if @character_set != 'UNSET' -%> default-character-set = <%= @character_set %> -<% end %> +<% end -%> + [mysqld_safe] socket = <%= @socket %> nice = 0 @@ -20,7 +21,7 @@ datadir = <%= @datadir %> tmpdir = /tmp skip-external-locking -<% if bind_address -%> +<% if @bind_address -%> bind-address = <%= @bind_address %> <% end -%> key_buffer = <%= @key_buffer %> @@ -73,10 +74,10 @@ replicate-wild-do-table = <%= @replicate_wild_do_table %> replicate-wild-ignore-table = <%= @replicate_wild_ignore_table %> <% end -%> -<% if log_error != 'syslog' -%> -log_error = <%= log_error %> +<% if @log_error != 'syslog' -%> +log_error = <%= @log_error %> <% end -%> -<% if default_engine != 'UNSET' %> +<% if @default_engine != 'UNSET' %> default-storage-engine = <%= @default_engine %> <% end -%> <% if @character_set != 'UNSET' -%> From fad4f06cb251bf4c258ad9c23d45c29f9fb4ea59 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Mon, 17 Jun 2013 18:04:55 +0400 Subject: [PATCH 6/7] * Fixing lint warnings --- manifests/config.pp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index bbf413d..583d68c 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -23,8 +23,8 @@ # client character set # [*key_buffer] - Index blocks for MyISAM tables are buffered and # are shared by all threads. key_buffer_size is the size of the buffer used -# for index blocks. -# [*max_allowed_packet] - The maximum size of one packet or any +# for index blocks. +# [*max_allowed_packet] - The maximum size of one packet or any # generated/intermediate string, or any parameter sent by the # mysql_stmt_send_long_data() C API function. # [*thread_stack] - The stack size for each thread. @@ -43,18 +43,18 @@ # [*table_open_cache] - The number of open tables for all threads. # [*long_query_time] - If a query takes longer than this many seconds, # the server increments the Slow_queries status variable. -# [*server_id] - The server ID, used in replication to give each +# [*server_id] - The server ID, used in replication to give each # master and slave a unique identity. -# [*sql_log_bin] - This variable controls whether logging to the -# binary log is done. The default value is 1. +# [*sql_log_bin] - This variable controls whether logging to the +# binary log is done. The default value is 1. # [*log_bin] - Enable binary logging. The server logs all -# statements that change data to the binary log, which is used for backup +# statements that change data to the binary log, which is used for backup # and replication. # [*max_binlog_size] - If a write to the binary log causes the current -# log file size to exceed the value of this variable, the server rotates +# log file size to exceed the value of this variable, the server rotates # the binary logs (closes the current file and opens the next one). # [*binlog_do_db] - This option affects binary logging in a manner -# similar to the way that --replicate-do-db affects replication. +# similar to the way that --replicate-do-db affects replication. # [*expire_logs_days] - The number of days for automatic binary log file # removal. # [*log_bin_trust_function_creators] - It controls whether stored function From 4d9e9a50ae33574c5fa51a02d9409dbbf8c3bc70 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Mon, 17 Jun 2013 18:07:21 +0400 Subject: [PATCH 7/7] * Fixing lint warnings --- .fixtures.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.fixtures.yml b/.fixtures.yml index 1ec2306..395fdfe 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,6 +1,6 @@ fixtures: repositories: "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib" - "create_resources": "git://github.com/puppetlabs/puppetlabs-create_resources.git" + "create_resources": "git://github.com/puppetlabs/puppetlabs-create_resources.git" symlinks: "mysql": "#{source_dir}"