From 4c1528963e5b4c6706b21184f6de5e5db5223f0d Mon Sep 17 00:00:00 2001 From: Patrick McCarren Date: Tue, 31 Mar 2015 16:28:32 -0400 Subject: [PATCH 001/300] Added additional configuration options * table_definition_cache * sysdate_is_now * query_cache_type * log_queries_not_using_indexes * binlog_rows_query_log_events * gtid_mode * enforce_gtid_consistency * binlog_checksum * sync_master_info * sync_relay_log * sync_relay_log_info * master_verify_checksum * slave_net_timeout * slave_sql_verify_checksum --- attributes/default.rb | 14 +++++++++ templates/default/my.cnf.cluster.erb | 39 +++++++++++++++++++++-- templates/default/my.cnf.main.erb | 46 ++++++++++++++++++++++++++-- 3 files changed, 94 insertions(+), 5 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 439fbcd8..160a58de 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -104,13 +104,16 @@ default["percona"]["server"]["max_connect_errors"] = 9_999_999 default["percona"]["server"]["sql_modes"] = [] default["percona"]["server"]["table_cache"] = 8192 +default["percona"]["server"]["table_definition_cache"] = "-1" default["percona"]["server"]["group_concat_max_len"] = 4096 default["percona"]["server"]["expand_fast_index_creation"] = false default["percona"]["server"]["read_rnd_buffer_size"] = 262_144 +default["percona"]["server"]["sysdate_is_now"] = false # Query Cache Configuration default["percona"]["server"]["query_cache_size"] = "64M" default["percona"]["server"]["query_cache_limit"] = "2M" +default["percona"]["server"]["query_cache_type"] = "1" # Logging and Replication default["percona"]["server"]["sync_binlog"] = (node["percona"]["server"]["role"] == "cluster" ? 0 : 1) @@ -118,18 +121,29 @@ default["percona"]["server"]["slow_query_logdir"] = "/var/log/mysql" default["percona"]["server"]["slow_query_log_file"] = "#{node["percona"]["server"]["slow_query_logdir"]}/mysql-slow.log" default["percona"]["server"]["long_query_time"] = 2 +default["percona"]["server"]["log_queries_not_using_indexes"] = 0 default["percona"]["server"]["server_id"] = 1 +default["percona"]["server"]["binlog_rows_query_log_events"] = false default["percona"]["server"]["binlog_do_db"] = [] default["percona"]["server"]["expire_logs_days"] = 10 +default["percona"]["server"]["gtid_mode"] = "OFF" +default["percona"]["server"]["enforce_gtid_consistency"] = false default["percona"]["server"]["max_binlog_size"] = "100M" default["percona"]["server"]["binlog_cache_size"] = "1M" default["percona"]["server"]["binlog_format"] = "MIXED" +default["percona"]["server"]["binlog_checksum"] = "CRC32" default["percona"]["server"]["log_bin"] = "master-bin" default["percona"]["server"]["relay_log"] = "slave-relay-bin" default["percona"]["server"]["log_slave_updates"] = false default["percona"]["server"]["log_warnings"] = true default["percona"]["server"]["log_long_format"] = false default["percona"]["server"]["bulk_insert_buffer_size"] = "64M" +default["percona"]["server"]["sync_master_info"] = false +default["percona"]["server"]["sync_relay_log"] = false +default["percona"]["server"]["sync_relay_log_info"] = false +default["percona"]["server"]["master_verify_checksum"] = false +default["percona"]["server"]["slave_net_timeout"] = 3600 +default["percona"]["server"]["slave_sql_verify_checksum"] = false # MyISAM Specific default["percona"]["server"]["myisam_recover_options"] = "BACKUP" diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index dac3d43d..8d36b3ae 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -55,6 +55,10 @@ slave_load_tmpdir = <%= node["percona"]["server"]["tmpdir"] %> character_set_server = <%= node["percona"]["server"]["character_set"] %> collation_server = <%= node["percona"]["server"]["collation"] %> +<% unless node["percona"]["server"]["report_host"].enpty? %> +report-host = <%= node["percona"]["server"]["report_host"] %> +<% end %> + <% if node["percona"]["server"]["federated"] %> federated <% end %> @@ -224,6 +228,7 @@ sql-mode = <%= node["percona"]["server"]["sql_modes"].join(",") %> # mysqld_safe section <%- if node["percona"]["version"] >= "5.6" %> table_open_cache = <%= node["percona"]["server"]["table_cache"] %> +table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- else %> table_cache = <%= node["percona"]["server"]["table_cache"] %> <%- end %> @@ -235,6 +240,7 @@ table_cache = <%= node["percona"]["server"]["table_cache"] %> # query_cache_limit = <%= node["percona"]["server"]["query_cache_limit"] %> query_cache_size = <%= node["percona"]["server"]["query_cache_size"] %> +query_cache_type = <%= node["percona"]["server"]["query_cache_type"] %> # # * Logging and Replication @@ -269,8 +275,10 @@ slow_query_log_file = <%= node["percona"]["server"]["slow_query_log_file"] %> # currently measures time with second accuracy only). long_query_time = <%= node["percona"]["server"]["long_query_time"] %> -# log-queries-not-using-indexes -# +<% if node["percona"]["server"]["log_queries_not_using_indexes"] %> +log-queries-not-using-indexes = <%= node["percona"]["server"]["log_queries_not_using_indexes"] %> +<% end %> + # The following can be used as easy to replay backup logs or for replication. # note: if you are setting up a replication slave, see README.Debian about # other settings you may need to change. @@ -318,11 +326,38 @@ log_bin = <%= node["percona"]["server"]["datadir"] %>/mysql-bin.log expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> +binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> +slave_net_timeout = <%= node["percona"]["server"]["master_verify_checksum"] %> +<% if node["percona"]["server"]["master_verify_checksum"] %> +master_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> +<% end %> +<% if node["percona"]["server"]["slave_sql_verify_checksum"] %> +slave_sql_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> +<% end %> + +<% if node["percona"]["server"]["binlog_rows_query_log_events"] %> +binlog_rows_query_log_events +<% end %> <% node["percona"]["server"]["binlog_do_db"].each do |db_name| %> binlog-do-db = <%= db_name %> <% end -%> +gtid_mode <%= node["percona"]["server"]["gtid_mode"] %> +<% if node["percona"]["server"]["enforce_gtid_consistency"] %> +enforce_gtid_consistency <%= node["percona"]["server"]["enforce_gtid_consistency"] %> +<% end %> + +<% if node["percona"]["server"]["sync_master_info"] %> +sync_master_info = <%= node["percona"]["server"]["sync_master_info"] %> +<% end %> +<% if node["percona"]["server"]["sync_relay_log"] %> +sync_relay_log = <%= node["percona"]["server"]["sync_relay_log"] %> +<% end %> +<% if node["percona"]["server"]["sync_relay_log_info"] %> +sync_relay_log_info = <%= node["percona"]["server"]["sync_relay_log_info"] %> +<% end %> + # The size of the cache to hold the SQL statements for the binary log # during a transaction. If you often use big, multi-statement # transactions you can increase this value to get more performance. All diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 7a861b5f..0440bca3 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -58,6 +58,10 @@ slave_load_tmpdir = <%= node["percona"]["server"]["tmpdir"] %> character_set_server = <%= node["percona"]["server"]["character_set"] %> collation_server = <%= node["percona"]["server"]["collation"] %> +<% unless node["percona"]["server"]["report_host"].empty? %> +report-host = <%= node["percona"]["server"]["report_host"] %> +<% end %> + <% if node["percona"]["server"]["federated"] %> federated <% end %> @@ -93,6 +97,9 @@ performance_schema=<%= node["percona"]["server"]["performance_schema"] ? "ON" : # * Fine Tuning # + +sysdate_is_now = <%= node["percona"]["server"]["sysdate_is_now"] %> + key_buffer_size = <%= node["percona"]["server"]["key_buffer_size"] %> # The maximum size of a query packet the server can handle as well as @@ -192,6 +199,7 @@ myisam-recover-options = <%= node["percona"]["server"]["myisam_recover_options"] back_log = <%= node["percona"]["server"]["back_log"] %> max_connections = <%= node["percona"]["server"]["max_connections"] %> + # I don't know why 0 doesn't disable max_connect_errors checking # but it doesn't, so set it to a high value to prevent MySQL from # refusing to accept connections from a flaky host, especially if you @@ -207,6 +215,7 @@ sql-mode = <%= node["percona"]["server"]["sql_modes"].join(",") %> # mysqld_safe section <%- if node["percona"]["version"] >= "5.6" %> table_open_cache = <%= node["percona"]["server"]["table_cache"] %> +table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- else %> table_cache = <%= node["percona"]["server"]["table_cache"] %> <%- end %> @@ -232,6 +241,9 @@ query_cache_size = <%= node["percona"]["server"]["query_cache_size"] %> # other query results. query_cache_limit = <%= node["percona"]["server"]["query_cache_limit"] %> +query_cache_type = <%= node["percona"]["server"]["query_cache_type"] %> + + # # * Logging and Replication # @@ -265,8 +277,10 @@ slow_query_log_file = <%= node["percona"]["server"]["slow_query_log_file"] %> # currently measures time with second accuracy only). long_query_time = <%= node["percona"]["server"]["long_query_time"] %> -# log-queries-not-using-indexes -# +<% if node["percona"]["server"]["log_queries_not_using_indexes"] %> +log-queries-not-using-indexes = <%= node["percona"]["server"]["log_queries_not_using_indexes"] %> +<% end %> + # The following can be used as easy to replay backup logs or for replication. # note: if you are setting up a replication slave, see README.Debian about # other settings you may need to change. @@ -314,11 +328,38 @@ log_bin = <%= node["percona"]["server"]["datadir"] %>/mysql-bin.log expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> +binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> +slave_net_timeout = <%= node["percona"]["server"]["master_verify_checksum"] %> +<% if node["percona"]["server"]["master_verify_checksum"] %> +master_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> +<% end %> +<% if node["percona"]["server"]["slave_sql_verify_checksum"] %> +slave_sql_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> +<% end %> + +<% if node["percona"]["server"]["binlog_rows_query_log_events"] %> +binlog_rows_query_log_events +<% end %> <% node["percona"]["server"]["binlog_do_db"].each do |db_name| %> binlog-do-db = <%= db_name %> <% end -%> +gtid_mode <%= node["percona"]["server"]["gtid_mode"] %> +<% if node["percona"]["server"]["enforce_gtid_consistency"] %> +enforce_gtid_consistency <%= node["percona"]["server"]["enforce_gtid_consistency"] %> +<% end %> + +<% if node["percona"]["server"]["sync_master_info"] %> +sync_master_info = <%= node["percona"]["server"]["sync_master_info"] %> +<% end %> +<% if node["percona"]["server"]["sync_relay_log"] %> +sync_relay_log = <%= node["percona"]["server"]["sync_relay_log"] %> +<% end %> +<% if node["percona"]["server"]["sync_relay_log_info"] %> +sync_relay_log_info = <%= node["percona"]["server"]["sync_relay_log_info"] %> +<% end %> + # The size of the cache to hold the SQL statements for the binary log # during a transaction. If you often use big, multi-statement # transactions you can increase this value to get more performance. All @@ -343,7 +384,6 @@ log-bin = <%= node["percona"]["server"]["log_bin"] %> relay-log = <%= node["percona"]["server"]["relay_log"] %> <% end %> - # If you're using replication with chained slaves (A->B->C), you need to # enable this option on server B. It enables logging of updates done by # the slave thread into the slave's binary log. From ca668fac9632d4cb6a4557f22ac798bb7a28516f Mon Sep 17 00:00:00 2001 From: Patrick McCarren Date: Tue, 31 Mar 2015 16:32:22 -0400 Subject: [PATCH 002/300] Bump version to 0.16.1 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index c23665d4..4ceb8821 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license "MIT" description "Installs Percona MySQL client and server" long_description "Please refer to README.md" -version "0.16.0" +version "0.16.1" recipe "percona", "Includes the client recipe to configure a client" recipe "percona::package_repo", "Sets up the package repository and installs dependent packages" From b79dc3fb644848ca9809e4d2627e214f08911f26 Mon Sep 17 00:00:00 2001 From: Patrick McCarren Date: Tue, 31 Mar 2015 17:00:22 -0400 Subject: [PATCH 003/300] Fix gtid assignment typo --- templates/default/my.cnf.cluster.erb | 4 ++-- templates/default/my.cnf.main.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index 8d36b3ae..1368c852 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -343,9 +343,9 @@ binlog_rows_query_log_events binlog-do-db = <%= db_name %> <% end -%> -gtid_mode <%= node["percona"]["server"]["gtid_mode"] %> +gtid_mode = <%= node["percona"]["server"]["gtid_mode"] %> <% if node["percona"]["server"]["enforce_gtid_consistency"] %> -enforce_gtid_consistency <%= node["percona"]["server"]["enforce_gtid_consistency"] %> +enforce_gtid_consistency = <%= node["percona"]["server"]["enforce_gtid_consistency"] %> <% end %> <% if node["percona"]["server"]["sync_master_info"] %> diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 0440bca3..621e85c1 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -345,9 +345,9 @@ binlog_rows_query_log_events binlog-do-db = <%= db_name %> <% end -%> -gtid_mode <%= node["percona"]["server"]["gtid_mode"] %> +gtid_mode = <%= node["percona"]["server"]["gtid_mode"] %> <% if node["percona"]["server"]["enforce_gtid_consistency"] %> -enforce_gtid_consistency <%= node["percona"]["server"]["enforce_gtid_consistency"] %> +enforce_gtid_consistency = <%= node["percona"]["server"]["enforce_gtid_consistency"] %> <% end %> <% if node["percona"]["server"]["sync_master_info"] %> From 8d618dae45e11b8e6f0b2d2fd6dbdf4a70e9dd1e Mon Sep 17 00:00:00 2001 From: Patrick McCarren Date: Tue, 31 Mar 2015 19:31:48 -0400 Subject: [PATCH 004/300] Fix typo in my.cnf.cluster.erb 'entpy' -> 'empty' --- templates/default/my.cnf.cluster.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index 1368c852..2b275f40 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -55,7 +55,7 @@ slave_load_tmpdir = <%= node["percona"]["server"]["tmpdir"] %> character_set_server = <%= node["percona"]["server"]["character_set"] %> collation_server = <%= node["percona"]["server"]["collation"] %> -<% unless node["percona"]["server"]["report_host"].enpty? %> +<% unless node["percona"]["server"]["report_host"].empty? %> report-host = <%= node["percona"]["server"]["report_host"] %> <% end %> From b5c04b7cc59b39684dbe7693b8b02f2cda1e31d1 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 22 May 2015 12:38:49 +0300 Subject: [PATCH 005/300] add replication_sql pat as attribute --- attributes/default.rb | 1 + recipes/replication.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index 439fbcd8..15d6802d 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -170,6 +170,7 @@ default["percona"]["server"]["replication"]["ignore_table"] = [] default["percona"]["server"]["replication"]["ssl_enabled"] = false default["percona"]["server"]["replication"]["suppress_1592"] = false +default["percona"]["server"]["replication"]["replication_sql"] = "/etc/mysql/replication.sql" # XtraBackup Settings default["percona"]["backup"]["configure"] = false diff --git a/recipes/replication.rb b/recipes/replication.rb index e80a7771..d485f33f 100644 --- a/recipes/replication.rb +++ b/recipes/replication.rb @@ -6,8 +6,8 @@ require "shellwords" passwords = EncryptedPasswords.new(node, node["percona"]["encrypted_data_bag"]) -replication_sql = "/etc/mysql/replication.sql" server = node["percona"]["server"] +replication_sql = server["replication"]["replication_sql"] # define access grants template replication_sql do From 2096c8d3be6e1159d3a8fffd02947178c13afd83 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 22 May 2015 14:34:34 +0300 Subject: [PATCH 006/300] add check to file exists --- recipes/replication.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/replication.rb b/recipes/replication.rb index d485f33f..9419ec34 100644 --- a/recipes/replication.rb +++ b/recipes/replication.rb @@ -18,7 +18,7 @@ mode "0600" sensitive true only_if do - server["replication"]["host"] != "" || server["role"].include?("master") + (server["replication"]["host"] != "" || server["role"].include?("master")) && !::File.exists?(replication_sql) end end From 69ae198bc39b12046126b351d06b501948c0fdb5 Mon Sep 17 00:00:00 2001 From: Antek Baranski Date: Fri, 5 Jun 2015 12:56:28 -0700 Subject: [PATCH 007/300] Clean up find replication_password Make replication_password follow the convention for how other find_password(s) are constructed, and let it use the node["percona"]["server"]['replication']['username'] attribute --- libraries/passwords.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/passwords.rb b/libraries/passwords.rb index 181bdfdf..ac707776 100644 --- a/libraries/passwords.rb +++ b/libraries/passwords.rb @@ -52,9 +52,7 @@ def old_passwords # password for user responsbile for replicating in master/slave environment def replication_password - find_password( - @mysql_item, "replication", node_server["replication"]["password"] - ) + find_password @mysql_item, node_server['replication']['username'], node_server['replication']["password"] end # password for user responsbile for running xtrabackup From 4fb0098117af20e7c664f7ba2757dfcbb4dc4c35 Mon Sep 17 00:00:00 2001 From: rgbml Date: Thu, 25 Jun 2015 17:38:14 +0200 Subject: [PATCH 008/300] fixed jemalloc_lib for ubuntu --- attributes/default.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 868c021c..3bd2fd08 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -62,8 +62,8 @@ default["percona"]["server"]["jemalloc_lib"] = value_for_platform_family( "debian" => value_for_platform( "ubuntu" => { - "trusty" => "/usr/lib/x86_64-linux-gnu/libjemalloc.so.1", - "precise" => "/usr/lib/libjemalloc.so.1" + "14.04" => "/usr/lib/x86_64-linux-gnu/libjemalloc.so.1", + "12.04" => "/usr/lib/libjemalloc.so.1" } ), "rhel" => "/usr/lib64/libjemalloc.so.1" From 2f9b2c589d16ad682b657af37f7eabeaa01dd107 Mon Sep 17 00:00:00 2001 From: Grant Ridder Date: Tue, 13 Oct 2015 10:21:35 -0700 Subject: [PATCH 009/300] Allow sst password to be loaded from an encrypted data bag --- recipes/configure_server.rb | 11 +++++++++++ templates/default/my.cnf.cluster.erb | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 5d385010..4070cede 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -118,6 +118,14 @@ include_recipe "percona::ssl" end +if Array(server["role"]).include?("cluster") + if node["percona"]["cluster"]["wsrep_sst_auth"] == "" + wsrep_sst_auth = "#{node["percona"]["backup"]["username"]}:#{passwords.backup_password}" # rubocop:disable LineLength + else + wsrep_sst_auth = node["percona"]["cluster"]["wsrep_sst_auth"] + end +end + # setup the main server config file template percona["main_config_file"] do if Array(server["role"]).include?("cluster") @@ -129,6 +137,9 @@ group "root" mode "0644" sensitive true + if Array(server["role"]).include?("cluster") + variables(wsrep_sst_auth: wsrep_sst_auth) + end notifies :run, "execute[setup mysql datadir]", :immediately if node["percona"]["auto_restart"] notifies :restart, "service[mysql]", :immediately diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index c8f4879b..705fadba 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -84,8 +84,8 @@ wsrep_sst_method = <%= node["percona"]["cluster"]["wsrep_sst_metho wsrep_node_name = <%= node["percona"]["cluster"]["wsrep_node_name"] %> wsrep_notify_cmd = <%= node["percona"]["cluster"]["wsrep_notify_cmd"] %> wsrep_sst_receive_address = <%= node["percona"]["cluster"]["wsrep_sst_receive_address"] %> -<% unless node["percona"]["cluster"]["wsrep_sst_auth"].empty? -%> -wsrep_sst_auth = <%= node["percona"]["cluster"]["wsrep_sst_auth"] %> +<% unless @wsrep_sst_auth.empty? -%> +wsrep_sst_auth = "<%= @wsrep_sst_auth %>" <% end -%> innodb_locks_unsafe_for_binlog = <%= node["percona"]["cluster"]["innodb_locks_unsafe_for_binlog"] %> innodb_autoinc_lock_mode = <%= node["percona"]["cluster"]["innodb_autoinc_lock_mode"] %> From 897b186df64eb4fc3d01365a7b67285c9ac9d87e Mon Sep 17 00:00:00 2001 From: Grant Ridder Date: Tue, 13 Oct 2015 12:44:50 -0700 Subject: [PATCH 010/300] Add SELinux module to allow SST to work Disabling SELinux (per https://www.percona.com/doc/percona-xtradb-cluster/5.6/howtos/centos_howto.html) is not always an option. This SELinux module allows SSTs and in turn a percona cluster to work with SELinux enabled. `node["percona"]["selinux_module_url"]` can be set to nil to disable the installation of this module. From https://github.com/gguillen/selinux_percona-pxc-56-cluster --- README.md | 3 +++ attributes/default.rb | 3 +++ recipes/configure_server.rb | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/README.md b/README.md index f18000f2..0a542219 100644 --- a/README.md +++ b/README.md @@ -263,6 +263,9 @@ default["percona"]["skip_configure"] = false # Start percona server on boot default["percona"]["server"]["enable"] = true +# SELinux module URL +default["percona"]["selinux_module_url"] = "https://github.com/gguillen/selinux_percona-pxc-56-cluster/raw/master/percona-pxc-56-cluster.pp" + # install vs. upgrade packages default["percona"]["server"]["package_action"] = "install" diff --git a/attributes/default.rb b/attributes/default.rb index 868c021c..d0d99181 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -17,6 +17,9 @@ # Always restart percona on configuration changes default["percona"]["auto_restart"] = true +# SELinux module URL +default["percona"]["selinux_module_url"] = "https://github.com/gguillen/selinux_percona-pxc-56-cluster/raw/master/percona-pxc-56-cluster.pp" + case node["platform_family"] when "debian" default["percona"]["server"]["socket"] = "/var/run/mysqld/mysqld.sock" diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 5d385010..419c6c58 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -8,6 +8,20 @@ conf = percona["conf"] mysqld = (conf && conf["mysqld"]) || {} +# setup SELinux if needed +semodule_filename = node["percona"]["selinux_module_url"].split("/")[-1] +semodule_filepath = "#{Chef::Config[:file_cache_path]}/#{semodule_filename}" +remote_file semodule_filepath do + source node["percona"]["selinux_module_url"] + only_if { semodule_filename && node["platform_family"] == "rhel" } +end + +execute "semodule-install-#{semodule_filename}" do + command "/usr/sbin/semodule -i #{semodule_filepath}" + only_if { semodule_filename && node["platform_family"] == "rhel" } + only_if { shell_out("/usr/sbin/semodule -l | grep '^#{semodule_filename.split(".")[0..-2]}\\s'").stdout == "" } # rubocop:disable LineLength +end + # install chef-vault if needed include_recipe "chef-vault" if node["percona"]["use_chef_vault"] From 14011b7d3f3990b36246b64d9f10758964f27c46 Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Wed, 28 Oct 2015 01:08:42 -0400 Subject: [PATCH 011/300] Fixed network ranges FYI, Localhost is 127.0.0.0/8, and you missed the 172.16.0.0/12 range for the private IP range. --- libraries/config_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/config_helper.rb b/libraries/config_helper.rb index de8966fe..27a4f5f9 100644 --- a/libraries/config_helper.rb +++ b/libraries/config_helper.rb @@ -16,12 +16,12 @@ def for(ipaddress) module_function :for def loopback?(address) - IPAddr.new("0.0.0.0/8").include?(address) + IPAddr.new("127.0.0.0/8").include?(address) end module_function :loopback? def private?(address) - [IPAddr.new("10.0.0.0/8"), IPAddr.new("192.168.0.0/16")].any? do |range| + [IPAddr.new("10.0.0.0/8"),IPAddr.new("172.16.0.0/12"), IPAddr.new("192.168.0.0/16")].any? do |range| range.include?(address) end end From 8f18a7dd398f74046b9883a190c3e465f28c71c8 Mon Sep 17 00:00:00 2001 From: Kyle McGovern Date: Wed, 28 Oct 2015 15:58:49 -0500 Subject: [PATCH 012/300] Update to allow for custom template source and cookbook location --- Gemfile | 2 +- attributes/default.rb | 3 +++ doc/dependency_decisions.yml | 5 +++++ recipes/configure_server.rb | 5 +++-- spec/configure_server_spec.rb | 12 +++++++++--- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 7a6aeaeb..f2e99bfe 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ gem "chef", "~> #{chef_version}" gem "chefspec", "~> 4.2.0" gem "chef-vault", "~> 2.6.0" -gem "berkshelf", "~> 3.2.4" +gem "berkshelf", "~> 4.0.1" gem "foodcritic", "~> 4.0.0" gem "license_finder", "~> 2.0.4" gem "rake", "~> 10.4.2" diff --git a/attributes/default.rb b/attributes/default.rb index 868c021c..f96d5058 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -35,6 +35,9 @@ "debian" => "/etc/mysql/my.cnf", "rhel" => "/etc/my.cnf" ) +default["percona"]["main_config_template"]["cookbook"] = "percona" +default["percona"]["main_config_template"]["source"]["default"] = "my.cnf.main.erb" +default["percona"]["main_config_template"]["source"]["cluster"] = "my.cnf.cluster.erb" default["percona"]["encrypted_data_bag"] = "passwords" default["percona"]["encrypted_data_bag_secret_file"] = "" default["percona"]["encrypted_data_bag_item_mysql"] = "mysql" diff --git a/doc/dependency_decisions.yml b/doc/dependency_decisions.yml index 1f819d69..a86cd1f9 100644 --- a/doc/dependency_decisions.yml +++ b/doc/dependency_decisions.yml @@ -49,3 +49,8 @@ - :who: Phil Cohen :why: :when: 2015-05-14 01:50:31.944663000 Z +- - :approve + - sfl + - :who: + :why: + :when: 2015-10-28 21:13:00.983615000 Z diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 5d385010..901bbf43 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -121,10 +121,11 @@ # setup the main server config file template percona["main_config_file"] do if Array(server["role"]).include?("cluster") - source "my.cnf.cluster.erb" + source node["percona"]["main_config_template"]["source"]["cluster"] else - source "my.cnf.main.erb" + source node["percona"]["main_config_template"]["source"]["default"] end + cookbook node["percona"]["main_config_template"]["cookbook"] owner "root" group "root" mode "0644" diff --git a/spec/configure_server_spec.rb b/spec/configure_server_spec.rb index cb801809..aae13bce 100644 --- a/spec/configure_server_spec.rb +++ b/spec/configure_server_spec.rb @@ -20,7 +20,9 @@ expect(chef_run).to create_template("/etc/mysql/my.cnf").with( owner: "root", group: "root", - mode: "0644" + mode: "0644", + cookbook: "percona", + source: "my.cnf.main.erb" ) expect(chef_run).to render_file("/etc/mysql/my.cnf").with_content( @@ -168,7 +170,9 @@ owner: "root", group: "root", mode: "0644", - sensitive: true + sensitive: true, + cookbook: "percona", + source: "my.cnf.main.erb" ) expect(chef_run).to render_file("/mysql/my.cnf").with_content( @@ -239,7 +243,9 @@ owner: "root", group: "root", mode: "0644", - sensitive: true + sensitive: true, + cookbook: "percona", + source: "my.cnf.main.erb" ) resource = chef_run.template("/etc/my.cnf") From 5374b203418fd27cfc048859409bb9e7ab7d7494 Mon Sep 17 00:00:00 2001 From: Brian Hays Date: Sat, 14 Nov 2015 13:11:11 -0500 Subject: [PATCH 013/300] remove toolkit workaround --- recipes/toolkit.rb | 7 ------- spec/toolkit_spec.rb | 9 --------- 2 files changed, 16 deletions(-) diff --git a/recipes/toolkit.rb b/recipes/toolkit.rb index fcced0fa..246908e4 100644 --- a/recipes/toolkit.rb +++ b/recipes/toolkit.rb @@ -5,13 +5,6 @@ include_recipe "percona::package_repo" -# Workaround a bug in the RPM packaging of percona-toolkit. Otherwise, it'll -# try to pull in Percona-Server-shared-51, which will conflict with 5.5. -# https://bugs.launchpad.net/percona-toolkit/+bug/1031427 -if platform_family?("rhel") && node["percona"]["version"].match(/5\.[15]/) - package "Percona-Server-shared-compat" -end - package "percona-toolkit" do options "--force-yes" if platform_family?("debian") end diff --git a/spec/toolkit_spec.rb b/spec/toolkit_spec.rb index c6ed13c0..96a2b9c6 100644 --- a/spec/toolkit_spec.rb +++ b/spec/toolkit_spec.rb @@ -1,10 +1,6 @@ require "spec_helper" describe "percona::toolkit" do - let(:centos_package) do - "Percona-Server-shared-compat" - end - let(:toolkit_package) do "percona-toolkit" end @@ -15,8 +11,6 @@ end specify do - expect(chef_run).to_not install_package(centos_package) - expect(chef_run).to install_package(toolkit_package) end end @@ -31,7 +25,6 @@ end specify do - expect(chef_run).to install_package(centos_package) expect(chef_run).to install_package(toolkit_package) end end @@ -45,8 +38,6 @@ end specify do - expect(chef_run).to_not install_package(centos_package) - expect(chef_run).to install_package(toolkit_package) end end From 57c9946cdc3c886308de6e19322ae0af4785467b Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Fri, 20 Nov 2015 14:07:23 +0100 Subject: [PATCH 014/300] remove devel packages, not needed - rpm collision with cluster packages --- attributes/client.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/attributes/client.rb b/attributes/client.rb index 6b55105e..cddfd438 100644 --- a/attributes/client.rb +++ b/attributes/client.rb @@ -31,11 +31,13 @@ when "rhel" if Array(node["percona"]["server"]["role"]).include?("cluster") default["percona"]["client"]["packages"] = %W[ - Percona-XtraDB-Cluster-devel-#{version} Percona-XtraDB-Cluster-client-#{version} + Percona-XtraDB-Cluster-client-#{version} ] + #Percona-XtraDB-Cluster-devel-#{version} else default["percona"]["client"]["packages"] = %W[ - Percona-Server-devel-#{version} Percona-Server-client-#{version} + Percona-Server-client-#{version} ] + #Percona-Server-devel-#{version} end end From 468ddb546281e14b3b132533a5bfd942dee6fddf Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Fri, 20 Nov 2015 14:08:36 +0100 Subject: [PATCH 015/300] workaround, as value_for_platform_family was failing --- recipes/cluster.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/cluster.rb b/recipes/cluster.rb index 8afb22d6..72d2c074 100644 --- a/recipes/cluster.rb +++ b/recipes/cluster.rb @@ -17,8 +17,8 @@ # set default package attributes version = node["percona"]["version"] node.default["percona"]["cluster"]["package"] = value_for_platform_family( - "debian" => "percona-xtradb-cluster-#{version.tr(".", "")}", - "rhel" => "Percona-XtraDB-Cluster-#{version.tr(".", "")}" + "rhel" => "Percona-XtraDB-Cluster-#{version.tr(".", "")}", + "debian" => "percona-xtradb-cluster-#{version.tr(".", "")}" ) # install packages From d04eda08f296b185865b932b918fa25c733a73ee Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 12:01:15 +0100 Subject: [PATCH 016/300] add addtributes, update comment of default vaues on others --- attributes/default.rb | 4 +++- templates/default/my.cnf.cluster.erb | 4 ++++ templates/default/my.cnf.main.erb | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index 868c021c..603d27a2 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -102,11 +102,12 @@ default["percona"]["server"]["sort_buffer_size"] = "8M" default["percona"]["server"]["join_buffer_size"] = "8M" default["percona"]["server"]["thread_cache_size"] = 16 -default["percona"]["server"]["back_log"] = 50 +default["percona"]["server"]["back_log"] = 50 # >= 5.6.6, -1 (autosized) default["percona"]["server"]["max_connections"] = 30 default["percona"]["server"]["max_connect_errors"] = 9_999_999 default["percona"]["server"]["sql_modes"] = [] default["percona"]["server"]["table_cache"] = 8192 +default["percona"]["server"]["table_definition_cache"] = 4096 # >= 5.6.8, Default -1 (autosized) default["percona"]["server"]["group_concat_max_len"] = 4096 default["percona"]["server"]["expand_fast_index_creation"] = false default["percona"]["server"]["read_rnd_buffer_size"] = 262_144 @@ -146,6 +147,7 @@ default["percona"]["server"]["skip_innodb"] = false default["percona"]["server"]["innodb_additional_mem_pool_size"] = "32M" default["percona"]["server"]["innodb_buffer_pool_size"] = "128M" +default["percona"]["server"]["innodb_buffer_pool_instances"] = 8 default["percona"]["server"]["innodb_data_file_path"] = "ibdata1:10M:autoextend" default["percona"]["server"]["innodb_autoextend_increment"] = "128M" default["percona"]["server"]["innodb_open_files"] = 2000 diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index c8f4879b..c75774d0 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -237,6 +237,8 @@ table_open_cache = <%= node["percona"]["server"]["table_cache"] %> table_cache = <%= node["percona"]["server"]["table_cache"] %> <%- end %> +table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> + #thread_concurrency = 10 # # @@ -427,6 +429,8 @@ innodb_additional_mem_pool_size = <%= node["percona"]["server"]["innodb_addition # This config file assumes a main memory of at least 8G innodb_buffer_pool_size = <%= node["percona"]["server"]["innodb_buffer_pool_size"] %> +innodb_buffer_pool_instances = <%= node["percona"]["server"]["innodb_buffer_pool_instances"] %> + # InnoDB stores data in one or more data files forming the tablespace. # If you have a single logical drive for your data, a single # autoextending file would be good enough. In other cases, a single file diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 652a01f3..7733c988 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -219,6 +219,8 @@ table_open_cache = <%= node["percona"]["server"]["table_cache"] %> table_cache = <%= node["percona"]["server"]["table_cache"] %> <%- end %> +table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> + #thread_concurrency = 10 # # * Query Cache Configuration @@ -458,6 +460,8 @@ innodb_additional_mem_pool_size = <%= node["percona"]["server"]["innodb_addition # This config file assumes a main memory of at least 8G innodb_buffer_pool_size = <%= node["percona"]["server"]["innodb_buffer_pool_size"] %> +innodb_buffer_pool_instances = <%= node["percona"]["server"]["innodb_buffer_pool_instances"] %> + # InnoDB stores data in one or more data files forming the tablespace. # If you have a single logical drive for your data, a single # autoextending file would be good enough. In other cases, a single file From 17a31cd25ec5b3927a605f8b9ed94819c32c2ae2 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 13:24:58 +0100 Subject: [PATCH 017/300] ootb - disable external selinux defintion in cfg --- attributes/default.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index 00b447ca..bb3fe9fd 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -18,7 +18,8 @@ default["percona"]["auto_restart"] = true # SELinux module URL -default["percona"]["selinux_module_url"] = "https://github.com/gguillen/selinux_percona-pxc-56-cluster/raw/master/percona-pxc-56-cluster.pp" +# If interested, use "https://github.com/gguillen/selinux_percona-pxc-56-cluster/raw/master/percona-pxc-56-cluster.pp" +default["percona"]["selinux_module_url"] = nil case node["platform_family"] when "debian" From 8e92d6f1ae3df0881681bebba8a1e589465b8b8a Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 13:31:29 +0100 Subject: [PATCH 018/300] remove improper configured sfl, anyway can't find it's being loaded --- doc/dependency_decisions.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/dependency_decisions.yml b/doc/dependency_decisions.yml index a86cd1f9..1f819d69 100644 --- a/doc/dependency_decisions.yml +++ b/doc/dependency_decisions.yml @@ -49,8 +49,3 @@ - :who: Phil Cohen :why: :when: 2015-05-14 01:50:31.944663000 Z -- - :approve - - sfl - - :who: - :why: - :when: 2015-10-28 21:13:00.983615000 Z From a75df3d17e464a307493dc5162b75ca04e917079 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 13:39:07 +0100 Subject: [PATCH 019/300] bump patch level version --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 6ea49054..a7bd2bbd 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license "MIT" description "Installs Percona MySQL client and server" long_description "Please refer to README.md" -version "0.16.1" +version "0.16.2" recipe "percona", "Includes the client recipe to configure a client" recipe "percona::package_repo", "Sets up the package repository and installs dependent packages" From 35059a4e389087b18cbedb564cf6b78b717e5f41 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 14:03:34 +0100 Subject: [PATCH 020/300] minor, fix syntax --- libraries/config_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/config_helper.rb b/libraries/config_helper.rb index 27a4f5f9..a3c2f5cc 100644 --- a/libraries/config_helper.rb +++ b/libraries/config_helper.rb @@ -21,7 +21,7 @@ def loopback?(address) module_function :loopback? def private?(address) - [IPAddr.new("10.0.0.0/8"),IPAddr.new("172.16.0.0/12"), IPAddr.new("192.168.0.0/16")].any? do |range| + [IPAddr.new("10.0.0.0/8"), IPAddr.new("172.16.0.0/12"), IPAddr.new("192.168.0.0/16")].any? do |range| range.include?(address) end end From 66fe2ace5c5e3e9b33636ccf1b950f187675719a Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 14:09:00 +0100 Subject: [PATCH 021/300] add skip-syslog option --- attributes/default.rb | 3 +++ templates/default/my.cnf.cluster.erb | 3 +++ templates/default/my.cnf.main.erb | 3 +++ 3 files changed, 9 insertions(+) diff --git a/attributes/default.rb b/attributes/default.rb index 868c021c..faf25fbd 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -180,6 +180,9 @@ default["percona"]["server"]["replication"]["replication_sql"] = "/etc/mysql/replication.sql" default["percona"]["server"]["replication"]["slave_transaction_retries"] = 10 +# Mysqld_safe +default["percona"]["server"]["skip_syslog"] = false + # XtraBackup Settings default["percona"]["backup"]["configure"] = false default["percona"]["backup"]["username"] = "backup" diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index c8f4879b..957c41cb 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -32,6 +32,9 @@ open-files-limit = <%= node["percona"]["server"]["open_files_limit"] %> <% if node["percona"]["server"]["jemalloc"] %> malloc-lib = <%= node["percona"]["server"]["jemalloc_lib"] %> <% end %> +<% if node["percona"]["server"]["skip_syslog"] %> +skip-syslog +<% end %> # *** Application-specific options follow here *** diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 652a01f3..6aa98b62 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -35,6 +35,9 @@ open-files-limit = <%= node["percona"]["server"]["open_files_limit"] %> <% if node["percona"]["server"]["jemalloc"] %> malloc-lib = <%= node["percona"]["server"]["jemalloc_lib"] %> <% end %> +<% if node["percona"]["server"]["skip_syslog"] %> +skip-syslog +<% end %> # *** Application-specific options follow here *** From a458527086bb2a2a03c404c6d637498fae797d2a Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 16:37:59 +0100 Subject: [PATCH 022/300] fix selinux cfg, replacing nil by empty string --- attributes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index bb3fe9fd..7f3aab2f 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -19,7 +19,7 @@ # SELinux module URL # If interested, use "https://github.com/gguillen/selinux_percona-pxc-56-cluster/raw/master/percona-pxc-56-cluster.pp" -default["percona"]["selinux_module_url"] = nil +default["percona"]["selinux_module_url"] = "" case node["platform_family"] when "debian" From a6ecd8f8dbba502f23554485f63bc08f9dbaf180 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 16:37:59 +0100 Subject: [PATCH 023/300] fix selinux cfg, replacing nil by empty string --- recipes/configure_server.rb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index f18e890b..9daad331 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -9,17 +9,19 @@ mysqld = (conf && conf["mysqld"]) || {} # setup SELinux if needed -semodule_filename = node["percona"]["selinux_module_url"].split("/")[-1] -semodule_filepath = "#{Chef::Config[:file_cache_path]}/#{semodule_filename}" -remote_file semodule_filepath do - source node["percona"]["selinux_module_url"] - only_if { semodule_filename && node["platform_family"] == "rhel" } -end +unless node["percona"]["selinux_module_url"].nil? || node["percona"]["selinux_module_url"] == "" + semodule_filename = node["percona"]["selinux_module_url"].split("/")[-1] + semodule_filepath = "#{Chef::Config[:file_cache_path]}/#{semodule_filename}" + remote_file semodule_filepath do + source node["percona"]["selinux_module_url"] + only_if { semodule_filename && node["platform_family"] == "rhel" } + end -execute "semodule-install-#{semodule_filename}" do - command "/usr/sbin/semodule -i #{semodule_filepath}" - only_if { semodule_filename && node["platform_family"] == "rhel" } - only_if { shell_out("/usr/sbin/semodule -l | grep '^#{semodule_filename.split(".")[0..-2]}\\s'").stdout == "" } # rubocop:disable LineLength + execute "semodule-install-#{semodule_filename}" do + command "/usr/sbin/semodule -i #{semodule_filepath}" + only_if { semodule_filename && node["platform_family"] == "rhel" } + only_if { shell_out("/usr/sbin/semodule -l | grep '^#{semodule_filename.split(".")[0..-2]}\\s'").stdout == "" } # rubocop:disable LineLength + end end # install chef-vault if needed From 2ca9179e493e92d55f9df557302070339f45f9f8 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 17:09:14 +0100 Subject: [PATCH 024/300] minor, add vim tags to properly format indent in file --- templates/default/my.cnf.cluster.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index 62c99122..3f8e4b5a 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -592,3 +592,5 @@ key_buffer_size = <%= node["percona"]["server"]["key_buffer_size"] %> <% if !node["percona"]["server"]["includedir"].empty? %> !includedir <%= node["percona"]["server"]["includedir"] %> <% end %> + +# vim: ts=1 sts=2 From fa13d8eda483466ea6b1a96f0233310dfec98c6a Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 17:14:44 +0100 Subject: [PATCH 025/300] fix erb syntax --- templates/default/my.cnf.cluster.erb | 1 + templates/default/my.cnf.main.erb | 1 + 2 files changed, 2 insertions(+) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index 09c7d59e..d16192e4 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -367,6 +367,7 @@ binlog-do-db = <%= db_name %> <% node["percona"]["server"]["binlog_ignore_db"].each do |db_name| %> binlog-ignore-db = <%= db_name %> +<% end -%> gtid_mode = <%= node["percona"]["server"]["gtid_mode"] %> <% if node["percona"]["server"]["enforce_gtid_consistency"] %> diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 8e04a6c5..be6a7946 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -368,6 +368,7 @@ binlog-do-db = <%= db_name %> <% node["percona"]["server"]["binlog_ignore_db"].each do |db_name| %> binlog-ignore-db = <%= db_name %> +<% end -%> gtid_mode = <%= node["percona"]["server"]["gtid_mode"] %> <% if node["percona"]["server"]["enforce_gtid_consistency"] %> From ddc8c772feda410616153ade8ce1ede6318d8567 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 17:26:37 +0100 Subject: [PATCH 026/300] fix missing attribute in default --- attributes/default.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/attributes/default.rb b/attributes/default.rb index 67abf2c1..c3b3afff 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -90,6 +90,7 @@ default["percona"]["server"]["old_passwords"] = 0 default["percona"]["server"]["bind_address"] = "127.0.0.1" default["percona"]["server"]["federated"] = false +default["percona"]["server"]["report_host"] = "" %w[debian_password root_password].each do |attribute| next if attribute?(node["percona"]["server"][attribute]) @@ -201,6 +202,7 @@ default["percona"]["server"]["replication"]["replication_sql"] = "/etc/mysql/replication.sql" default["percona"]["server"]["replication"]["slave_transaction_retries"] = 10 + # XtraBackup Settings default["percona"]["backup"]["configure"] = false default["percona"]["backup"]["username"] = "backup" From f27703d787ccc85a61a2b6972cc2a1deb365054d Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 17:50:41 +0100 Subject: [PATCH 027/300] fix ootb binlog_format to ROW as supported on 5.5 version --- attributes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index bb3fe9fd..46391294 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -135,7 +135,7 @@ default["percona"]["server"]["expire_logs_days"] = 10 default["percona"]["server"]["max_binlog_size"] = "100M" default["percona"]["server"]["binlog_cache_size"] = "1M" -default["percona"]["server"]["binlog_format"] = "MIXED" +default["percona"]["server"]["binlog_format"] = "ROW" # Alt. MIXED default["percona"]["server"]["log_bin"] = "master-bin" default["percona"]["server"]["relay_log"] = "slave-relay-bin" default["percona"]["server"]["log_slave_updates"] = false From d605de898422234ced6355189c549b52b6b8d65e Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 17:58:51 +0100 Subject: [PATCH 028/300] fix attribute assigment --- templates/default/my.cnf.cluster.erb | 2 +- templates/default/my.cnf.main.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index d16192e4..1e519785 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -349,7 +349,7 @@ expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> -slave_net_timeout = <%= node["percona"]["server"]["master_verify_checksum"] %> +slave_net_timeout = <%= node["percona"]["server"]["slave_net_timeout"] %> <% if node["percona"]["server"]["master_verify_checksum"] %> master_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> <% end %> diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index be6a7946..f82b1924 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -350,7 +350,7 @@ expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> -slave_net_timeout = <%= node["percona"]["server"]["master_verify_checksum"] %> +slave_net_timeout = <%= node["percona"]["server"]["slave_net_timeout"] %> <% if node["percona"]["server"]["master_verify_checksum"] %> master_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> <% end %> From cf9479d51b2d01fd6277c2e687e71fe9edb65443 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 23 Nov 2015 18:18:19 +0100 Subject: [PATCH 029/300] configure checksum options only for >=56 --- templates/default/my.cnf.main.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index f82b1924..d258f520 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -349,14 +349,16 @@ log_bin = <%= node["percona"]["server"]["datadir"] %>/mysql-bin.log expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> +<%- if node["percona"]["version"] >= "5.6" %> binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> -slave_net_timeout = <%= node["percona"]["server"]["slave_net_timeout"] %> <% if node["percona"]["server"]["master_verify_checksum"] %> master_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> <% end %> <% if node["percona"]["server"]["slave_sql_verify_checksum"] %> slave_sql_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> <% end %> +<% end %> +slave_net_timeout = <%= node["percona"]["server"]["slave_net_timeout"] %> <% if node["percona"]["server"]["binlog_rows_query_log_events"] %> binlog_rows_query_log_events From 3c79587ad650e6e4ed04458d7bb8a0e65d9cc8fb Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Tue, 24 Nov 2015 10:53:03 +0100 Subject: [PATCH 030/300] configure checksum options only for >=56 --- templates/default/my.cnf.cluster.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index 1e519785..6f88ae43 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -350,12 +350,14 @@ max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> slave_net_timeout = <%= node["percona"]["server"]["slave_net_timeout"] %> +<%- if node["percona"]["version"] >= "5.6" %> <% if node["percona"]["server"]["master_verify_checksum"] %> master_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> <% end %> <% if node["percona"]["server"]["slave_sql_verify_checksum"] %> slave_sql_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> <% end %> +<% end %> <% if node["percona"]["server"]["binlog_rows_query_log_events"] %> binlog_rows_query_log_events From fd2191db49b5d1ec74e551f1134d0b2a57f2b717 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Tue, 24 Nov 2015 11:04:13 +0100 Subject: [PATCH 031/300] configure checksum options only for >=56 --- templates/default/my.cnf.cluster.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index bdf90a18..d69e2935 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -351,9 +351,9 @@ log_bin = <%= node["percona"]["server"]["datadir"] %>/mysql-bin.log expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> -binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> slave_net_timeout = <%= node["percona"]["server"]["slave_net_timeout"] %> <%- if node["percona"]["version"] >= "5.6" %> +binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> <% if node["percona"]["server"]["master_verify_checksum"] %> master_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> <% end %> From a0ca462ea0248764068aa5e7f7a9a4c4da4c206b Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Tue, 24 Nov 2015 11:05:07 +0100 Subject: [PATCH 032/300] configure checksum options only for >=56 --- templates/default/my.cnf.cluster.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index 6f88ae43..ac351d9c 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -348,9 +348,9 @@ log_bin = <%= node["percona"]["server"]["datadir"] %>/mysql-bin.log expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> -binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> slave_net_timeout = <%= node["percona"]["server"]["slave_net_timeout"] %> <%- if node["percona"]["version"] >= "5.6" %> +binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> <% if node["percona"]["server"]["master_verify_checksum"] %> master_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> <% end %> From 68104086965f0a86935889b26702950164d170ea Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Tue, 24 Nov 2015 11:10:11 +0100 Subject: [PATCH 033/300] configure options only for >=56 --- templates/default/my.cnf.cluster.erb | 2 ++ templates/default/my.cnf.main.erb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index ac351d9c..6bd0d923 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -371,10 +371,12 @@ binlog-do-db = <%= db_name %> binlog-ignore-db = <%= db_name %> <% end -%> +<%- if node["percona"]["version"] >= "5.6" %> gtid_mode = <%= node["percona"]["server"]["gtid_mode"] %> <% if node["percona"]["server"]["enforce_gtid_consistency"] %> enforce_gtid_consistency = <%= node["percona"]["server"]["enforce_gtid_consistency"] %> <% end %> +<% end %> <% if node["percona"]["server"]["sync_master_info"] %> sync_master_info = <%= node["percona"]["server"]["sync_master_info"] %> diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index d258f520..31b691d3 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -372,10 +372,12 @@ binlog-do-db = <%= db_name %> binlog-ignore-db = <%= db_name %> <% end -%> +<%- if node["percona"]["version"] >= "5.6" %> gtid_mode = <%= node["percona"]["server"]["gtid_mode"] %> <% if node["percona"]["server"]["enforce_gtid_consistency"] %> enforce_gtid_consistency = <%= node["percona"]["server"]["enforce_gtid_consistency"] %> <% end %> +<% end %> <% if node["percona"]["server"]["sync_master_info"] %> sync_master_info = <%= node["percona"]["server"]["sync_master_info"] %> From bfb55c9590519b96a1d8849396c1e67c03d8c8f8 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Wed, 10 Feb 2016 14:39:09 +0100 Subject: [PATCH 034/300] proper use of bin_log, bin-log and bin_log_basename over 5.5 and 5.6 --- attributes/default.rb | 3 +- templates/default/my.cnf.cluster.erb | 29 +++++++++++++++- templates/default/my.cnf.main.erb | 50 +++++++++++++++++++--------- 3 files changed, 65 insertions(+), 17 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 9479a6c8..2fe50195 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -144,7 +144,8 @@ default["percona"]["server"]["binlog_cache_size"] = "1M" default["percona"]["server"]["binlog_format"] = "ROW" # Alt. MIXED default["percona"]["server"]["binlog_checksum"] = "CRC32" -default["percona"]["server"]["log_bin"] = "master-bin" +default["percona"]["server"]["log_bin"] = 1 # enable/disable bin log +default["percona"]["server"]["log_bin_basename"] = "master-bin" # 5.6~> default: datadir + '/' + hostname + '-bin' default["percona"]["server"]["relay_log"] = "slave-relay-bin" default["percona"]["server"]["log_slave_updates"] = false default["percona"]["server"]["log_warnings"] = true diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index 8fcaea33..02fdf95f 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -347,7 +347,32 @@ skip-slave-start # stopping. slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_transaction_retries"] %> -log_bin = <%= node["percona"]["server"]["datadir"] %>/mysql-bin.log +# Bin log basename +# https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin_basename +# it is recommened to specify a filename for the binary log, hopefully +# something that is not host specific. I've chosen master-bin. +<%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') %> +log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> +<%- else %> + <%- unless [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> + <# from toady point log_bin attr. was missused in the cookbook in the past #> + <# and contained more or less the base-name #> +log-bin = <%= node["percona"]["server"]["log_bin"] %> + <%- else %> + # to allow on <= 5.5 useage of log_bin_basename + # introduced by this PR + <%- if node["percona"]["server"].key?('log_bin_basename') %> +log-bin = <%= node["percona"]["server"]["log_bin_basename"] %> + <%- end %> + <%- end %> +<%- end %> + +# Bin log on/off switch +# https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin +<%- if [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> +log_bin = <%= node["percona"]["server"]["log_bin"] %> +<%- end %> + expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> @@ -384,6 +409,8 @@ enforce_gtid_consistency = <%= node["percona"]["server"]["enforce_gtid_consisten <% if node["percona"]["server"]["sync_master_info"] %> sync_master_info = <%= node["percona"]["server"]["sync_master_info"] %> <% end %> + + <% if node["percona"]["server"]["sync_relay_log"] %> sync_relay_log = <%= node["percona"]["server"]["sync_relay_log"] %> <% end %> diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index b21e355d..0ba629ee 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -348,7 +348,41 @@ skip-slave-start # stopping. slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_transaction_retries"] %> -log_bin = <%= node["percona"]["server"]["datadir"] %>/mysql-bin.log + +# Enable binary logging. This is required for acting as a MASTER in a +# replication configuration. You also need the binary log if you need +# the ability to do point in time recovery from your latest backup. +# +# Bin log basename +# https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin_basename +# it is recommened to specify a filename for the binary log, hopefully +# something that is not host specific. I've chosen master-bin. +<%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') %> +log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> +<%- else %> + <%- unless [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> + <# from toady point log_bin attr. was missused in the cookbook in the past #> + <# and contained more or less the base-name #> +log-bin = <%= node["percona"]["server"]["log_bin"] %> + <%- else %> + # to allow on <= 5.5 useage of log_bin_basename + # introduced by this PR + <%- if node["percona"]["server"].key?('log_bin_basename') %> +log-bin = <%= node["percona"]["server"]["log_bin_basename"] %> + <%- end %> + <%- end %> +<%- end %> + +# Bin log on/off switch +# https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin +<%- if [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> +log_bin = <%= node["percona"]["server"]["log_bin"] %> +<%- end %> + +<% unless node["percona"]["server"]["relay_log"].empty? %> +relay-log = <%= node["percona"]["server"]["relay_log"] %> +<% end %> + expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> @@ -402,20 +436,6 @@ sync_relay_log_info = <%= node["percona"]["server"]["sync_relay_log_info"] %> # statement in transaction binlog_cache_size = <%= node["percona"]["server"]["binlog_cache_size"] %> -# Enable binary logging. This is required for acting as a MASTER in a -# replication configuration. You also need the binary log if you need -# the ability to do point in time recovery from your latest backup. - -# it is recommened to specify a filename for the binary log, hopefully -# something that is not host specific. I've chosen master-bin. -<% unless node["percona"]["server"]["log_bin"].empty? %> -log-bin = <%= node["percona"]["server"]["log_bin"] %> -<% end %> - -<% unless node["percona"]["server"]["relay_log"].empty? %> -relay-log = <%= node["percona"]["server"]["relay_log"] %> -<% end %> - # If you're using replication with chained slaves (A->B->C), you need to # enable this option on server B. It enables logging of updates done by # the slave thread into the slave's binary log. From 75b58d48e0005b9fa6ef9a5bbe0b2563e6425013 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Wed, 10 Feb 2016 14:39:09 +0100 Subject: [PATCH 035/300] proper use of bin_log, bin-log and bin_log_basename over 5.5 and 5.6 --- attributes/default.rb | 3 +- templates/default/my.cnf.cluster.erb | 37 +++++++++++++++++++- templates/default/my.cnf.main.erb | 50 +++++++++++++++++++--------- 3 files changed, 73 insertions(+), 17 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 9479a6c8..2fe50195 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -144,7 +144,8 @@ default["percona"]["server"]["binlog_cache_size"] = "1M" default["percona"]["server"]["binlog_format"] = "ROW" # Alt. MIXED default["percona"]["server"]["binlog_checksum"] = "CRC32" -default["percona"]["server"]["log_bin"] = "master-bin" +default["percona"]["server"]["log_bin"] = 1 # enable/disable bin log +default["percona"]["server"]["log_bin_basename"] = "master-bin" # 5.6~> default: datadir + '/' + hostname + '-bin' default["percona"]["server"]["relay_log"] = "slave-relay-bin" default["percona"]["server"]["log_slave_updates"] = false default["percona"]["server"]["log_warnings"] = true diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index 8fcaea33..12b3a6b0 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -347,7 +347,40 @@ skip-slave-start # stopping. slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_transaction_retries"] %> -log_bin = <%= node["percona"]["server"]["datadir"] %>/mysql-bin.log +# Enable binary logging. This is required for acting as a MASTER in a +# replication configuration. You also need the binary log if you need +# the ability to do point in time recovery from your latest backup. +# +# Bin log basename +# https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin_basename +# it is recommened to specify a filename for the binary log, hopefully +# something that is not host specific. I've chosen master-bin. +<%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') %> +log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> +<%- else %> + <%- unless [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> + <# from toady point log_bin attr. was missused in the cookbook in the past #> + <# and contained more or less the base-name #> +log-bin = <%= node["percona"]["server"]["log_bin"] %> + <%- else %> + # to allow on <= 5.5 useage of log_bin_basename + # introduced by this PR + <%- if node["percona"]["server"].key?('log_bin_basename') %> +log-bin = <%= node["percona"]["server"]["log_bin_basename"] %> + <%- end %> + <%- end %> +<%- end %> + +# Bin log on/off switch +# https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin +<%- if [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> +log_bin = <%= node["percona"]["server"]["log_bin"] %> +<%- end %> + +<% unless node["percona"]["server"]["relay_log"].empty? %> +relay-log = <%= node["percona"]["server"]["relay_log"] %> +<% end %> + expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> @@ -384,6 +417,8 @@ enforce_gtid_consistency = <%= node["percona"]["server"]["enforce_gtid_consisten <% if node["percona"]["server"]["sync_master_info"] %> sync_master_info = <%= node["percona"]["server"]["sync_master_info"] %> <% end %> + + <% if node["percona"]["server"]["sync_relay_log"] %> sync_relay_log = <%= node["percona"]["server"]["sync_relay_log"] %> <% end %> diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index b21e355d..0ba629ee 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -348,7 +348,41 @@ skip-slave-start # stopping. slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_transaction_retries"] %> -log_bin = <%= node["percona"]["server"]["datadir"] %>/mysql-bin.log + +# Enable binary logging. This is required for acting as a MASTER in a +# replication configuration. You also need the binary log if you need +# the ability to do point in time recovery from your latest backup. +# +# Bin log basename +# https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin_basename +# it is recommened to specify a filename for the binary log, hopefully +# something that is not host specific. I've chosen master-bin. +<%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') %> +log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> +<%- else %> + <%- unless [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> + <# from toady point log_bin attr. was missused in the cookbook in the past #> + <# and contained more or less the base-name #> +log-bin = <%= node["percona"]["server"]["log_bin"] %> + <%- else %> + # to allow on <= 5.5 useage of log_bin_basename + # introduced by this PR + <%- if node["percona"]["server"].key?('log_bin_basename') %> +log-bin = <%= node["percona"]["server"]["log_bin_basename"] %> + <%- end %> + <%- end %> +<%- end %> + +# Bin log on/off switch +# https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin +<%- if [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> +log_bin = <%= node["percona"]["server"]["log_bin"] %> +<%- end %> + +<% unless node["percona"]["server"]["relay_log"].empty? %> +relay-log = <%= node["percona"]["server"]["relay_log"] %> +<% end %> + expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> @@ -402,20 +436,6 @@ sync_relay_log_info = <%= node["percona"]["server"]["sync_relay_log_info"] %> # statement in transaction binlog_cache_size = <%= node["percona"]["server"]["binlog_cache_size"] %> -# Enable binary logging. This is required for acting as a MASTER in a -# replication configuration. You also need the binary log if you need -# the ability to do point in time recovery from your latest backup. - -# it is recommened to specify a filename for the binary log, hopefully -# something that is not host specific. I've chosen master-bin. -<% unless node["percona"]["server"]["log_bin"].empty? %> -log-bin = <%= node["percona"]["server"]["log_bin"] %> -<% end %> - -<% unless node["percona"]["server"]["relay_log"].empty? %> -relay-log = <%= node["percona"]["server"]["relay_log"] %> -<% end %> - # If you're using replication with chained slaves (A->B->C), you need to # enable this option on server B. It enables logging of updates done by # the slave thread into the slave's binary log. From cc2aa23ee69aeeda716b85955050cb3646934385 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Wed, 10 Feb 2016 15:49:18 +0100 Subject: [PATCH 036/300] add table definition cache for <= 5.5 --- templates/default/my.cnf.cluster.erb | 4 ++++ templates/default/my.cnf.main.erb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index 12b3a6b0..c75dc18e 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -243,6 +243,10 @@ table_open_cache = <%= node["percona"]["server"]["table_cache"] %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- else %> table_cache = <%= node["percona"]["server"]["table_cache"] %> +<# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value #> + <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eq?(-1) +table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> + <%- end %> <%- end %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 0ba629ee..2a01d5ed 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -229,6 +229,10 @@ table_open_cache = <%= node["percona"]["server"]["table_cache"] %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- else %> table_cache = <%= node["percona"]["server"]["table_cache"] %> +<# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value #> + <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eq?(-1) +table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> + <%- end %> <%- end %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> From fa42c6cb88aed22c8a1752e505dac83ec962a86e Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Wed, 10 Feb 2016 15:58:35 +0100 Subject: [PATCH 037/300] fix - table_cache -> table_open_cache (valid for >=5.5) --- templates/default/my.cnf.cluster.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index c75dc18e..d47a1e85 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -242,9 +242,9 @@ sql-mode = <%= node["percona"]["server"]["sql_modes"].join(",") %> table_open_cache = <%= node["percona"]["server"]["table_cache"] %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- else %> -table_cache = <%= node["percona"]["server"]["table_cache"] %> -<# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value #> - <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eq?(-1) +table_open_cache = <%= node["percona"]["server"]["table_cache"] %> + <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eq?(-1) %> + <# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value #> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- end %> <%- end %> From d747cf96d3815a2900c3068fefa5fbd199f55697 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Wed, 10 Feb 2016 16:33:32 +0100 Subject: [PATCH 038/300] add some additional configuration options --- attributes/default.rb | 2 ++ templates/default/my.cnf.cluster.erb | 4 ++++ templates/default/my.cnf.main.erb | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index 2fe50195..05094fd2 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -170,6 +170,7 @@ default["percona"]["server"]["innodb_additional_mem_pool_size"] = "32M" default["percona"]["server"]["innodb_buffer_pool_size"] = "128M" default["percona"]["server"]["innodb_buffer_pool_instances"] = 8 +default["percona"]["server"]["innodb_buffer_pool_populate"] = 0 # Introduced: MariaDB 5.5 / XtraDB 5.5.28-29.1 default["percona"]["server"]["innodb_data_file_path"] = "ibdata1:10M:autoextend" default["percona"]["server"]["innodb_autoextend_increment"] = "128M" default["percona"]["server"]["innodb_open_files"] = 2000 @@ -186,6 +187,7 @@ default["percona"]["server"]["innodb_flush_method"] = "O_DIRECT" default["percona"]["server"]["innodb_lock_wait_timeout"] = 120 default["percona"]["server"]["innodb_import_table_from_xtrabackup"] = 0 +default["percona"]["server"]["innodb_numa_interleave"] = 0 # Performance Schema default["percona"]["server"]["performance_schema"] = false diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index d47a1e85..b20652e0 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -513,6 +513,8 @@ innodb_buffer_pool_size = <%= node["percona"]["server"]["innodb_buffer_pool_size innodb_buffer_pool_instances = <%= node["percona"]["server"]["innodb_buffer_pool_instances"] %> +innodb_buffer_pool_populate = <%= node["percona"]["server"]["innodb_buffer_pool_populate"] %> + # InnoDB stores data in one or more data files forming the tablespace. # If you have a single logical drive for your data, a single # autoextending file would be good enough. In other cases, a single file @@ -630,6 +632,8 @@ innodb_commit_concurrency=0 innodb_open_files=<%= node["percona"]["server"]["innodb_open_files"] %> +innodb_numa_interleave=<%= node["percona"]["server"]["innodb_numa_interleave"] %> + # # * Security Features # diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 2a01d5ed..1243d03e 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -230,7 +230,7 @@ table_definition_cache = <%= node["percona"]["server"]["table_definition_cache" <%- else %> table_cache = <%= node["percona"]["server"]["table_cache"] %> <# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value #> - <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eq?(-1) + <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eq?(-1) %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- end %> <%- end %> @@ -650,6 +650,8 @@ innodb_commit_concurrency=0 innodb_open_files=<%= node["percona"]["server"]["innodb_open_files"] %> +innodb_numa_interleave=<%= node["percona"]["server"]["innodb_numa_interleave"] %> + <% if node["percona"]["version"] == "5.5" %> # set this to 1 if you like to import single tables from xtrabackup snapshot innodb_import_table_from_xtrabackup = <%= node["percona"]["server"]["innodb_import_table_from_xtrabackup"] %> From 2107fab617481aee33a031d0019d54d3f83a6cc6 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Wed, 10 Feb 2016 16:33:32 +0100 Subject: [PATCH 039/300] add some additional configuration options --- attributes/default.rb | 2 ++ templates/default/my.cnf.cluster.erb | 6 ++++++ templates/default/my.cnf.main.erb | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index 2fe50195..05094fd2 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -170,6 +170,7 @@ default["percona"]["server"]["innodb_additional_mem_pool_size"] = "32M" default["percona"]["server"]["innodb_buffer_pool_size"] = "128M" default["percona"]["server"]["innodb_buffer_pool_instances"] = 8 +default["percona"]["server"]["innodb_buffer_pool_populate"] = 0 # Introduced: MariaDB 5.5 / XtraDB 5.5.28-29.1 default["percona"]["server"]["innodb_data_file_path"] = "ibdata1:10M:autoextend" default["percona"]["server"]["innodb_autoextend_increment"] = "128M" default["percona"]["server"]["innodb_open_files"] = 2000 @@ -186,6 +187,7 @@ default["percona"]["server"]["innodb_flush_method"] = "O_DIRECT" default["percona"]["server"]["innodb_lock_wait_timeout"] = 120 default["percona"]["server"]["innodb_import_table_from_xtrabackup"] = 0 +default["percona"]["server"]["innodb_numa_interleave"] = 0 # Performance Schema default["percona"]["server"]["performance_schema"] = false diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index d47a1e85..a8f183bd 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -513,6 +513,8 @@ innodb_buffer_pool_size = <%= node["percona"]["server"]["innodb_buffer_pool_size innodb_buffer_pool_instances = <%= node["percona"]["server"]["innodb_buffer_pool_instances"] %> +innodb_buffer_pool_populate = <%= node["percona"]["server"]["innodb_buffer_pool_populate"] %> + # InnoDB stores data in one or more data files forming the tablespace. # If you have a single logical drive for your data, a single # autoextending file would be good enough. In other cases, a single file @@ -630,6 +632,10 @@ innodb_commit_concurrency=0 innodb_open_files=<%= node["percona"]["server"]["innodb_open_files"] %> +<%- if node["percona"]["version"] >= "5.6" %> +innodb_numa_interleave=<%= node["percona"]["server"]["innodb_numa_interleave"] %> +<%- end %> + # # * Security Features # diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 2a01d5ed..9a739a1b 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -230,7 +230,7 @@ table_definition_cache = <%= node["percona"]["server"]["table_definition_cache" <%- else %> table_cache = <%= node["percona"]["server"]["table_cache"] %> <# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value #> - <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eq?(-1) + <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eq?(-1) %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- end %> <%- end %> @@ -650,6 +650,10 @@ innodb_commit_concurrency=0 innodb_open_files=<%= node["percona"]["server"]["innodb_open_files"] %> +<%- if node["percona"]["version"] >= "5.6" %> +innodb_numa_interleave=<%= node["percona"]["server"]["innodb_numa_interleave"] %> +<%- end %> + <% if node["percona"]["version"] == "5.5" %> # set this to 1 if you like to import single tables from xtrabackup snapshot innodb_import_table_from_xtrabackup = <%= node["percona"]["server"]["innodb_import_table_from_xtrabackup"] %> From 536894d279cfdd587c80eb32d9b5bc52494d77ea Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Thu, 11 Feb 2016 00:28:01 +0100 Subject: [PATCH 040/300] syntax fixes --- templates/default/my.cnf.cluster.erb | 2 +- templates/default/my.cnf.main.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index a8f183bd..fc60c076 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -243,7 +243,7 @@ table_open_cache = <%= node["percona"]["server"]["table_cache"] %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- else %> table_open_cache = <%= node["percona"]["server"]["table_cache"] %> - <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eq?(-1) %> + <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eql?(-1) %> <# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value #> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- end %> diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 9a739a1b..5bd8073b 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -230,7 +230,7 @@ table_definition_cache = <%= node["percona"]["server"]["table_definition_cache" <%- else %> table_cache = <%= node["percona"]["server"]["table_cache"] %> <# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value #> - <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eq?(-1) %> + <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eql?(-1) %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- end %> <%- end %> From e8615554a78c3a76ea5951292ea7afdc5bd279a1 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Thu, 11 Feb 2016 16:55:06 +0100 Subject: [PATCH 041/300] fix erb comment syntax --- templates/default/my.cnf.cluster.erb | 6 +++--- templates/default/my.cnf.main.erb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index fc60c076..6bc675d3 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -244,7 +244,7 @@ table_definition_cache = <%= node["percona"]["server"]["table_definition_cache" <%- else %> table_open_cache = <%= node["percona"]["server"]["table_cache"] %> <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eql?(-1) %> - <# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value #> + <%# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- end %> <%- end %> @@ -363,8 +363,8 @@ slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_ log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> <%- else %> <%- unless [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> - <# from toady point log_bin attr. was missused in the cookbook in the past #> - <# and contained more or less the base-name #> + <%# from toady point log_bin attr. was missused in the cookbook in the past %> + <%# and contained more or less the base-name %> log-bin = <%= node["percona"]["server"]["log_bin"] %> <%- else %> # to allow on <= 5.5 useage of log_bin_basename diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 5bd8073b..870c373d 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -229,7 +229,7 @@ table_open_cache = <%= node["percona"]["server"]["table_cache"] %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- else %> table_cache = <%= node["percona"]["server"]["table_cache"] %> -<# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value #> +<%# for <= 5.6.7, keep in mind MIN/MAX values. The -1 is the default value %> <%- unless node["percona"]["server"]["table_definition_cache"].to_i.eql?(-1) %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- end %> @@ -365,8 +365,8 @@ slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_ log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> <%- else %> <%- unless [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> - <# from toady point log_bin attr. was missused in the cookbook in the past #> - <# and contained more or less the base-name #> + <%# from toady point log_bin attr. was missused in the cookbook in the past %> + <%# and contained more or less the base-name %> log-bin = <%= node["percona"]["server"]["log_bin"] %> <%- else %> # to allow on <= 5.5 useage of log_bin_basename From d9e1d3ae5d28f2609cab883bc004263245137307 Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Mon, 29 Feb 2016 15:36:15 +0100 Subject: [PATCH 042/300] fix, log-bin vs. log_bin behavior --- templates/default/my.cnf.cluster.erb | 10 ++-------- templates/default/my.cnf.main.erb | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index 6bc675d3..d2fb6688 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -365,22 +365,16 @@ log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> <%- unless [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> <%# from toady point log_bin attr. was missused in the cookbook in the past %> <%# and contained more or less the base-name %> -log-bin = <%= node["percona"]["server"]["log_bin"] %> +log_bin = <%= node["percona"]["server"]["log_bin"] %> <%- else %> # to allow on <= 5.5 useage of log_bin_basename # introduced by this PR <%- if node["percona"]["server"].key?('log_bin_basename') %> -log-bin = <%= node["percona"]["server"]["log_bin_basename"] %> +log_bin = <%= node["percona"]["server"]["log_bin_basename"] %> <%- end %> <%- end %> <%- end %> -# Bin log on/off switch -# https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin -<%- if [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> -log_bin = <%= node["percona"]["server"]["log_bin"] %> -<%- end %> - <% unless node["percona"]["server"]["relay_log"].empty? %> relay-log = <%= node["percona"]["server"]["relay_log"] %> <% end %> diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 870c373d..62b8bf90 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -367,22 +367,16 @@ log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> <%- unless [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> <%# from toady point log_bin attr. was missused in the cookbook in the past %> <%# and contained more or less the base-name %> -log-bin = <%= node["percona"]["server"]["log_bin"] %> +log_bin = <%= node["percona"]["server"]["log_bin"] %> <%- else %> # to allow on <= 5.5 useage of log_bin_basename # introduced by this PR <%- if node["percona"]["server"].key?('log_bin_basename') %> -log-bin = <%= node["percona"]["server"]["log_bin_basename"] %> +log_bin = <%= node["percona"]["server"]["log_bin_basename"] %> <%- end %> <%- end %> <%- end %> -# Bin log on/off switch -# https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin -<%- if [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> -log_bin = <%= node["percona"]["server"]["log_bin"] %> -<%- end %> - <% unless node["percona"]["server"]["relay_log"].empty? %> relay-log = <%= node["percona"]["server"]["relay_log"] %> <% end %> From d27aacf314da74b067734c2a1722e057b4d78eff Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Fri, 11 Mar 2016 11:15:13 +0100 Subject: [PATCH 043/300] exclude log-bin empty attribs to be placed in configs --- templates/default/my.cnf.cluster.erb | 8 ++++---- templates/default/my.cnf.main.erb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index d2fb6688..ef809808 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -305,7 +305,7 @@ log-queries-not-using-indexes = <%= node["percona"]["server"]["log_queries_not_u # is required for both master and slave hosts. It defaults to 1 if # "master-host" is not set, but will MySQL will not function as a master # if it is omitted. -#server-id = 1 +# server-id = <%= node["percona"]["server"]["server_id"] %> <% unless node["percona"]["server"]["replication"]["ignore_db"].empty? %> # Tells the slave SQL thread not to replicate any statement where the default database is. @@ -359,17 +359,17 @@ slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_ # https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin_basename # it is recommened to specify a filename for the binary log, hopefully # something that is not host specific. I've chosen master-bin. -<%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') %> +<%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> <%- else %> - <%- unless [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> + <%- unless [1,'1',0,'0','OFF','off',''].include?(node["percona"]["server"]["log_bin"]) %> <%# from toady point log_bin attr. was missused in the cookbook in the past %> <%# and contained more or less the base-name %> log_bin = <%= node["percona"]["server"]["log_bin"] %> <%- else %> # to allow on <= 5.5 useage of log_bin_basename # introduced by this PR - <%- if node["percona"]["server"].key?('log_bin_basename') %> + <%- if node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> log_bin = <%= node["percona"]["server"]["log_bin_basename"] %> <%- end %> <%- end %> diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 62b8bf90..900ad69b 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -361,17 +361,17 @@ slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_ # https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin_basename # it is recommened to specify a filename for the binary log, hopefully # something that is not host specific. I've chosen master-bin. -<%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') %> +<%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> <%- else %> - <%- unless [1,'1',0,'0','OFF','off'].include?(node["percona"]["server"]["log_bin"]) %> + <%- unless [1,'1',0,'0','OFF','off',''].include?(node["percona"]["server"]["log_bin"]) %> <%# from toady point log_bin attr. was missused in the cookbook in the past %> <%# and contained more or less the base-name %> log_bin = <%= node["percona"]["server"]["log_bin"] %> <%- else %> # to allow on <= 5.5 useage of log_bin_basename # introduced by this PR - <%- if node["percona"]["server"].key?('log_bin_basename') %> + <%- if node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> log_bin = <%= node["percona"]["server"]["log_bin_basename"] %> <%- end %> <%- end %> @@ -384,6 +384,7 @@ relay-log = <%= node["percona"]["server"]["relay_log"] %> expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> +slave_net_timeout = <%= node["percona"]["server"]["slave_net_timeout"] %> <%- if node["percona"]["version"] >= "5.6" %> binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> <% if node["percona"]["server"]["master_verify_checksum"] %> @@ -393,7 +394,6 @@ master_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] slave_sql_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> <% end %> <% end %> -slave_net_timeout = <%= node["percona"]["server"]["slave_net_timeout"] %> <% if node["percona"]["server"]["binlog_rows_query_log_events"] %> binlog_rows_query_log_events From e961a7393f3098c282ced981df71f20c84081d91 Mon Sep 17 00:00:00 2001 From: Alexei Smirnov Date: Thu, 24 Mar 2016 22:31:50 -0700 Subject: [PATCH 044/300] removed deprecated options from my.cnf.* that prevent 5.7.4+ from starting up removed some of the deprecated options from my.cnf.* that prevent 5.7.4+ from starting up successfully --- templates/default/my.cnf.main.erb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 652a01f3..ffc3837b 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -429,11 +429,12 @@ myisam_max_sort_file_size = <%= node["percona"]["server"]["myisam_max_sort_file_ # have multiple CPUs and plenty of memory. myisam_repair_threads = <%= node["percona"]["server"]["myisam_repair_threads"] %> +<%- if node["percona"]["version"] < "5.7.4" %> # Automatically check and repair not properly closed MyISAM tables. <% if node["percona"]["server"]["myisam_recover_options"] %> myisam_recover <% end %> - +<%- end %> # # * InnoDB @@ -448,12 +449,14 @@ myisam_recover skip-innodb <% end %> +<%- if node["percona"]["version"] < "5.7.4" %> # Additional memory pool that is used by InnoDB to store metadata # information. If InnoDB requires more memory for this purpose it will # start to allocate it from the OS. As this is fast enough on most # recent operating systems, you normally do not need to change this # value. SHOW INNODB STATUS will display the current amount used. innodb_additional_mem_pool_size = <%= node["percona"]["server"]["innodb_additional_mem_pool_size"] %> +<%- end %> # This config file assumes a main memory of at least 8G innodb_buffer_pool_size = <%= node["percona"]["server"]["innodb_buffer_pool_size"] %> From a49e80343fb66d9d7f1b36c0b89fc608a3a30107 Mon Sep 17 00:00:00 2001 From: Alexei Smirnov Date: Thu, 24 Mar 2016 22:32:48 -0700 Subject: [PATCH 045/300] removed deprecated options from my.cnf.* that prevent 5.7.4+ from starting up removed some of the deprecated options from my.cnf.* that prevent 5.7.4+ from starting up --- templates/default/my.cnf.cluster.erb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index c8f4879b..1158bc2e 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -398,11 +398,12 @@ myisam_max_sort_file_size = <%= node["percona"]["server"]["myisam_max_sort_file_ # have multiple CPUs and plenty of memory. myisam_repair_threads = <%= node["percona"]["server"]["myisam_repair_threads"] %> +<%- if node["percona"]["version"] < "5.7.4" %> # Automatically check and repair not properly closed MyISAM tables. <% if node["percona"]["server"]["myisam_recover_options"] %> myisam_recover <% end %> - +<%- end %> # # * InnoDB @@ -417,12 +418,14 @@ myisam_recover skip-innodb <% end %> +<%- if node["percona"]["version"] < "5.7.4" %> # Additional memory pool that is used by InnoDB to store metadata # information. If InnoDB requires more memory for this purpose it will # start to allocate it from the OS. As this is fast enough on most # recent operating systems, you normally do not need to change this # value. SHOW INNODB STATUS will display the current amount used. innodb_additional_mem_pool_size = <%= node["percona"]["server"]["innodb_additional_mem_pool_size"] %> +<%- end %> # This config file assumes a main memory of at least 8G innodb_buffer_pool_size = <%= node["percona"]["server"]["innodb_buffer_pool_size"] %> From 8092de895a21502188653a3d889ca0bf23ffad16 Mon Sep 17 00:00:00 2001 From: Matthew Silvey Date: Fri, 8 Apr 2016 14:33:12 -0700 Subject: [PATCH 046/300] putting the datadir option back into db creation. --- recipes/configure_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 5d385010..d6cb6b24 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -108,7 +108,7 @@ # install db to the data directory execute "setup mysql datadir" do - command "mysql_install_db --defaults-file=#{percona["main_config_file"]} --user=#{user}" # rubocop:disable LineLength + command "mysql_install_db --datadir=#{datadir} --defaults-file=#{percona["main_config_file"]} --user=#{user}" # rubocop:disable LineLength not_if "test -f #{datadir}/mysql/user.frm" action :nothing end From 78c3726f3097dca224da31058cbb1b813d66e420 Mon Sep 17 00:00:00 2001 From: Roman Lenskij Date: Sun, 24 Apr 2016 16:27:15 +0300 Subject: [PATCH 047/300] Rename log_bin_basename to log_bin --- templates/default/my.cnf.cluster.erb | 2 +- templates/default/my.cnf.main.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/default/my.cnf.cluster.erb b/templates/default/my.cnf.cluster.erb index ef809808..8d74184e 100644 --- a/templates/default/my.cnf.cluster.erb +++ b/templates/default/my.cnf.cluster.erb @@ -360,7 +360,7 @@ slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_ # it is recommened to specify a filename for the binary log, hopefully # something that is not host specific. I've chosen master-bin. <%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> -log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> +log_bin = <%= node["percona"]["server"]["log_bin_basename"] %> <%- else %> <%- unless [1,'1',0,'0','OFF','off',''].include?(node["percona"]["server"]["log_bin"]) %> <%# from toady point log_bin attr. was missused in the cookbook in the past %> diff --git a/templates/default/my.cnf.main.erb b/templates/default/my.cnf.main.erb index 900ad69b..04c1c5e1 100644 --- a/templates/default/my.cnf.main.erb +++ b/templates/default/my.cnf.main.erb @@ -362,7 +362,7 @@ slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_ # it is recommened to specify a filename for the binary log, hopefully # something that is not host specific. I've chosen master-bin. <%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> -log_bin_basename = <%= node["percona"]["server"]["log_bin_basename"] %> +log_bin = <%= node["percona"]["server"]["log_bin_basename"] %> <%- else %> <%- unless [1,'1',0,'0','OFF','off',''].include?(node["percona"]["server"]["log_bin"]) %> <%# from toady point log_bin attr. was missused in the cookbook in the past %> From 85f87a509fb11b106a864ee26f2fb5c736c27571 Mon Sep 17 00:00:00 2001 From: Roman Lenskij Date: Sun, 24 Apr 2016 16:33:41 +0300 Subject: [PATCH 048/300] Don't add repository if key already present --- recipes/package_repo.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index e3b5a044..0771a5d2 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -22,6 +22,7 @@ components ["main"] keyserver node["percona"]["apt"]["keyserver"] key node["percona"]["apt"]["key"] + not_if "apt-key list | grep #{node['percona']['apt']['key'][-8,8]}" end when "rhel" From e9856d0108bd31e257eb5fb56781737fea52ba2e Mon Sep 17 00:00:00 2001 From: Roman Lenskij Date: Sun, 24 Apr 2016 16:33:55 +0300 Subject: [PATCH 049/300] Bump version to 0.16.3 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index a7bd2bbd..b888f54d 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license "MIT" description "Installs Percona MySQL client and server" long_description "Please refer to README.md" -version "0.16.2" +version "0.16.3" recipe "percona", "Includes the client recipe to configure a client" recipe "percona::package_repo", "Sets up the package repository and installs dependent packages" From c4bb234e2dd276bebc8e09990cc7b78fa24ae80b Mon Sep 17 00:00:00 2001 From: Kevin Bonner Date: Tue, 3 May 2016 17:16:39 -0400 Subject: [PATCH 050/300] use the percona data bag secret file to obtain SSL replication certificates --- recipes/ssl.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/recipes/ssl.rb b/recipes/ssl.rb index e9cf1d5d..c3a617f5 100644 --- a/recipes/ssl.rb +++ b/recipes/ssl.rb @@ -6,15 +6,18 @@ certs_path = "/etc/mysql/ssl" server = node["percona"]["server"] data_bag = node["percona"]["encrypted_data_bag"] +secret_file = node["percona"]["encrypted_data_bag_secret_file"] directory certs_path do owner node["percona"]["server"]["username"] mode "0700" end +secret = Chef::EncryptedDataBagItem.load_secret(secret_file) certs = Chef::EncryptedDataBagItem.load( data_bag, - node["percona"]["encrypted_data_bag_item_ssl_replication"] + node["percona"]["encrypted_data_bag_item_ssl_replication"], + secret ) # place the CA certificate, it should be present on both master and slave From cc3a114ab823a6afd20eec4f07453ace9383d119 Mon Sep 17 00:00:00 2001 From: Daniel van Dorp Date: Thu, 20 Oct 2016 15:14:08 +0200 Subject: [PATCH 051/300] Update the Signing Key for Percona Debian and Ubuntu Packages See: https://www.percona.com/blog/2016/10/13/new-signing-key-for-percona-debian-and-ubuntu-packages/ --- attributes/package_repo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attributes/package_repo.rb b/attributes/package_repo.rb index 6bef7f2f..307b022d 100644 --- a/attributes/package_repo.rb +++ b/attributes/package_repo.rb @@ -11,7 +11,7 @@ "default" => node["platform_version"].to_i ) -default["percona"]["apt"]["key"] = "0x1C4CBDCDCD2EFD2A" +default["percona"]["apt"]["key"] = "0x9334A25F8507EFA5" default["percona"]["apt"]["keyserver"] = "hkp://keys.gnupg.net:80" default["percona"]["apt"]["uri"] = "http://repo.percona.com/apt" From eb054574dc1fc88e57d969394b9092a36cdffd34 Mon Sep 17 00:00:00 2001 From: Roman Lenskij Date: Mon, 24 Oct 2016 22:03:32 +0300 Subject: [PATCH 052/300] Version bump --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index b888f54d..53160bc9 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license "MIT" description "Installs Percona MySQL client and server" long_description "Please refer to README.md" -version "0.16.3" +version "0.16.4" recipe "percona", "Includes the client recipe to configure a client" recipe "percona::package_repo", "Sets up the package repository and installs dependent packages" From 6a62618475516f4f4296f8c714ccc348b0a71393 Mon Sep 17 00:00:00 2001 From: Grant Ridder Date: Mon, 30 Jan 2017 01:47:02 -0800 Subject: [PATCH 053/300] Update travis and Gems to newest --- .ruby-version | 2 +- .travis.yml | 11 +++-------- Gemfile | 26 +++++++++++++------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/.ruby-version b/.ruby-version index 8bbe6cf7..2bf1c1cc 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.2 +2.3.1 diff --git a/.travis.yml b/.travis.yml index b9bb1a16..2c3d5876 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,13 @@ language: ruby bundler_args: --jobs 4 --without integration rvm: - - 2.0 - - 2.1 - - 2.2 + - 2.3.1 cache: bundler sudo: false # travis docker container env: matrix: - - CHEF_VERSION=11.18.0 - - CHEF_VERSION=12.0.0 - - CHEF_VERSION=12.1.0 - - CHEF_VERSION=12.2.0 - - CHEF_VERSION=12.3.0 + - CHEF_VERSION=12.5.0 + - CHEF_VERSION=12.18.31 before_script: - "gem install bundler-audit --no-rdoc --no-ri && bundle-audit update" script: diff --git a/Gemfile b/Gemfile index 7a6aeaeb..14a55605 100644 --- a/Gemfile +++ b/Gemfile @@ -1,21 +1,21 @@ source "https://rubygems.org" -chef_version = ENV.fetch("CHEF_VERSION", "12.3.0") +chef_version = ENV.fetch("CHEF_VERSION", "12.18.31") gem "chef", "~> #{chef_version}" -gem "chefspec", "~> 4.2.0" -gem "chef-vault", "~> 2.6.0" +gem "chefspec" +gem "chef-vault" -gem "berkshelf", "~> 3.2.4" -gem "foodcritic", "~> 4.0.0" -gem "license_finder", "~> 2.0.4" -gem "rake", "~> 10.4.2" -gem "rubocop", "~> 0.31.0" -gem "serverspec", "~> 2.17.0" +gem "berkshelf" +gem "foodcritic" +gem "license_finder" +gem "rake" +gem "rubocop" +gem "serverspec" group :integration do - gem "busser-serverspec", "~> 0.5.6" - gem "kitchen-docker", "~> 2.1.0" - gem "kitchen-sync", "~> 1.0.1" - gem "test-kitchen", "~> 1.4.0" + gem "busser-serverspec" + gem "kitchen-docker" + gem "kitchen-sync" + gem "test-kitchen" end From e881a8084e19fde6c2f296fc243e1ab54b3809aa Mon Sep 17 00:00:00 2001 From: Grant Ridder Date: Mon, 30 Jan 2017 01:47:30 -0800 Subject: [PATCH 054/300] Ignore .bundle --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c19cb3c1..ea1344d4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ tmp .kitchen.local.yml Berksfile.lock Gemfile.lock +.bundle/ From 2c3264c7901d8ec60cc64365b3dac332cb71cce9 Mon Sep 17 00:00:00 2001 From: Grant Ridder Date: Mon, 30 Jan 2017 01:47:49 -0800 Subject: [PATCH 055/300] Fix docker cli access for kitchen-docker See https://github.com/test-kitchen/kitchen-docker/issues/207 --- .kitchen.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.kitchen.yml b/.kitchen.yml index 154dfc50..658886b8 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -3,6 +3,7 @@ driver: name: docker require_chef_omnibus: <%= ENV.fetch("CHEF_VERSION", "true") %> + use_sudo: false provisioner: name: chef_zero From 29572f00b6e5ad74fa52cf909849205ac6fd67aa Mon Sep 17 00:00:00 2001 From: Grant Ridder Date: Mon, 30 Jan 2017 01:58:38 -0800 Subject: [PATCH 056/300] Cleanup rubocop offenses --- .rubocop.yml | 21 +- Gemfile | 2 +- attributes/default.rb | 30 +- libraries/config_helper.rb | 12 +- recipes/access_grants.rb | 2 +- recipes/configure_server.rb | 4 +- recipes/replication.rb | 2 +- spec/configure_server_spec.rb | 2 +- test/support/rubocop/disabled.yml | 25 -- test/support/rubocop/enabled.yml | 652 ------------------------------ 10 files changed, 38 insertions(+), 714 deletions(-) delete mode 100644 test/support/rubocop/disabled.yml delete mode 100644 test/support/rubocop/enabled.yml diff --git a/.rubocop.yml b/.rubocop.yml index cac7b3be..eef2091d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,29 +1,30 @@ AllCops: + DisplayCopNames: true Exclude: - ".bundle/**/*" - ".kitchen/**/*" - "vendor/**/*" -LineLength: +Metrics/BlockLength: + Enabled: false + +Metrics/LineLength: Max: 80 Exclude: - "**/attributes/*.rb" - "**/metadata.rb" -StringLiterals: +Style/FrozenStringLiteralComment: + Enabled: false + +Style/StringLiterals: EnforcedStyle: double_quotes -StringLiteralsInInterpolation: +Style/StringLiteralsInInterpolation: EnforcedStyle: double_quotes -PercentLiteralDelimiters: +Style/PercentLiteralDelimiters: PreferredDelimiters: "%r": "()" "%w": "[]" # Arrays use brackets "%W": "[]" # Arrays use brackets - -SingleSpaceBeforeFirstArg: - Enabled: false # too strict about metadata and certain formatting - -inherit_from: test/support/rubocop/enabled.yml -inherit_from: test/support/rubocop/disabled.yml diff --git a/Gemfile b/Gemfile index 14a55605..b6ca199a 100644 --- a/Gemfile +++ b/Gemfile @@ -3,8 +3,8 @@ source "https://rubygems.org" chef_version = ENV.fetch("CHEF_VERSION", "12.18.31") gem "chef", "~> #{chef_version}" -gem "chefspec" gem "chef-vault" +gem "chefspec" gem "berkshelf" gem "foodcritic" diff --git a/attributes/default.rb b/attributes/default.rb index 868c021c..7f0da6cf 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -68,21 +68,21 @@ ), "rhel" => "/usr/lib64/libjemalloc.so.1" ) -default["percona"]["server"]["nice"] = 0 -default["percona"]["server"]["open_files_limit"] = 16_384 -default["percona"]["server"]["hostname"] = "localhost" -default["percona"]["server"]["basedir"] = "/usr" -default["percona"]["server"]["port"] = 3306 -default["percona"]["server"]["language"] = "/usr/share/mysql/english" -default["percona"]["server"]["character_set"] = "utf8" -default["percona"]["server"]["collation"] = "utf8_unicode_ci" -default["percona"]["server"]["skip_name_resolve"] = false -default["percona"]["server"]["skip_external_locking"] = true -default["percona"]["server"]["net_read_timeout"] = 120 -default["percona"]["server"]["connect_timeout"] = 10 -default["percona"]["server"]["wait_timeout"] = 28_800 -default["percona"]["server"]["old_passwords"] = 0 -default["percona"]["server"]["bind_address"] = "127.0.0.1" +default["percona"]["server"]["nice"] = 0 +default["percona"]["server"]["open_files_limit"] = 16_384 +default["percona"]["server"]["hostname"] = "localhost" +default["percona"]["server"]["basedir"] = "/usr" +default["percona"]["server"]["port"] = 3306 +default["percona"]["server"]["language"] = "/usr/share/mysql/english" +default["percona"]["server"]["character_set"] = "utf8" +default["percona"]["server"]["collation"] = "utf8_unicode_ci" +default["percona"]["server"]["skip_name_resolve"] = false +default["percona"]["server"]["skip_external_locking"] = true +default["percona"]["server"]["net_read_timeout"] = 120 +default["percona"]["server"]["connect_timeout"] = 10 +default["percona"]["server"]["wait_timeout"] = 28_800 +default["percona"]["server"]["old_passwords"] = 0 +default["percona"]["server"]["bind_address"] = "127.0.0.1" default["percona"]["server"]["federated"] = false %w[debian_password root_password].each do |attribute| diff --git a/libraries/config_helper.rb b/libraries/config_helper.rb index de8966fe..3713e6e8 100644 --- a/libraries/config_helper.rb +++ b/libraries/config_helper.rb @@ -7,10 +7,12 @@ module IPScope def for(ipaddress) address = IPAddr.new(ipaddress) - case - when private?(address) then :private - when loopback?(address) then :loopback - else :public + if private?(address) + :private + elsif loopback?(address) + :loopback + else + :public end end module_function :for @@ -41,8 +43,6 @@ def bind_to(node, interface) end module_function :bind_to - private - def self.find_public_ip(node) if node["cloud"] && node["cloud"]["public_ipv4"] node["cloud"]["public_ipv4"] diff --git a/recipes/access_grants.rb b/recipes/access_grants.rb index d008d4e4..2b89b9a5 100644 --- a/recipes/access_grants.rb +++ b/recipes/access_grants.rb @@ -25,7 +25,7 @@ # Intent is to check whether the root_password works, and use it to # load the grants if so. If not, try loading without a password # and see if we get lucky - execute "mysql-install-privileges" do # ~FC009 - `sensitive` + execute "mysql-install-privileges" do # ~FC009 - `sensitive` command "/usr/bin/mysql -p'#{passwords.root_password}' -e '' &> /dev/null > /dev/null &> /dev/null ; if [ $? -eq 0 ] ; then /usr/bin/mysql -p'#{passwords.root_password}' < /etc/mysql/grants.sql ; else /usr/bin/mysql < /etc/mysql/grants.sql ; fi ;" # rubocop:disable LineLength action :nothing subscribes :run, resources("template[/etc/mysql/grants.sql]"), :immediately diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 5d385010..1bfd0e1b 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -83,7 +83,7 @@ end # setup the configuration include directory -unless includedir.empty? # ~FC023 +unless includedir.empty? # ~FC023 directory includedir do # don't evaluate an empty `directory` resource owner user group user @@ -139,7 +139,7 @@ unless node["percona"]["skip_passwords"] root_pw = passwords.root_password - execute "Update MySQL root password" do # ~FC009 - `sensitive` + execute "Update MySQL root password" do # ~FC009 - `sensitive` command "mysqladmin --user=root --password='' password '#{root_pw}'" only_if "mysqladmin --user=root --password='' version" sensitive true diff --git a/recipes/replication.rb b/recipes/replication.rb index d485f33f..9f3e8eb6 100644 --- a/recipes/replication.rb +++ b/recipes/replication.rb @@ -25,7 +25,7 @@ root_pass = passwords.root_password.to_s root_pass = Shellwords.escape(root_pass).prepend("-p") unless root_pass.empty? -execute "mysql-set-replication" do # ~FC009 - `sensitive` +execute "mysql-set-replication" do # ~FC009 - `sensitive` command "/usr/bin/mysql #{root_pass} < #{replication_sql}" action :nothing subscribes :run, resources("template[#{replication_sql}]"), :immediately diff --git a/spec/configure_server_spec.rb b/spec/configure_server_spec.rb index cb801809..a4f6aac8 100644 --- a/spec/configure_server_spec.rb +++ b/spec/configure_server_spec.rb @@ -28,7 +28,7 @@ ) resource = chef_run.template("/etc/mysql/my.cnf") - expect(resource).to notify("execute[setup mysql datadir]").to(:run).immediately # rubocop:disable LineLength + expect(resource).to notify("execute[setup mysql datadir]").to(:run).immediately # rubocop:disable LineLength expect(resource).to notify("service[mysql]").to(:restart).immediately end diff --git a/test/support/rubocop/disabled.yml b/test/support/rubocop/disabled.yml deleted file mode 100644 index b4fd70ad..00000000 --- a/test/support/rubocop/disabled.yml +++ /dev/null @@ -1,25 +0,0 @@ -Encoding: - Description: 'Use UTF-8 as the source file encoding.' - Enabled: false - -SymbolArray: - Description: 'Use %i or %I for arrays of symbols.' - Enabled: false - -##################### Rails ################################## - -DefaultScope: - Description: 'Checks if the argument passed to default_scope is a block.' - Enabled: false - -HasAndBelongsToMany: - Description: 'Prefer has_many :through to has_and_belongs_to_many.' - Enabled: false - -Output: - Description: 'Checks for calls to puts, print, etc.' - Enabled: false - -Validation: - Description: 'Use sexy validations.' - Enabled: false diff --git a/test/support/rubocop/enabled.yml b/test/support/rubocop/enabled.yml deleted file mode 100644 index df712be3..00000000 --- a/test/support/rubocop/enabled.yml +++ /dev/null @@ -1,652 +0,0 @@ -# These are all the cops that are enabled in the default configuration. - -AccessModifierIndentation: - Description: Check indentation of private/protected visibility modifiers. - Enabled: true - -AccessorMethodName: - Description: Check the naming of accessor methods for get_/set_. - Enabled: true - -Alias: - Description: 'Use alias_method instead of alias.' - Enabled: true - -AlignArray: - Description: >- - Align the elements of an array literal if they span more than - one line. - Enabled: true - -AlignHash: - Description: >- - Align the elements of a hash literal if they span more than - one line. - Enabled: true - -AlignParameters: - Description: >- - Align the parameters of a method call if they span more - than one line. - Enabled: true - -AndOr: - Description: 'Use &&/|| instead of and/or.' - Enabled: true - -AsciiComments: - Description: 'Use only ascii symbols in comments.' - Enabled: true - -AsciiIdentifiers: - Description: 'Use only ascii symbols in identifiers.' - Enabled: true - -Attr: - Description: 'Checks for uses of Module#attr.' - Enabled: true - -BeginBlock: - Description: 'Avoid the use of BEGIN blocks.' - Enabled: true - -BlockComments: - Description: 'Do not use block comments.' - Enabled: true - -BlockNesting: - Description: 'Avoid excessive block nesting' - Enabled: true - -Blocks: - Description: >- - Avoid using {...} for multi-line blocks (multiline chaining is - always ugly). - Prefer {...} over do...end for single-line blocks. - Enabled: true - -BracesAroundHashParameters: - Description: 'Enforce braces style inside hash parameters.' - Enabled: true - -CaseEquality: - Description: 'Avoid explicit use of the case equality operator(===).' - Enabled: true - -CaseIndentation: - Description: 'Indentation of when in a case/when/[else/]end.' - Enabled: true - -CharacterLiteral: - Description: 'Checks for uses of character literals.' - Enabled: true - -ClassAndModuleCamelCase: - Description: 'Use CamelCase for classes and modules.' - Enabled: true - -ClassLength: - Description: 'Avoid classes longer than 100 lines of code.' - Enabled: true - -ClassMethods: - Description: 'Use self when defining module/class methods.' - Enabled: true - -ClassVars: - Description: 'Avoid the use of class variables.' - Enabled: true - -CollectionMethods: - Description: 'Preferred collection methods.' - Enabled: true - -ColonMethodCall: - Description: 'Do not use :: for method call.' - Enabled: true - -CommentAnnotation: - Description: >- - Checks formatting of special comments - (TODO, FIXME, OPTIMIZE, HACK, REVIEW). - Enabled: true - -ConstantName: - Description: 'Constants should use SCREAMING_SNAKE_CASE.' - Enabled: true - -CyclomaticComplexity: - Description: 'Avoid complex methods.' - Enabled: true - -DefWithParentheses: - Description: 'Use def with parentheses when there are arguments.' - Enabled: true - -Documentation: - Description: 'Document classes and non-namespace modules.' - Enabled: true - -DotPosition: - Description: 'Checks the position of the dot in multi-line method calls.' - Enabled: true - -EmptyLineBetweenDefs: - Description: 'Use empty lines between defs.' - Enabled: true - -EmptyLines: - Description: "Don't use several empty lines in a row." - Enabled: true - -EmptyLinesAroundAccessModifier: - Description: "Keep blank lines around access modifiers." - Enabled: true - -EmptyLinesAroundBody: - Description: "Keeps track of empty lines around expression bodies." - Enabled: true - -EmptyLiteral: - Description: 'Prefer literals to Array.new/Hash.new/String.new.' - Enabled: true - -EndBlock: - Description: 'Avoid the use of END blocks.' - Enabled: true - -EndOfLine: - Description: 'Use Unix-style line endings.' - Enabled: true - -EvenOdd: - Description: 'Favor the use of Fixnum#even? && Fixnum#odd?' - Enabled: true - -FavorJoin: - Description: 'Use Array#join instead of Array#*.' - Enabled: true - -FavorUnlessOverNegatedIf: - Description: >- - Favor unless over if for negative conditions - (or control flow or). - Enabled: true - -FavorUntilOverNegatedWhile: - Description: 'Favor until over while for negative conditions.' - Enabled: true - -FileName: - Description: 'Use snake_case for source file names.' - Enabled: true - -FinalNewline: - Description: 'Checks for a final newline in a source file.' - Enabled: true - -FlipFlop: - Description: 'Checks for flip flops' - Enabled: true - -For: - Description: 'Checks use of for or each in multiline loops.' - Enabled: true - -FormatString: - Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.' - Enabled: true - -GlobalVars: - Description: 'Do not introduce global variables.' - Enabled: true - -HashMethods: - Description: 'Checks for use of deprecated Hash methods.' - Enabled: true - -HashSyntax: - Description: >- - Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax - { :a => 1, :b => 2 }. - Enabled: true - -IfUnlessModifier: - Description: >- - Favor modifier if/unless usage when you have a - single-line body. - Enabled: true - -IfWithSemicolon: - Description: 'Never use if x; .... Use the ternary operator instead.' - Enabled: true - -IndentationConsistency: - Description: 'Keep indentation straight.' - Enabled: true - -IndentationWidth: - Description: 'Use 2 spaces for indentation.' - Enabled: true - -IndentArray: - Description: >- - Checks the indentation of the first element in an array - literal. - Enabled: true - -IndentHash: - Description: 'Checks the indentation of the first key in a hash literal.' - Enabled: true - -Lambda: - Description: 'Use the new lambda literal syntax for single-line blocks.' - Enabled: true - -LambdaCall: - Description: 'Use lambda.call(...) instead of lambda.(...).' - Enabled: true - -LeadingCommentSpace: - Description: 'Comments should start with a space.' - Enabled: true - -LineEndConcatenation: - Description: 'Use \\ instead of + to concatenate two string literals at line end.' - Enabled: true - -LineLength: - Description: 'Limit lines to 79 characters.' - Enabled: true - -MethodCalledOnDoEndBlock: - Description: 'Avoid chaining a method call on a do...end block.' - Enabled: true - -MethodCallParentheses: - Description: 'Do not use parentheses for method calls with no arguments.' - Enabled: true - -MethodDefParentheses: - Description: >- - Checks if the method definitions have or don't have - parentheses. - Enabled: true - -MethodLength: - Description: 'Avoid methods longer than 10 lines of code.' - Enabled: true - -MethodName: - Description: 'Use the configured style when naming methods.' - Enabled: true - -ModuleFunction: - Description: 'Checks for usage of `extend self` in modules.' - Enabled: true - -MultilineBlockChain: - Description: 'Avoid multi-line chains of blocks.' - Enabled: true - -MultilineIfThen: - Description: 'Never use then for multi-line if/unless.' - Enabled: true - -MultilineTernaryOperator: - Description: >- - Avoid multi-line ?: (the ternary operator); - use if/unless instead. - Enabled: true - -NestedTernaryOperator: - Description: 'Use one expression per branch in a ternary operator.' - Enabled: true - -NilComparison: - Description: 'Prefer x.nil? to x == nil.' - Enabled: true - -Not: - Description: 'Use ! instead of not.' - Enabled: true - -NumericLiterals: - Description: >- - Add underscores to large numeric literals to improve their - readability. - Enabled: true - -OneLineConditional: - Description: >- - Favor the ternary operator(?:) over - if/then/else/end constructs. - Enabled: true - -OpMethod: - Description: 'When defining binary operators, name the argument other.' - Enabled: true - -ParameterLists: - Description: 'Avoid parameter lists longer than three or four parameters.' - Enabled: true - -ParenthesesAroundCondition: - Description: >- - Don't use parentheses around the condition of an - if/unless/while. - Enabled: true - -PerlBackrefs: - Description: 'Avoid Perl-style regex back references.' - Enabled: true - -PredicateName: - Description: 'Check the names of predicate methods.' - Enabled: true - -Proc: - Description: 'Use proc instead of Proc.new.' - Enabled: true - -RaiseArgs: - Description: 'Checks the arguments passed to raise/fail.' - Enabled: true - -RedundantBegin: - Description: "Don't use begin blocks when they are not needed." - Enabled: true - -RedundantException: - Description: "Checks for an obsolete RuntimeException argument in raise/fail." - Enabled: true - -RedundantReturn: - Description: "Don't use return where it's not required." - Enabled: true - -RedundantSelf: - Description: "Don't use self where it's not needed." - Enabled: true - -RegexpLiteral: - Description: >- - Use %r for regular expressions matching more than - `MaxSlashes` '/' characters. - Use %r only for regular expressions matching more than - `MaxSlashes` '/' character. - Enabled: true - -RescueModifier: - Description: 'Avoid using rescue in its modifier form.' - Enabled: true - -Semicolon: - Description: "Don't use semicolons to terminate expressions." - Enabled: true - -SignalException: - Description: 'Checks for proper usage of fail and raise.' - Enabled: true - -SingleLineBlockParams: - Description: 'Enforces the names of some block params.' - Enabled: true - -SingleLineMethods: - Description: 'Avoid single-line methods.' - Enabled: true - -SpaceAfterColon: - Description: 'Use spaces after colons.' - Enabled: true - -SpaceAfterComma: - Description: 'Use spaces after commas.' - Enabled: true - -SpaceAfterControlKeyword: - Description: 'Use spaces after if/elsif/unless/while/until/case/when.' - Enabled: true - -SpaceAfterMethodName: - Description: >- - Never put a space between a method name and the opening - parenthesis. - Enabled: true - -SpaceAfterNot: - Description: Tracks redundant space after the ! operator. - Enabled: true - -SpaceAfterSemicolon: - Description: 'Use spaces after semicolons.' - Enabled: true - -SpaceAroundBlockBraces: - Description: >- - Checks that block braces have or don't have surrounding space. - For blocks taking parameters, checks that the left brace has - or doesn't have trailing space. - Enabled: true - -SpaceAroundEqualsInParameterDefault: - Description: >- - Use spaces around the = operator when assigning default - values in def params. - Enabled: true - -SpaceAroundOperators: - Description: 'Use spaces around operators.' - Enabled: true - -SpaceBeforeModifierKeyword: - Description: 'Put a space before the modifier keyword.' - Enabled: true - -SpaceInsideBrackets: - Description: 'No spaces after [ or before ].' - Enabled: true - -SpaceInsideHashLiteralBraces: - Description: "Use spaces inside hash literal braces - or don't." - Enabled: true - -SpaceInsideParens: - Description: 'No spaces after ( or before ).' - Enabled: true - -SpecialGlobalVars: - Description: 'Avoid Perl-style global variables.' - Enabled: true - -StringLiterals: - Description: 'Checks if uses of quotes match the configured preference.' - Enabled: true - -Tab: - Description: 'No hard tabs.' - Enabled: true - -TrailingBlankLines: - Description: 'Checks for superfluous trailing blank lines.' - Enabled: true - -TrailingComma: - Description: 'Checks for trailing comma in parameter lists and literals.' - Enabled: true - -TrailingWhitespace: - Description: 'Avoid trailing whitespace.' - Enabled: true - -TrivialAccessors: - Description: 'Prefer attr_* methods to trivial readers/writers.' - Enabled: true - -UnlessElse: - Description: >- - Never use unless with else. Rewrite these with the positive - case first. - Enabled: true - -VariableInterpolation: - Description: >- - Don't interpolate global, instance and class variables - directly in strings. - Enabled: true - -VariableName: - Description: 'Use the configured style when naming variables.' - Enabled: true - -WhenThen: - Description: 'Use when x then ... for one-line cases.' - Enabled: true - -WhileUntilDo: - Description: 'Checks for redundant do after while or until.' - Enabled: true - -WhileUntilModifier: - Description: >- - Favor modifier while/until usage when you have a - single-line body. - Enabled: true - -WordArray: - Description: 'Use %w or %W for arrays of words.' - Enabled: true - -#################### Lint ################################ -### Warnings - -AmbiguousOperator: - Description: >- - Checks for ambiguous operators in the first argument of a - method invocation without parentheses. - Enabled: true - -AmbiguousRegexpLiteral: - Description: >- - Checks for ambiguous regexp literals in the first argument of - a method invocation without parenthesis. - Enabled: true - -AssignmentInCondition: - Description: "Don't use assignment in conditions." - Enabled: true - -BlockAlignment: - Description: 'Align block ends correctly.' - Enabled: true - -ConditionPosition: - Description: 'Checks for condition placed in a confusing position relative to the keyword.' - Enabled: true - -Debugger: - Description: 'Check for debugger calls.' - Enabled: true - -DeprecatedClassMethods: - Description: 'Check for deprecated class method calls.' - Enabled: true - -ElseLayout: - Description: 'Check for odd code arrangement in an else block.' - Enabled: true - -EmptyEnsure: - Description: 'Checks for empty ensure block.' - Enabled: true - -EndAlignment: - Description: 'Align ends correctly.' - Enabled: true - -EndInMethod: - Description: 'END blocks should not be placed inside method definitions.' - Enabled: true - -EnsureReturn: - Description: 'Never use return in an ensure block.' - Enabled: true - -Eval: - Description: 'The use of eval represents a serious security risk.' - Enabled: true - -HandleExceptions: - Description: "Don't suppress exception." - Enabled: true - -InvalidCharacterLiteral: - Description: >- - Checks for invalid character literals with a non-escaped - whitespace character. - Enabled: true - -LiteralInCondition: - Description: 'Checks of literals used in conditions.' - Enabled: true - -LiteralInInterpolation: - Description: 'Checks for literals used in interpolation.' - Enabled: true - -Loop: - Description: >- - Use Kernel#loop with break rather than begin/end/until or - begin/end/while for post-loop tests. - Enabled: true - -ParenthesesAsGroupedExpression: - Description: >- - Checks for method calls with a space before the opening - parenthesis. - Enabled: true - -RequireParentheses: - Description: >- - Use parentheses in the method call to avoid confusion - about precedence. - Enabled: true - -RescueException: - Description: 'Avoid rescuing the Exception class.' - Enabled: true - -ShadowingOuterLocalVariable: - Description: >- - Do not use the same name as outer local variable - for block arguments or block local variables. - Enabled: true - -StringConversionInInterpolation: - Description: 'Checks for Object#to_s usage in string interpolation.' - Enabled: true - -UnreachableCode: - Description: 'Unreachable code.' - Enabled: true - -UselessAssignment: - Description: 'Checks for useless assignment to a local variable.' - Enabled: true - -UselessComparison: - Description: 'Checks for comparison of something with itself.' - Enabled: true - -UselessElseWithoutRescue: - Description: 'Checks for useless `else` in `begin..end` without `rescue`.' - Enabled: true - -UselessSetterCall: - Description: 'Checks for useless setter call to a local variable.' - Enabled: true - -Void: - Description: 'Possible use of operator/literal/variable in void context.' - Enabled: true From 6407bf1d0a30040cd2eb964b3c8a5ff15dd3ab83 Mon Sep 17 00:00:00 2001 From: Grant Ridder Date: Mon, 30 Jan 2017 02:08:45 -0800 Subject: [PATCH 057/300] Fix FC058, FC064, and FC065 Foodcritic rules --- libraries/provider_mysql2_chef_gem.rb | 4 ++-- libraries/provider_mysql_chef_gem.rb | 4 ++-- metadata.rb | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/provider_mysql2_chef_gem.rb b/libraries/provider_mysql2_chef_gem.rb index 4849e9c8..01c77713 100644 --- a/libraries/provider_mysql2_chef_gem.rb +++ b/libraries/provider_mysql2_chef_gem.rb @@ -9,7 +9,7 @@ def whyrun_supported? true end - def action_install + action :install do converge_by "install mysql2 chef_gem and dependencies" do recipe_eval do run_context.include_recipe "build-essential" @@ -22,7 +22,7 @@ def action_install end end - def action_remove + action :remove do chef_gem "mysql2" do action :remove end diff --git a/libraries/provider_mysql_chef_gem.rb b/libraries/provider_mysql_chef_gem.rb index 63623c29..a54c45fa 100644 --- a/libraries/provider_mysql_chef_gem.rb +++ b/libraries/provider_mysql_chef_gem.rb @@ -9,7 +9,7 @@ def whyrun_supported? true end - def action_install + action :install do converge_by "install mysql chef_gem and dependencies" do recipe_eval do run_context.include_recipe "build-essential" @@ -22,7 +22,7 @@ def action_install end end - def action_remove + action :remove do chef_gem "mysql" do action :remove end diff --git a/metadata.rb b/metadata.rb index 6ea49054..a5afb99b 100644 --- a/metadata.rb +++ b/metadata.rb @@ -32,3 +32,6 @@ supports "scientific" supports "fedora" supports "redhat" + +source_url "https://github.com/phlipper/chef-percona" if respond_to?(:source_url) +issues_url "https://github.com/phlipper/chef-percona/issues" if respond_to?(:issues_url) From aed1c988960d963c7a152269287ba93916314feb Mon Sep 17 00:00:00 2001 From: Grant Ridder Date: Mon, 30 Jan 2017 02:28:04 -0800 Subject: [PATCH 058/300] Add license_finder approval --- Rakefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Rakefile b/Rakefile index af455346..527ae384 100644 --- a/Rakefile +++ b/Rakefile @@ -10,6 +10,8 @@ task all_tests: [ # license finder task :license_finder do + sh "bundle exec license_finder approval add ffi" # Used by Oahi + sh "bundle exec license_finder approval add rubyzip" # Used by license_finder sh "bundle exec license_finder --quiet" end From 0f2f90878f799f196308c2781c6b551cc3da1e9e Mon Sep 17 00:00:00 2001 From: Cyberflow Date: Fri, 17 Nov 2017 14:49:32 +0200 Subject: [PATCH 059/300] update depends for yum --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 6ea49054..731e07a2 100644 --- a/metadata.rb +++ b/metadata.rb @@ -21,7 +21,7 @@ depends "apt", ">= 2.7.0" depends "build-essential" depends "openssl" -depends "yum", "~> 3.0" +depends "yum", "~> 4.1" depends "yum-epel" depends "chef-vault" From eee6e1c86290e5fea0bd04654c29bd6b3dedf28c Mon Sep 17 00:00:00 2001 From: Cyberflow Date: Thu, 14 Dec 2017 15:17:21 +0200 Subject: [PATCH 060/300] update cookbook version --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 731e07a2..1fd84786 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license "MIT" description "Installs Percona MySQL client and server" long_description "Please refer to README.md" -version "0.16.1" +version "0.16.2" recipe "percona", "Includes the client recipe to configure a client" recipe "percona::package_repo", "Sets up the package repository and installs dependent packages" From 0ff1da3387f6d8d63ecac355496a065becd975d9 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Thu, 14 Jun 2018 20:32:18 +0100 Subject: [PATCH 061/300] Add delivery and all the standard ChefDK tools cookstyle all the things --- .delivery/project.toml | 1 + .github/ISSUE_TEMPLATE.md | 20 + .github/PULL_REQUEST_TEMPLATE.md | 13 + .github/lock.yml | 28 ++ .gitignore | 54 ++- .kitchen.dokken.yml | 73 ++++ .rubocop.yml | 30 -- .ruby-version | 1 - Berksfile | 6 +- Gemfile | 21 +- Rakefile | 40 -- attributes/client.rb | 58 +-- attributes/default.rb | 362 +++++++++--------- attributes/monitoring.rb | 4 +- attributes/package_repo.rb | 24 +- chefignore | 107 ++++++ libraries/config_helper.rb | 42 +- libraries/passwords.rb | 28 +- libraries/provider_mysql2_chef_gem.rb | 10 +- libraries/provider_mysql_chef_gem.rb | 10 +- metadata.rb | 57 ++- recipes/access_grants.rb | 26 +- recipes/backup.rb | 18 +- recipes/client.rb | 6 +- recipes/cluster.rb | 42 +- recipes/configure_server.rb | 144 +++---- recipes/default.rb | 2 +- recipes/monitoring.rb | 4 +- recipes/package_repo.rb | 46 +-- recipes/replication.rb | 22 +- recipes/server.rb | 42 +- recipes/ssl.rb | 24 +- recipes/toolkit.rb | 6 +- spec/access_grants_spec.rb | 26 +- spec/backup_spec.rb | 22 +- spec/client_spec.rb | 40 +- spec/cluster_spec.rb | 58 +-- spec/configure_server_spec.rb | 260 ++++++------- spec/default_spec.rb | 6 +- spec/monitoring_spec.rb | 10 +- spec/package_repo_spec.rb | 22 +- spec/replication_spec.rb | 40 +- spec/server_spec.rb | 68 ++-- spec/spec_helper.rb | 10 +- spec/ssl_spec.rb | 62 +-- spec/toolkit_spec.rb | 22 +- test/.chef/knife.rb | 2 - .../serverspec/localhost/client_55_spec.rb | 32 +- .../serverspec/localhost/client_56_spec.rb | 32 +- .../serverspec/localhost/server_55_spec.rb | 132 +++---- .../serverspec/localhost/server_56_spec.rb | 132 +++---- 51 files changed, 1266 insertions(+), 1081 deletions(-) create mode 100644 .delivery/project.toml create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/lock.yml create mode 100644 .kitchen.dokken.yml delete mode 100644 .rubocop.yml delete mode 100644 .ruby-version delete mode 100644 Rakefile create mode 100644 chefignore delete mode 100644 test/.chef/knife.rb diff --git a/.delivery/project.toml b/.delivery/project.toml new file mode 100644 index 00000000..6d5e3617 --- /dev/null +++ b/.delivery/project.toml @@ -0,0 +1 @@ +remote_file = "https://raw.githubusercontent.com/chef-cookbooks/community_cookbook_tools/master/delivery/project.toml" diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..651e753a --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,20 @@ +### Cookbook version +[Version of the cookbook where you are encountering the issue] + +### Chef-client version +[Version of chef-client in your environment] + +### Platform Details +[Operating system distribution and release version. Cloud provider if running in the cloud] + +### Scenario: +[What you are trying to achieve and you can't?] + +### Steps to Reproduce: +[If you are filing an issue what are the things we need to do in order to repro your problem? How are you using this cookbook or any resources it includes?] + +### Expected Result: +[What are you expecting to happen as the consequence of above reproduction steps?] + +### Actual Result: +[What actually happens after the reproduction steps? Include the error output or a link to a gist if possible.] diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..bce1ae57 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,13 @@ +### Description + +[Describe what this change achieves] + +### Issues Resolved + +[List any existing issues this PR resolves] + +### Contribution Check List + +- [ ] All tests pass. +- [ ] New functionality includes testing. +- [ ] New functionality has been documented in the README if applicable \ No newline at end of file diff --git a/.github/lock.yml b/.github/lock.yml new file mode 100644 index 00000000..97037158 --- /dev/null +++ b/.github/lock.yml @@ -0,0 +1,28 @@ +# Configuration for lock-threads - https://github.com/dessant/lock-threads + +# Number of days of inactivity before a closed issue or pull request is locked +daysUntilLock: 365 + +# Issues and pull requests with these labels will not be locked. Set to `[]` to disable +exemptLabels: [] + +# Label to add before locking, such as `outdated`. Set to `false` to disable +lockLabel: false + +# Comment to post before locking. Set to `false` to disable +lockComment: > + This thread has been automatically locked since there has not been + any recent activity after it was closed. Please open a new issue for + related bugs. + +# Limit to only `issues` or `pulls` +# only: issues + +# Optionally, specify configuration settings just for `issues` or `pulls` +# issues: +# exemptLabels: +# - help-wanted +# lockLabel: outdated + +# pulls: +# daysUntilLock: 30 diff --git a/.gitignore b/.gitignore index ea1344d4..2230a419 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,52 @@ -cookbooks/* +*.rbc +.config +coverage +InstalledFiles +lib/bundler/man +pkg +rdoc +spec/reports +test/tmp +test/version_tmp tmp +_Store +.DS_Store +*~ +*# +.#* +\#*# +.*.sw[a-z] +*.un~ +*.tmp +*.bk +*.bkup + +# ruby/bundler files +.ruby-version +.ruby-gemset +.rvmrc +Gemfile.lock +.bundle +*.gem + +# YARD artifacts +.yardoc +_yardoc +doc/ +.idea + +# chef stuff +Berksfile.lock +.kitchen +.kitchen.local.yml +vendor/ +.coverage/ +.zero-knife.rb +Policyfile.lock.json +Cheffile.lock .librarian/ + +# vagrant stuff +.vagrant/ +.vagrant.d/ .kitchen/ -.kitchen.local.yml -Berksfile.lock -Gemfile.lock -.bundle/ diff --git a/.kitchen.dokken.yml b/.kitchen.dokken.yml new file mode 100644 index 00000000..1b2e6b51 --- /dev/null +++ b/.kitchen.dokken.yml @@ -0,0 +1,73 @@ +driver: + name: dokken + privileged: true # because Docker and SystemD/Upstart + +transport: + name: dokken + +provisioner: + name: dokken + product_name: chef + product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> + install_strategy: once + +platforms: +- name: debian-8 + driver: + image: dokken/debian-8 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + +- name: debian-9 + driver: + image: dokken/debian-9 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + +- name: centos-6 + driver: + image: dokken/centos-6 + platform: rhel + pid_one_command: /sbin/init + +- name: centos-7 + driver: + image: dokken/centos-7 + platform: rhel + pid_one_command: /usr/lib/systemd/systemd + +- name: fedora-26 + driver: + image: dokken/fedora-26 + pid_one_command: /usr/lib/systemd/systemd + +- name: fedora-27 + driver: + image: dokken/fedora-27 + pid_one_command: /usr/lib/systemd/systemd + +- name: ubuntu-14.04 + driver: + image: dokken/ubuntu-14.04 + pid_one_command: /sbin/init + intermediate_instructions: + - RUN /usr/bin/apt-get update + +- name: ubuntu-16.04 + driver: + image: dokken/ubuntu-16.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + +- name: opensuse-leap + driver: + image: dokken/opensuse-leap + pid_one_command: /bin/systemd + +- name: amazonlinux + driver: + image: dokken/amazonlinux + pid_one_command: /sbin/init diff --git a/.rubocop.yml b/.rubocop.yml deleted file mode 100644 index eef2091d..00000000 --- a/.rubocop.yml +++ /dev/null @@ -1,30 +0,0 @@ -AllCops: - DisplayCopNames: true - Exclude: - - ".bundle/**/*" - - ".kitchen/**/*" - - "vendor/**/*" - -Metrics/BlockLength: - Enabled: false - -Metrics/LineLength: - Max: 80 - Exclude: - - "**/attributes/*.rb" - - "**/metadata.rb" - -Style/FrozenStringLiteralComment: - Enabled: false - -Style/StringLiterals: - EnforcedStyle: double_quotes - -Style/StringLiteralsInInterpolation: - EnforcedStyle: double_quotes - -Style/PercentLiteralDelimiters: - PreferredDelimiters: - "%r": "()" - "%w": "[]" # Arrays use brackets - "%W": "[]" # Arrays use brackets diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 2bf1c1cc..00000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.3.1 diff --git a/Berksfile b/Berksfile index 967b9a78..e09849c7 100644 --- a/Berksfile +++ b/Berksfile @@ -1,3 +1,7 @@ -source "https://supermarket.chef.io" +source 'https://supermarket.chef.io' metadata + +group :integration do + cookbook 'test', path: 'test/fixtures/cookbooks/test' +end diff --git a/Gemfile b/Gemfile index b4041f7e..20b4d4ae 100644 --- a/Gemfile +++ b/Gemfile @@ -1,20 +1 @@ -source "https://rubygems.org" - -chef_version = ENV.fetch("CHEF_VERSION", "12.18.31") - -gem "chef", "~> #{chef_version}" -gem "chef-vault" -gem "chefspec" -gem "berkshelf" -gem "foodcritic" -gem "license_finder" -gem "rake" -gem "rubocop" -gem "serverspec" - -group :integration do - gem "busser-serverspec" - gem "kitchen-docker" - gem "kitchen-sync" - gem "test-kitchen" -end +source 'https://rubygems.org' diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 527ae384..00000000 --- a/Rakefile +++ /dev/null @@ -1,40 +0,0 @@ -task default: "test" - -desc "Run all tests except `kitchen`" -task test: [:rubocop, :foodcritic, :chefspec] - -desc "Run all tests" -task all_tests: [ - :license_finder, :rubocop, :foodcritic, :chefspec, "kitchen:all" -] - -# license finder -task :license_finder do - sh "bundle exec license_finder approval add ffi" # Used by Oahi - sh "bundle exec license_finder approval add rubyzip" # Used by license_finder - sh "bundle exec license_finder --quiet" -end - -# rubocop style checker -require "rubocop/rake_task" -RuboCop::RakeTask.new - -# foodcritic chef lint -require "foodcritic" -FoodCritic::Rake::LintTask.new do |t| - t.options = { fail_tags: ["any"] } -end - -# chefspec unit tests -require "rspec/core/rake_task" -RSpec::Core::RakeTask.new(:chefspec) do |t| - t.rspec_opts = "--color --format progress" -end - -# test-kitchen integration tests -begin - require "kitchen/rake_tasks" - Kitchen::RakeTasks.new -rescue LoadError - task("kitchen:all") { puts "Unable to run `test-kitchen`" } -end diff --git a/attributes/client.rb b/attributes/client.rb index cddfd438..fb07dc04 100644 --- a/attributes/client.rb +++ b/attributes/client.rb @@ -4,40 +4,40 @@ # # install vs. upgrade packages -default["percona"]["client"]["package_action"] = "install" +default['percona']['client']['package_action'] = 'install' version = value_for_platform_family( - "debian" => node["percona"]["version"], - "rhel" => node["percona"]["version"].tr(".", "") + 'debian' => node['percona']['version'], + 'rhel' => node['percona']['version'].tr('.', '') ) -case node["platform_family"] -when "debian" +case node['platform_family'] +when 'debian' abi_version = case version - when "5.5" then "18" - when "5.6" then "18.1" - else "" + when '5.5' then '18' + when '5.6' then '18.1' + else '' end - if Array(node["percona"]["server"]["role"]).include?("cluster") - default["percona"]["client"]["packages"] = %W[ - libperconaserverclient#{abi_version}-dev percona-xtradb-cluster-client-#{version} - ] - else - default["percona"]["client"]["packages"] = %W[ - libperconaserverclient#{abi_version}-dev percona-server-client-#{version} - ] - end -when "rhel" - if Array(node["percona"]["server"]["role"]).include?("cluster") - default["percona"]["client"]["packages"] = %W[ - Percona-XtraDB-Cluster-client-#{version} - ] - #Percona-XtraDB-Cluster-devel-#{version} - else - default["percona"]["client"]["packages"] = %W[ - Percona-Server-client-#{version} - ] - #Percona-Server-devel-#{version} - end + default['percona']['client']['packages'] = if Array(node['percona']['server']['role']).include?('cluster') + %W( + libperconaserverclient#{abi_version}-dev percona-xtradb-cluster-client-#{version} + ) + else + %W( + libperconaserverclient#{abi_version}-dev percona-server-client-#{version} + ) + end +when 'rhel' + default['percona']['client']['packages'] = if Array(node['percona']['server']['role']).include?('cluster') + %W( + Percona-XtraDB-Cluster-client-#{version} + ) + # Percona-XtraDB-Cluster-devel-#{version} + else + %W( + Percona-Server-client-#{version} + ) + # Percona-Server-devel-#{version} + end end diff --git a/attributes/default.rb b/attributes/default.rb index a1f6f17d..f33eb77b 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -12,228 +12,228 @@ ::Chef::Node.send(:include, ::Chef::OpenSSL::Password) end -default["percona"]["version"] = "5.6" +default['percona']['version'] = '5.6' # Always restart percona on configuration changes -default["percona"]["auto_restart"] = true +default['percona']['auto_restart'] = true # SELinux module URL # If interested, use "https://github.com/gguillen/selinux_percona-pxc-56-cluster/raw/master/percona-pxc-56-cluster.pp" -default["percona"]["selinux_module_url"] = "" - -case node["platform_family"] -when "debian" - default["percona"]["server"]["socket"] = "/var/run/mysqld/mysqld.sock" - default["percona"]["server"]["default_storage_engine"] = "InnoDB" - default["percona"]["server"]["includedir"] = "/etc/mysql/conf.d/" - default["percona"]["server"]["pidfile"] = "/var/run/mysqld/mysqld.pid" -when "rhel" - default["percona"]["server"]["socket"] = "/var/lib/mysql/mysql.sock" - default["percona"]["server"]["default_storage_engine"] = "innodb" - default["percona"]["server"]["includedir"] = "" - default["percona"]["server"]["pidfile"] = "/var/lib/mysql/mysqld.pid" +default['percona']['selinux_module_url'] = '' + +case node['platform_family'] +when 'debian' + default['percona']['server']['socket'] = '/var/run/mysqld/mysqld.sock' + default['percona']['server']['default_storage_engine'] = 'InnoDB' + default['percona']['server']['includedir'] = '/etc/mysql/conf.d/' + default['percona']['server']['pidfile'] = '/var/run/mysqld/mysqld.pid' +when 'rhel' + default['percona']['server']['socket'] = '/var/lib/mysql/mysql.sock' + default['percona']['server']['default_storage_engine'] = 'innodb' + default['percona']['server']['includedir'] = '' + default['percona']['server']['pidfile'] = '/var/lib/mysql/mysqld.pid' end # Cookbook Settings -default["percona"]["main_config_file"] = value_for_platform_family( - "debian" => "/etc/mysql/my.cnf", - "rhel" => "/etc/my.cnf" +default['percona']['main_config_file'] = value_for_platform_family( + 'debian' => '/etc/mysql/my.cnf', + 'rhel' => '/etc/my.cnf' ) -default["percona"]["main_config_template"]["cookbook"] = "percona" -default["percona"]["main_config_template"]["source"]["default"] = "my.cnf.main.erb" -default["percona"]["main_config_template"]["source"]["cluster"] = "my.cnf.cluster.erb" -default["percona"]["encrypted_data_bag"] = "passwords" -default["percona"]["encrypted_data_bag_secret_file"] = "" -default["percona"]["encrypted_data_bag_item_mysql"] = "mysql" -default["percona"]["encrypted_data_bag_item_system"] = "system" -default["percona"]["encrypted_data_bag_item_ssl_replication"] = "ssl_replication" -default["percona"]["use_chef_vault"] = false -default["percona"]["skip_passwords"] = false -default["percona"]["skip_configure"] = false +default['percona']['main_config_template']['cookbook'] = 'percona' +default['percona']['main_config_template']['source']['default'] = 'my.cnf.main.erb' +default['percona']['main_config_template']['source']['cluster'] = 'my.cnf.cluster.erb' +default['percona']['encrypted_data_bag'] = 'passwords' +default['percona']['encrypted_data_bag_secret_file'] = '' +default['percona']['encrypted_data_bag_item_mysql'] = 'mysql' +default['percona']['encrypted_data_bag_item_system'] = 'system' +default['percona']['encrypted_data_bag_item_ssl_replication'] = 'ssl_replication' +default['percona']['use_chef_vault'] = false +default['percona']['skip_passwords'] = false +default['percona']['skip_configure'] = false # Start percona server on boot -default["percona"]["server"]["enable"] = true +default['percona']['server']['enable'] = true # install vs. upgrade packages -default["percona"]["server"]["package_action"] = "install" +default['percona']['server']['package_action'] = 'install' # Basic Settings -default["percona"]["server"]["role"] = ["standalone"] -default["percona"]["server"]["username"] = "mysql" -default["percona"]["server"]["datadir"] = "/var/lib/mysql" -default["percona"]["server"]["logdir"] = "/var/log/mysql" -default["percona"]["server"]["tmpdir"] = "/tmp" -default["percona"]["server"]["slave_load_tmpdir"] = "/tmp" -default["percona"]["server"]["debian_username"] = "debian-sys-maint" -default["percona"]["server"]["jemalloc"] = false -default["percona"]["server"]["jemalloc_lib"] = value_for_platform_family( - "debian" => value_for_platform( - "ubuntu" => { - "14.04" => "/usr/lib/x86_64-linux-gnu/libjemalloc.so.1", - "12.04" => "/usr/lib/libjemalloc.so.1" +default['percona']['server']['role'] = ['standalone'] +default['percona']['server']['username'] = 'mysql' +default['percona']['server']['datadir'] = '/var/lib/mysql' +default['percona']['server']['logdir'] = '/var/log/mysql' +default['percona']['server']['tmpdir'] = '/tmp' +default['percona']['server']['slave_load_tmpdir'] = '/tmp' +default['percona']['server']['debian_username'] = 'debian-sys-maint' +default['percona']['server']['jemalloc'] = false +default['percona']['server']['jemalloc_lib'] = value_for_platform_family( + 'debian' => value_for_platform( + 'ubuntu' => { + '14.04' => '/usr/lib/x86_64-linux-gnu/libjemalloc.so.1', + '12.04' => '/usr/lib/libjemalloc.so.1', } ), - "rhel" => "/usr/lib64/libjemalloc.so.1" + 'rhel' => '/usr/lib64/libjemalloc.so.1' ) -default["percona"]["server"]["nice"] = 0 -default["percona"]["server"]["open_files_limit"] = 16_384 -default["percona"]["server"]["hostname"] = "localhost" -default["percona"]["server"]["basedir"] = "/usr" -default["percona"]["server"]["port"] = 3306 -default["percona"]["server"]["language"] = "/usr/share/mysql/english" -default["percona"]["server"]["character_set"] = "utf8" -default["percona"]["server"]["collation"] = "utf8_unicode_ci" -default["percona"]["server"]["skip_name_resolve"] = false -default["percona"]["server"]["skip_external_locking"] = true -default["percona"]["server"]["net_read_timeout"] = 120 -default["percona"]["server"]["connect_timeout"] = 10 -default["percona"]["server"]["wait_timeout"] = 28_800 -default["percona"]["server"]["old_passwords"] = 0 -default["percona"]["server"]["bind_address"] = "127.0.0.1" -default["percona"]["server"]["federated"] = false -default["percona"]["server"]["report_host"] = "" - -%w[debian_password root_password].each do |attribute| - next if attribute?(node["percona"]["server"][attribute]) - default["percona"]["server"][attribute] = secure_password +default['percona']['server']['nice'] = 0 +default['percona']['server']['open_files_limit'] = 16_384 +default['percona']['server']['hostname'] = 'localhost' +default['percona']['server']['basedir'] = '/usr' +default['percona']['server']['port'] = 3306 +default['percona']['server']['language'] = '/usr/share/mysql/english' +default['percona']['server']['character_set'] = 'utf8' +default['percona']['server']['collation'] = 'utf8_unicode_ci' +default['percona']['server']['skip_name_resolve'] = false +default['percona']['server']['skip_external_locking'] = true +default['percona']['server']['net_read_timeout'] = 120 +default['percona']['server']['connect_timeout'] = 10 +default['percona']['server']['wait_timeout'] = 28_800 +default['percona']['server']['old_passwords'] = 0 +default['percona']['server']['bind_address'] = '127.0.0.1' +default['percona']['server']['federated'] = false +default['percona']['server']['report_host'] = '' + +%w(debian_password root_password).each do |attribute| + next if attribute?(node['percona']['server'][attribute]) + default['percona']['server'][attribute] = secure_password end # Fine Tuning -default["percona"]["server"]["key_buffer_size"] = "16M" -default["percona"]["server"]["max_allowed_packet"] = "64M" -default["percona"]["server"]["thread_stack"] = "192K" -default["percona"]["server"]["query_alloc_block_size"] = "16K" -default["percona"]["server"]["memlock"] = false -default["percona"]["server"]["transaction_isolation"] = "REPEATABLE-READ" -default["percona"]["server"]["tmp_table_size"] = "64M" -default["percona"]["server"]["max_heap_table_size"] = "64M" -default["percona"]["server"]["sort_buffer_size"] = "8M" -default["percona"]["server"]["join_buffer_size"] = "8M" -default["percona"]["server"]["thread_cache_size"] = 16 -default["percona"]["server"]["back_log"] = -1 # <5.6.6, use 50 -default["percona"]["server"]["max_connections"] = 30 -default["percona"]["server"]["max_connect_errors"] = 9_999_999 -default["percona"]["server"]["sql_modes"] = [] -default["percona"]["server"]["table_cache"] = 8192 -default["percona"]["server"]["table_definition_cache"] = "-1" # <5.6, use 4096 -default["percona"]["server"]["group_concat_max_len"] = 4096 -default["percona"]["server"]["expand_fast_index_creation"] = false -default["percona"]["server"]["read_rnd_buffer_size"] = 262_144 -default["percona"]["server"]["sysdate_is_now"] = false +default['percona']['server']['key_buffer_size'] = '16M' +default['percona']['server']['max_allowed_packet'] = '64M' +default['percona']['server']['thread_stack'] = '192K' +default['percona']['server']['query_alloc_block_size'] = '16K' +default['percona']['server']['memlock'] = false +default['percona']['server']['transaction_isolation'] = 'REPEATABLE-READ' +default['percona']['server']['tmp_table_size'] = '64M' +default['percona']['server']['max_heap_table_size'] = '64M' +default['percona']['server']['sort_buffer_size'] = '8M' +default['percona']['server']['join_buffer_size'] = '8M' +default['percona']['server']['thread_cache_size'] = 16 +default['percona']['server']['back_log'] = -1 # <5.6.6, use 50 +default['percona']['server']['max_connections'] = 30 +default['percona']['server']['max_connect_errors'] = 9_999_999 +default['percona']['server']['sql_modes'] = [] +default['percona']['server']['table_cache'] = 8192 +default['percona']['server']['table_definition_cache'] = '-1' # <5.6, use 4096 +default['percona']['server']['group_concat_max_len'] = 4096 +default['percona']['server']['expand_fast_index_creation'] = false +default['percona']['server']['read_rnd_buffer_size'] = 262_144 +default['percona']['server']['sysdate_is_now'] = false # Query Cache Configuration -default["percona"]["server"]["query_cache_size"] = "64M" -default["percona"]["server"]["query_cache_limit"] = "2M" -default["percona"]["server"]["query_cache_type"] = "1" +default['percona']['server']['query_cache_size'] = '64M' +default['percona']['server']['query_cache_limit'] = '2M' +default['percona']['server']['query_cache_type'] = '1' # Logging and Replication -default["percona"]["server"]["sync_binlog"] = (node["percona"]["server"]["role"] == "cluster" ? 0 : 1) -default["percona"]["server"]["slow_query_log"] = 1 -default["percona"]["server"]["slow_query_logdir"] = "/var/log/mysql" -default["percona"]["server"]["slow_query_log_file"] = "#{node["percona"]["server"]["slow_query_logdir"]}/mysql-slow.log" -default["percona"]["server"]["long_query_time"] = 2 -default["percona"]["server"]["log_queries_not_using_indexes"] = 0 -default["percona"]["server"]["server_id"] = 1 -default["percona"]["server"]["binlog_rows_query_log_events"] = false -default["percona"]["server"]["binlog_do_db"] = [] -default["percona"]["server"]["binlog_ignore_db"] = [] -default["percona"]["server"]["expire_logs_days"] = 10 -default["percona"]["server"]["gtid_mode"] = "OFF" -default["percona"]["server"]["enforce_gtid_consistency"] = false -default["percona"]["server"]["max_binlog_size"] = "100M" -default["percona"]["server"]["binlog_cache_size"] = "1M" -default["percona"]["server"]["binlog_format"] = "ROW" # Alt. MIXED -default["percona"]["server"]["binlog_checksum"] = "CRC32" -default["percona"]["server"]["log_bin"] = 1 # enable/disable bin log -default["percona"]["server"]["log_bin_basename"] = "master-bin" # 5.6~> default: datadir + '/' + hostname + '-bin' -default["percona"]["server"]["relay_log"] = "slave-relay-bin" -default["percona"]["server"]["log_slave_updates"] = false -default["percona"]["server"]["log_warnings"] = true -default["percona"]["server"]["log_long_format"] = false -default["percona"]["server"]["bulk_insert_buffer_size"] = "64M" -default["percona"]["server"]["sync_master_info"] = false -default["percona"]["server"]["sync_relay_log"] = false -default["percona"]["server"]["sync_relay_log_info"] = false -default["percona"]["server"]["master_verify_checksum"] = false -default["percona"]["server"]["slave_net_timeout"] = 3600 -default["percona"]["server"]["slave_sql_verify_checksum"] = false +default['percona']['server']['sync_binlog'] = (node['percona']['server']['role'] == 'cluster' ? 0 : 1) +default['percona']['server']['slow_query_log'] = 1 +default['percona']['server']['slow_query_logdir'] = '/var/log/mysql' +default['percona']['server']['slow_query_log_file'] = "#{node['percona']['server']['slow_query_logdir']}/mysql-slow.log" +default['percona']['server']['long_query_time'] = 2 +default['percona']['server']['log_queries_not_using_indexes'] = 0 +default['percona']['server']['server_id'] = 1 +default['percona']['server']['binlog_rows_query_log_events'] = false +default['percona']['server']['binlog_do_db'] = [] +default['percona']['server']['binlog_ignore_db'] = [] +default['percona']['server']['expire_logs_days'] = 10 +default['percona']['server']['gtid_mode'] = 'OFF' +default['percona']['server']['enforce_gtid_consistency'] = false +default['percona']['server']['max_binlog_size'] = '100M' +default['percona']['server']['binlog_cache_size'] = '1M' +default['percona']['server']['binlog_format'] = 'ROW' # Alt. MIXED +default['percona']['server']['binlog_checksum'] = 'CRC32' +default['percona']['server']['log_bin'] = 1 # enable/disable bin log +default['percona']['server']['log_bin_basename'] = 'master-bin' # 5.6~> default: datadir + '/' + hostname + '-bin' +default['percona']['server']['relay_log'] = 'slave-relay-bin' +default['percona']['server']['log_slave_updates'] = false +default['percona']['server']['log_warnings'] = true +default['percona']['server']['log_long_format'] = false +default['percona']['server']['bulk_insert_buffer_size'] = '64M' +default['percona']['server']['sync_master_info'] = false +default['percona']['server']['sync_relay_log'] = false +default['percona']['server']['sync_relay_log_info'] = false +default['percona']['server']['master_verify_checksum'] = false +default['percona']['server']['slave_net_timeout'] = 3600 +default['percona']['server']['slave_sql_verify_checksum'] = false # MyISAM Specific -default["percona"]["server"]["myisam_recover_options"] = "BACKUP" -default["percona"]["server"]["myisam_sort_buffer_size"] = "128M" -default["percona"]["server"]["myisam_max_sort_file_size"] = "10G" -default["percona"]["server"]["myisam_repair_threads"] = 1 -default["percona"]["server"]["read_buffer_size"] = "8M" +default['percona']['server']['myisam_recover_options'] = 'BACKUP' +default['percona']['server']['myisam_sort_buffer_size'] = '128M' +default['percona']['server']['myisam_max_sort_file_size'] = '10G' +default['percona']['server']['myisam_repair_threads'] = 1 +default['percona']['server']['read_buffer_size'] = '8M' # InnoDB Specific -default["percona"]["server"]["skip_innodb"] = false -default["percona"]["server"]["innodb_additional_mem_pool_size"] = "32M" -default["percona"]["server"]["innodb_buffer_pool_size"] = "128M" -default["percona"]["server"]["innodb_buffer_pool_instances"] = 8 -default["percona"]["server"]["innodb_buffer_pool_populate"] = 0 # Introduced: MariaDB 5.5 / XtraDB 5.5.28-29.1 -default["percona"]["server"]["innodb_data_file_path"] = "ibdata1:10M:autoextend" -default["percona"]["server"]["innodb_autoextend_increment"] = "128M" -default["percona"]["server"]["innodb_open_files"] = 2000 -default["percona"]["server"]["innodb_file_per_table"] = true -default["percona"]["server"]["innodb_file_format"] = "Antelope" -default["percona"]["server"]["innodb_data_home_dir"] = "" -default["percona"]["server"]["innodb_thread_concurrency"] = 16 -default["percona"]["server"]["innodb_flush_log_at_trx_commit"] = 1 -default["percona"]["server"]["innodb_fast_shutdown"] = false -default["percona"]["server"]["innodb_log_buffer_size"] = "64M" -default["percona"]["server"]["innodb_log_file_size"] = "5M" -default["percona"]["server"]["innodb_log_files_in_group"] = 2 -default["percona"]["server"]["innodb_max_dirty_pages_pct"] = 80 -default["percona"]["server"]["innodb_flush_method"] = "O_DIRECT" -default["percona"]["server"]["innodb_lock_wait_timeout"] = 120 -default["percona"]["server"]["innodb_import_table_from_xtrabackup"] = 0 -default["percona"]["server"]["innodb_numa_interleave"] = 0 +default['percona']['server']['skip_innodb'] = false +default['percona']['server']['innodb_additional_mem_pool_size'] = '32M' +default['percona']['server']['innodb_buffer_pool_size'] = '128M' +default['percona']['server']['innodb_buffer_pool_instances'] = 8 +default['percona']['server']['innodb_buffer_pool_populate'] = 0 # Introduced: MariaDB 5.5 / XtraDB 5.5.28-29.1 +default['percona']['server']['innodb_data_file_path'] = 'ibdata1:10M:autoextend' +default['percona']['server']['innodb_autoextend_increment'] = '128M' +default['percona']['server']['innodb_open_files'] = 2000 +default['percona']['server']['innodb_file_per_table'] = true +default['percona']['server']['innodb_file_format'] = 'Antelope' +default['percona']['server']['innodb_data_home_dir'] = '' +default['percona']['server']['innodb_thread_concurrency'] = 16 +default['percona']['server']['innodb_flush_log_at_trx_commit'] = 1 +default['percona']['server']['innodb_fast_shutdown'] = false +default['percona']['server']['innodb_log_buffer_size'] = '64M' +default['percona']['server']['innodb_log_file_size'] = '5M' +default['percona']['server']['innodb_log_files_in_group'] = 2 +default['percona']['server']['innodb_max_dirty_pages_pct'] = 80 +default['percona']['server']['innodb_flush_method'] = 'O_DIRECT' +default['percona']['server']['innodb_lock_wait_timeout'] = 120 +default['percona']['server']['innodb_import_table_from_xtrabackup'] = 0 +default['percona']['server']['innodb_numa_interleave'] = 0 # Performance Schema -default["percona"]["server"]["performance_schema"] = false +default['percona']['server']['performance_schema'] = false # Replication Settings -default["percona"]["server"]["replication"]["read_only"] = false -default["percona"]["server"]["replication"]["host"] = "" -default["percona"]["server"]["replication"]["username"] = "" -default["percona"]["server"]["replication"]["password"] = "" -default["percona"]["server"]["replication"]["port"] = 3306 -default["percona"]["server"]["replication"]["ignore_db"] = [] -default["percona"]["server"]["replication"]["ignore_table"] = [] -default["percona"]["server"]["replication"]["ssl_enabled"] = false -default["percona"]["server"]["replication"]["suppress_1592"] = false -default["percona"]["server"]["replication"]["skip_slave_start"] = false -default["percona"]["server"]["replication"]["replication_sql"] = "/etc/mysql/replication.sql" -default["percona"]["server"]["replication"]["slave_transaction_retries"] = 10 +default['percona']['server']['replication']['read_only'] = false +default['percona']['server']['replication']['host'] = '' +default['percona']['server']['replication']['username'] = '' +default['percona']['server']['replication']['password'] = '' +default['percona']['server']['replication']['port'] = 3306 +default['percona']['server']['replication']['ignore_db'] = [] +default['percona']['server']['replication']['ignore_table'] = [] +default['percona']['server']['replication']['ssl_enabled'] = false +default['percona']['server']['replication']['suppress_1592'] = false +default['percona']['server']['replication']['skip_slave_start'] = false +default['percona']['server']['replication']['replication_sql'] = '/etc/mysql/replication.sql' +default['percona']['server']['replication']['slave_transaction_retries'] = 10 # Mysqld_safe -default["percona"]["server"]["skip_syslog"] = false +default['percona']['server']['skip_syslog'] = false # XtraBackup Settings -default["percona"]["backup"]["configure"] = false -default["percona"]["backup"]["username"] = "backup" -unless attribute?(node["percona"]["backup"]["password"]) - default["percona"]["backup"]["password"] = secure_password +default['percona']['backup']['configure'] = false +default['percona']['backup']['username'] = 'backup' +unless attribute?(node['percona']['backup']['password']) + default['percona']['backup']['password'] = secure_password end # XtraDB Cluster Settings -default["percona"]["cluster"]["binlog_format"] = "ROW" -default["percona"]["cluster"]["wsrep_provider"] = value_for_platform_family( - "debian" => "/usr/lib/libgalera_smm.so", - "rhel" => "/usr/lib64/libgalera_smm.so" +default['percona']['cluster']['binlog_format'] = 'ROW' +default['percona']['cluster']['wsrep_provider'] = value_for_platform_family( + 'debian' => '/usr/lib/libgalera_smm.so', + 'rhel' => '/usr/lib64/libgalera_smm.so' ) -default["percona"]["cluster"]["wsrep_provider_options"] = "" -default["percona"]["cluster"]["wsrep_cluster_address"] = "" -default["percona"]["cluster"]["wsrep_slave_threads"] = 2 -default["percona"]["cluster"]["wsrep_cluster_name"] = "" -default["percona"]["cluster"]["wsrep_sst_method"] = "rsync" -default["percona"]["cluster"]["wsrep_node_name"] = "" -default["percona"]["cluster"]["wsrep_notify_cmd"] = "" -default["percona"]["cluster"]["wsrep_sst_auth"] = "" +default['percona']['cluster']['wsrep_provider_options'] = '' +default['percona']['cluster']['wsrep_cluster_address'] = '' +default['percona']['cluster']['wsrep_slave_threads'] = 2 +default['percona']['cluster']['wsrep_cluster_name'] = '' +default['percona']['cluster']['wsrep_sst_method'] = 'rsync' +default['percona']['cluster']['wsrep_node_name'] = '' +default['percona']['cluster']['wsrep_notify_cmd'] = '' +default['percona']['cluster']['wsrep_sst_auth'] = '' # These both are used to build wsrep_sst_receive_address -default["percona"]["cluster"]["wsrep_sst_receive_interface"] = nil # Works like node["percona"]["server"]["bind_to"] -default["percona"]["cluster"]["wsrep_sst_receive_port"] = "4444" +default['percona']['cluster']['wsrep_sst_receive_interface'] = nil # Works like node["percona"]["server"]["bind_to"] +default['percona']['cluster']['wsrep_sst_receive_port'] = '4444' -default["percona"]["cluster"]["innodb_locks_unsafe_for_binlog"] = 1 -default["percona"]["cluster"]["innodb_autoinc_lock_mode"] = 2 +default['percona']['cluster']['innodb_locks_unsafe_for_binlog'] = 1 +default['percona']['cluster']['innodb_autoinc_lock_mode'] = 2 diff --git a/attributes/monitoring.rb b/attributes/monitoring.rb index b3033f53..f3e058ed 100644 --- a/attributes/monitoring.rb +++ b/attributes/monitoring.rb @@ -3,5 +3,5 @@ # Attributes:: monitoring # -default["percona"]["plugins_version"] = "1.1.3" -default["percona"]["plugins_packages"] = %w[percona-nagios-plugins percona-zabbix-templates percona-cacti-templates] +default['percona']['plugins_version'] = '1.1.3' +default['percona']['plugins_packages'] = %w(percona-nagios-plugins percona-zabbix-templates percona-cacti-templates) diff --git a/attributes/package_repo.rb b/attributes/package_repo.rb index 307b022d..ef5d3fcc 100644 --- a/attributes/package_repo.rb +++ b/attributes/package_repo.rb @@ -3,20 +3,20 @@ # Attributes:: package_repo # -default["percona"]["use_percona_repos"] = true +default['percona']['use_percona_repos'] = true -arch = node["kernel"]["machine"] == "x86_64" ? "x86_64" : "i386" +arch = node['kernel']['machine'] == 'x86_64' ? 'x86_64' : 'i386' pversion = value_for_platform( - "amazon" => { "default" => "latest" }, - "default" => node["platform_version"].to_i + 'amazon' => { 'default' => 'latest' }, + 'default' => node['platform_version'].to_i ) -default["percona"]["apt"]["key"] = "0x9334A25F8507EFA5" -default["percona"]["apt"]["keyserver"] = "hkp://keys.gnupg.net:80" -default["percona"]["apt"]["uri"] = "http://repo.percona.com/apt" +default['percona']['apt']['key'] = '0x9334A25F8507EFA5' +default['percona']['apt']['keyserver'] = 'hkp://keys.gnupg.net:80' +default['percona']['apt']['uri'] = 'http://repo.percona.com/apt' -default["percona"]["yum"]["description"] = "Percona Packages" -default["percona"]["yum"]["baseurl"] = "http://repo.percona.com/centos/#{pversion}/os/#{arch}/" -default["percona"]["yum"]["gpgkey"] = "http://www.percona.com/downloads/RPM-GPG-KEY-percona" -default["percona"]["yum"]["gpgcheck"] = true -default["percona"]["yum"]["sslverify"] = true +default['percona']['yum']['description'] = 'Percona Packages' +default['percona']['yum']['baseurl'] = "http://repo.percona.com/centos/#{pversion}/os/#{arch}/" +default['percona']['yum']['gpgkey'] = 'http://www.percona.com/downloads/RPM-GPG-KEY-percona' +default['percona']['yum']['gpgcheck'] = true +default['percona']['yum']['sslverify'] = true diff --git a/chefignore b/chefignore new file mode 100644 index 00000000..38e7379b --- /dev/null +++ b/chefignore @@ -0,0 +1,107 @@ +# Put files/directories that should be ignored in this file when uploading +# to a chef-server or supermarket. +# Lines that start with '# ' are comments. + +# OS generated files # +###################### +.DS_Store +Icon? +nohup.out +ehthumbs.db +Thumbs.db + +# SASS # +######## +.sass-cache + +# EDITORS # +########### +\#* +.#* +*~ +*.sw[a-z] +*.bak +REVISION +TAGS* +tmtags +*_flymake.* +*_flymake +*.tmproj +.project +.settings +mkmf.log + +## COMPILED ## +############## +a.out +*.o +*.pyc +*.so +*.com +*.class +*.dll +*.exe +*/rdoc/ + +# Testing # +########### +.watchr +.rspec +spec/* +spec/fixtures/* +test/* +features/* +examples/* +Guardfile +Procfile +.kitchen* +.rubocop.yml +spec/* +Rakefile +.travis.yml +.foodcritic +.codeclimate.yml + +# SCM # +####### +.git +*/.git +.gitignore +.gitmodules +.gitconfig +.gitattributes +.svn +*/.bzr/* +*/.hg/* +*/.svn/* + +# Berkshelf # +############# +Berksfile +Berksfile.lock +cookbooks/* +tmp + +# Policyfile # +############## +Policyfile.rb +Policyfile.lock.json + +# Cookbooks # +############# +CONTRIBUTING* +CHANGELOG* +TESTING* +MAINTAINERS.toml + +# Strainer # +############ +Colanderfile +Strainerfile +.colander +.strainer + +# Vagrant # +########### +.vagrant +Vagrantfile diff --git a/libraries/config_helper.rb b/libraries/config_helper.rb index b13baa07..5472d950 100644 --- a/libraries/config_helper.rb +++ b/libraries/config_helper.rb @@ -1,4 +1,4 @@ -require "ipaddr" +require 'ipaddr' module Percona # Public: This module provides a helper method for returning a "scope" for a @@ -18,12 +18,12 @@ def for(ipaddress) module_function :for def loopback?(address) - IPAddr.new("127.0.0.0/8").include?(address) + IPAddr.new('127.0.0.0/8').include?(address) end module_function :loopback? def private?(address) - [IPAddr.new("10.0.0.0/8"), IPAddr.new("172.16.0.0/12"), IPAddr.new("192.168.0.0/16")].any? do |range| + [IPAddr.new('10.0.0.0/8'), IPAddr.new('172.16.0.0/12'), IPAddr.new('192.168.0.0/16')].any? do |range| range.include?(address) end end @@ -35,29 +35,29 @@ def private?(address) module ConfigHelper def bind_to(node, interface) case interface - when "public_ip" then find_public_ip(node) - when "private_ip" then find_private_ip(node) - when "loopback" then find_loopback_ip(node) + when 'public_ip' then find_public_ip(node) + when 'private_ip' then find_private_ip(node) + when 'loopback' then find_loopback_ip(node) else find_interface_ip(node, interface) end end module_function :bind_to def self.find_public_ip(node) - if node["cloud"] && node["cloud"]["public_ipv4"] - node["cloud"]["public_ipv4"] + if node['cloud'] && node['cloud']['public_ipv4'] + node['cloud']['public_ipv4'] else find_ip(node, :private) end end def self.find_private_ip(node) - if node["cloud"] && node["cloud"]["local_ipv4"] - node["cloud"]["local_ipv4"] - elsif node["cloud"] && node["cloud"]["private_ipv4"] - node["cloud"]["private_ipv4"] - elsif node["privateaddress"] - node["privateaddress"] + if node['cloud'] && node['cloud']['local_ipv4'] + node['cloud']['local_ipv4'] + elsif node['cloud'] && node['cloud']['private_ipv4'] + node['cloud']['private_ipv4'] + elsif node['privateaddress'] + node['privateaddress'] else find_ip(node, :private) end @@ -68,20 +68,20 @@ def self.find_loopback_ip(node) end def self.find_ip(node, scope) - node["network"]["interfaces"].each do |_, attrs| - next unless attrs["addresses"] - attrs["addresses"].each do |addr, data| - next unless data["family"] == "inet" + node['network']['interfaces'].each do |_, attrs| + next unless attrs['addresses'] + attrs['addresses'].each do |addr, data| + next unless data['family'] == 'inet' return addr if IPScope.for(addr) == scope end end end def find_interface_ip(node, interface) - interfaces = node["network"]["interfaces"] + interfaces = node['network']['interfaces'] return unless interfaces[interface] - addr = interfaces[interface]["addresses"].find do |_, attrs| - attrs["family"] == "inet" + addr = interfaces[interface]['addresses'].find do |_, attrs| + attrs['family'] == 'inet' end addr && addr[0] end diff --git a/libraries/passwords.rb b/libraries/passwords.rb index ac707776..aabf3177 100644 --- a/libraries/passwords.rb +++ b/libraries/passwords.rb @@ -4,19 +4,19 @@ class Chef class EncryptedPasswords attr_accessor :node, :bag, :secret_file - def initialize(node, bag = "passwords") + def initialize(node, bag = 'passwords') @node = node @bag = bag - @secret_file = node["percona"]["encrypted_data_bag_secret_file"] - @mysql_item = node["percona"]["encrypted_data_bag_item_mysql"] - @system_item = node["percona"]["encrypted_data_bag_item_system"] + @secret_file = node['percona']['encrypted_data_bag_secret_file'] + @mysql_item = node['percona']['encrypted_data_bag_item_mysql'] + @system_item = node['percona']['encrypted_data_bag_item_system'] end # helper for passwords def find_password(item, user, default = nil) begin # attribute that controls use of chef-vault or encrypted data bags - vault = node["percona"]["use_chef_vault"] + vault = node['percona']['use_chef_vault'] # load password from the vault pwds = ChefVault::Item.load(bag, item) if vault # load the encrypted data bag item, using a secret if specified @@ -25,7 +25,7 @@ def find_password(item, user, default = nil) password = pwds[user] rescue Chef::Log.info("Unable to load password for #{user}, #{item},"\ - "fall back to non-encrypted password") + 'fall back to non-encrypted password') end # password will be nil if no encrypted data bag was loaded # fall back to the attribute on this node @@ -34,38 +34,38 @@ def find_password(item, user, default = nil) # mysql root def root_password - find_password @mysql_item, "root", node_server["root_password"] + find_password @mysql_item, 'root', node_server['root_password'] end # debian script user password def debian_password find_password( - @system_item, node_server["debian_username"], - node_server["debian_password"] + @system_item, node_server['debian_username'], + node_server['debian_password'] ) end # ? def old_passwords - find_password @mysql_item, "old_passwords", node_server["old_passwords"] + find_password @mysql_item, 'old_passwords', node_server['old_passwords'] end # password for user responsbile for replicating in master/slave environment def replication_password - find_password @mysql_item, node_server['replication']['username'], node_server['replication']["password"] + find_password @mysql_item, node_server['replication']['username'], node_server['replication']['password'] end # password for user responsbile for running xtrabackup def backup_password - backup = node["percona"]["backup"] - find_password @mysql_item, backup["username"], backup["password"] + backup = node['percona']['backup'] + find_password @mysql_item, backup['username'], backup['password'] end private # helper def node_server - @node["percona"]["server"] + @node['percona']['server'] end def data_bag_secret_file diff --git a/libraries/provider_mysql2_chef_gem.rb b/libraries/provider_mysql2_chef_gem.rb index 01c77713..37b39879 100644 --- a/libraries/provider_mysql2_chef_gem.rb +++ b/libraries/provider_mysql2_chef_gem.rb @@ -10,20 +10,20 @@ def whyrun_supported? end action :install do - converge_by "install mysql2 chef_gem and dependencies" do + converge_by 'install mysql2 chef_gem and dependencies' do recipe_eval do - run_context.include_recipe "build-essential" - run_context.include_recipe "percona::client" + run_context.include_recipe 'build-essential' + run_context.include_recipe 'percona::client' end - chef_gem "mysql2" do + chef_gem 'mysql2' do action :install end end end action :remove do - chef_gem "mysql2" do + chef_gem 'mysql2' do action :remove end end diff --git a/libraries/provider_mysql_chef_gem.rb b/libraries/provider_mysql_chef_gem.rb index a54c45fa..0727ed41 100644 --- a/libraries/provider_mysql_chef_gem.rb +++ b/libraries/provider_mysql_chef_gem.rb @@ -10,20 +10,20 @@ def whyrun_supported? end action :install do - converge_by "install mysql chef_gem and dependencies" do + converge_by 'install mysql chef_gem and dependencies' do recipe_eval do - run_context.include_recipe "build-essential" - run_context.include_recipe "percona::client" + run_context.include_recipe 'build-essential' + run_context.include_recipe 'percona::client' end - chef_gem "mysql" do + chef_gem 'mysql' do action :install end end end action :remove do - chef_gem "mysql" do + chef_gem 'mysql' do action :remove end end diff --git a/metadata.rb b/metadata.rb index ed94fc5e..a3e95357 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,37 +1,24 @@ -name "percona" -maintainer "Phil Cohen" -maintainer_email "github@phlippers.net" -license "MIT" -description "Installs Percona MySQL client and server" -long_description "Please refer to README.md" -version "0.16.4" +name 'percona' +maintainer 'Sous Chefs' +maintainer_email 'help@sous-chefs.org' +license 'MIT' +description 'Installs Percona MySQL client and server' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +source_url 'https://github.com/phlipper/chef-percona' +issues_url 'https://github.com/phlipper/chef-percona/issues' +version '0.16.4' -recipe "percona", "Includes the client recipe to configure a client" -recipe "percona::package_repo", "Sets up the package repository and installs dependent packages" -recipe "percona::client", "Installs client libraries" -recipe "percona::server", "Installs the server daemon" -recipe "percona::backup", "Installs the XtraBackup hot backup software" -recipe "percona::toolkit", "Installs the Percona Toolkit software" -recipe "percona::cluster", "Installs the Percona XtraDB Cluster server components" -recipe "percona::configure_server", "Used internally to manage the server configuration." -recipe "percona::replication", "Used internally to grant permissions for replication." -recipe "percona::access_grants", "Used internally to grant permissions for recipes" -recipe "percona::monitoring", "Installs Percona monitoring plugins for Nagios" +depends 'apt', '>= 2.7.0' +depends 'build-essential' +depends 'openssl' +depends 'yum', '~> 3.0' +depends 'yum-epel' +depends 'chef-vault' -depends "apt", ">= 2.7.0" -depends "build-essential" -depends "openssl" -depends "yum", "~> 3.0" -depends "yum-epel" -depends "chef-vault" - -supports "debian" -supports "ubuntu" -supports "centos" -supports "amazon" -supports "scientific" -supports "fedora" -supports "redhat" - -source_url "https://github.com/phlipper/chef-percona" if respond_to?(:source_url) -issues_url "https://github.com/phlipper/chef-percona/issues" if respond_to?(:issues_url) +supports 'debian' +supports 'ubuntu' +supports 'centos' +supports 'amazon' +supports 'scientific' +supports 'fedora' +supports 'redhat' diff --git a/recipes/access_grants.rb b/recipes/access_grants.rb index 2b89b9a5..9ea1bd52 100644 --- a/recipes/access_grants.rb +++ b/recipes/access_grants.rb @@ -3,20 +3,20 @@ # Recipe:: access_grants # -passwords = EncryptedPasswords.new(node, node["percona"]["encrypted_data_bag"]) +passwords = EncryptedPasswords.new(node, node['percona']['encrypted_data_bag']) # define access grants -template "/etc/mysql/grants.sql" do - source "grants.sql.erb" +template '/etc/mysql/grants.sql' do + source 'grants.sql.erb' variables( root_password: passwords.root_password, - debian_user: node["percona"]["server"]["debian_username"], + debian_user: node['percona']['server']['debian_username'], debian_password: passwords.debian_password, backup_password: passwords.backup_password ) - owner "root" - group "root" - mode "0600" + owner 'root' + group 'root' + mode '0600' sensitive true end @@ -25,18 +25,18 @@ # Intent is to check whether the root_password works, and use it to # load the grants if so. If not, try loading without a password # and see if we get lucky - execute "mysql-install-privileges" do # ~FC009 - `sensitive` - command "/usr/bin/mysql -p'#{passwords.root_password}' -e '' &> /dev/null > /dev/null &> /dev/null ; if [ $? -eq 0 ] ; then /usr/bin/mysql -p'#{passwords.root_password}' < /etc/mysql/grants.sql ; else /usr/bin/mysql < /etc/mysql/grants.sql ; fi ;" # rubocop:disable LineLength + execute 'mysql-install-privileges' do # ~FC009 - `sensitive` + command "/usr/bin/mysql -p'#{passwords.root_password}' -e '' &> /dev/null > /dev/null &> /dev/null ; if [ $? -eq 0 ] ; then /usr/bin/mysql -p'#{passwords.root_password}' < /etc/mysql/grants.sql ; else /usr/bin/mysql < /etc/mysql/grants.sql ; fi ;" action :nothing - subscribes :run, resources("template[/etc/mysql/grants.sql]"), :immediately + subscribes :run, resources('template[/etc/mysql/grants.sql]'), :immediately sensitive true end else # Simpler path... just try running the grants command - execute "mysql-install-privileges" do - command "/usr/bin/mysql < /etc/mysql/grants.sql" + execute 'mysql-install-privileges' do + command '/usr/bin/mysql < /etc/mysql/grants.sql' action :nothing - subscribes :run, resources("template[/etc/mysql/grants.sql]"), :immediately + subscribes :run, resources('template[/etc/mysql/grants.sql]'), :immediately sensitive true end end diff --git a/recipes/backup.rb b/recipes/backup.rb index 305bec79..cdbf721d 100644 --- a/recipes/backup.rb +++ b/recipes/backup.rb @@ -3,18 +3,18 @@ # Recipe:: backup # -node.set["percona"]["backup"]["configure"] = true +node.set['percona']['backup']['configure'] = true -include_recipe "percona::package_repo" +include_recipe 'percona::package_repo' -case node["platform_family"] -when "debian" - package "xtrabackup" do - options "--force-yes" +case node['platform_family'] +when 'debian' + package 'xtrabackup' do + options '--force-yes' end -when "rhel" - package "percona-xtrabackup" +when 'rhel' + package 'percona-xtrabackup' end # access grants -include_recipe "percona::access_grants" unless node["percona"]["skip_passwords"] +include_recipe 'percona::access_grants' unless node['percona']['skip_passwords'] diff --git a/recipes/client.rb b/recipes/client.rb index 9fb8861b..b04d59e3 100644 --- a/recipes/client.rb +++ b/recipes/client.rb @@ -3,10 +3,10 @@ # Recipe:: client # -include_recipe "percona::package_repo" +include_recipe 'percona::package_repo' -node["percona"]["client"]["packages"].each do |percona_client_pkg| +node['percona']['client']['packages'].each do |percona_client_pkg| package percona_client_pkg do - action node["percona"]["client"]["package_action"].to_sym + action node['percona']['client']['package_action'].to_sym end end diff --git a/recipes/cluster.rb b/recipes/cluster.rb index 72d2c074..3c8d8654 100644 --- a/recipes/cluster.rb +++ b/recipes/cluster.rb @@ -3,49 +3,49 @@ # Recipe:: cluster # -include_recipe "percona::package_repo" +include_recipe 'percona::package_repo' # Determine and set wsrep_sst_receive_address -if node["percona"]["cluster"]["wsrep_sst_receive_interface"] - sst_interface = node["percona"]["cluster"]["wsrep_sst_receive_interface"] - sst_port = node["percona"]["cluster"]["wsrep_sst_receive_port"] +if node['percona']['cluster']['wsrep_sst_receive_interface'] + sst_interface = node['percona']['cluster']['wsrep_sst_receive_interface'] + sst_port = node['percona']['cluster']['wsrep_sst_receive_port'] ip = Percona::ConfigHelper.bind_to(node, sst_interface) address = "#{ip}:#{sst_port}" - node.set["percona"]["cluster"]["wsrep_sst_receive_address"] = address + node.set['percona']['cluster']['wsrep_sst_receive_address'] = address end # set default package attributes -version = node["percona"]["version"] -node.default["percona"]["cluster"]["package"] = value_for_platform_family( - "rhel" => "Percona-XtraDB-Cluster-#{version.tr(".", "")}", - "debian" => "percona-xtradb-cluster-#{version.tr(".", "")}" +version = node['percona']['version'] +node.default['percona']['cluster']['package'] = value_for_platform_family( + 'rhel' => "Percona-XtraDB-Cluster-#{version.tr('.', '')}", + 'debian' => "percona-xtradb-cluster-#{version.tr('.', '')}" ) # install packages -case node["platform_family"] -when "debian" - package node["percona"]["cluster"]["package"] do +case node['platform_family'] +when 'debian' + package node['percona']['cluster']['package'] do # The package starts up immediately, then additional config is added and the # restart command fails to work. Instead, stop the database before changing # the configuration. - notifies :stop, "service[mysql]", :immediately + notifies :stop, 'service[mysql]', :immediately end -when "rhel" - package "mysql-libs" do +when 'rhel' + package 'mysql-libs' do action :remove - not_if "rpm -qa | grep -q '#{node["percona"]["cluster"]["package"]}'" + not_if "rpm -qa | grep -q '#{node['percona']['cluster']['package']}'" end # This is required for `socat` per: # www.percona.com/doc/percona-xtradb-cluster/5.6/installation/yum_repo.html - include_recipe "yum-epel" + include_recipe 'yum-epel' - package node["percona"]["cluster"]["package"] + package node['percona']['cluster']['package'] end -unless node["percona"]["skip_configure"] - include_recipe "percona::configure_server" +unless node['percona']['skip_configure'] + include_recipe 'percona::configure_server' end # access grants -include_recipe "percona::access_grants" unless node["percona"]["skip_passwords"] +include_recipe 'percona::access_grants' unless node['percona']['skip_passwords'] diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 62053268..81c4e365 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -3,77 +3,77 @@ # Recipe:: configure_server # -percona = node["percona"] -server = percona["server"] -conf = percona["conf"] -mysqld = (conf && conf["mysqld"]) || {} +percona = node['percona'] +server = percona['server'] +conf = percona['conf'] +mysqld = (conf && conf['mysqld']) || {} # setup SELinux if needed -unless node["percona"]["selinux_module_url"].nil? || node["percona"]["selinux_module_url"] == "" - semodule_filename = node["percona"]["selinux_module_url"].split("/")[-1] +unless node['percona']['selinux_module_url'].nil? || node['percona']['selinux_module_url'] == '' + semodule_filename = node['percona']['selinux_module_url'].split('/')[-1] semodule_filepath = "#{Chef::Config[:file_cache_path]}/#{semodule_filename}" remote_file semodule_filepath do - source node["percona"]["selinux_module_url"] - only_if { semodule_filename && node["platform_family"] == "rhel" } + source node['percona']['selinux_module_url'] + only_if { semodule_filename && node['platform_family'] == 'rhel' } end execute "semodule-install-#{semodule_filename}" do command "/usr/sbin/semodule -i #{semodule_filepath}" - only_if { semodule_filename && node["platform_family"] == "rhel" } - only_if { shell_out("/usr/sbin/semodule -l | grep '^#{semodule_filename.split(".")[0..-2]}\\s'").stdout == "" } # rubocop:disable LineLength + only_if { semodule_filename && node['platform_family'] == 'rhel' } + only_if { shell_out("/usr/sbin/semodule -l | grep '^#{semodule_filename.split('.')[0..-2]}\\s'").stdout == '' } end end # install chef-vault if needed -include_recipe "chef-vault" if node["percona"]["use_chef_vault"] +include_recipe 'chef-vault' if node['percona']['use_chef_vault'] # construct an encrypted passwords helper -- giving it the node and bag name -passwords = EncryptedPasswords.new(node, percona["encrypted_data_bag"]) +passwords = EncryptedPasswords.new(node, percona['encrypted_data_bag']) -if node["percona"]["server"]["jemalloc"] +if node['percona']['server']['jemalloc'] package_name = value_for_platform_family( - "debian" => "libjemalloc1", - "rhel" => "jemalloc" + 'debian' => 'libjemalloc1', + 'rhel' => 'jemalloc' ) package package_name end -template "/root/.my.cnf" do +template '/root/.my.cnf' do variables(root_password: passwords.root_password) - owner "root" - group "root" - mode "0600" - source "my.cnf.root.erb" + owner 'root' + group 'root' + mode '0600' + source 'my.cnf.root.erb' sensitive true - not_if { node["percona"]["skip_passwords"] } + not_if { node['percona']['skip_passwords'] } end -if server["bind_to"] - ipaddr = Percona::ConfigHelper.bind_to(node, server["bind_to"]) - if ipaddr && server["bind_address"] != ipaddr - node.override["percona"]["server"]["bind_address"] = ipaddr +if server['bind_to'] + ipaddr = Percona::ConfigHelper.bind_to(node, server['bind_to']) + if ipaddr && server['bind_address'] != ipaddr + node.override['percona']['server']['bind_address'] = ipaddr node.save unless Chef::Config[:solo] end - log "Can't find ip address for #{server["bind_to"]}" do + log "Can't find ip address for #{server['bind_to']}" do level :warn only_if { ipaddr.nil? } end end -datadir = mysqld["datadir"] || server["datadir"] -logdir = mysqld["logdir"] || server["logdir"] -tmpdir = mysqld["tmpdir"] || server["tmpdir"] -includedir = mysqld["includedir"] || server["includedir"] -user = mysqld["username"] || server["username"] -slow_query_logdir = mysqld["slow_query_logdir"] || server["slow_query_logdir"] +datadir = mysqld['datadir'] || server['datadir'] +logdir = mysqld['logdir'] || server['logdir'] +tmpdir = mysqld['tmpdir'] || server['tmpdir'] +includedir = mysqld['includedir'] || server['includedir'] +user = mysqld['username'] || server['username'] +slow_query_logdir = mysqld['slow_query_logdir'] || server['slow_query_logdir'] # this is where we dump sql templates for replication, etc. -directory "/etc/mysql" do - owner "root" - group "root" - mode "0755" +directory '/etc/mysql' do + owner 'root' + group 'root' + mode '0755' end # setup the data directory @@ -84,7 +84,7 @@ end # setup the log directory -directory "log directory" do +directory 'log directory' do path logdir owner user group user @@ -108,7 +108,7 @@ end # setup slow_query_logdir directory -directory "slow query log directory" do +directory 'slow query log directory' do path slow_query_logdir owner user group user @@ -117,57 +117,57 @@ end # define the service -service "mysql" do +service 'mysql' do supports restart: true - action server["enable"] ? :enable : :disable + action server['enable'] ? :enable : :disable end # install db to the data directory -execute "setup mysql datadir" do - command "mysql_install_db --defaults-file=#{percona["main_config_file"]} --user=#{user}" # rubocop:disable LineLength +execute 'setup mysql datadir' do + command "mysql_install_db --defaults-file=#{percona['main_config_file']} --user=#{user}" not_if "test -f #{datadir}/mysql/user.frm" action :nothing end # install SSL certificates before config phase -if node["percona"]["server"]["replication"]["ssl_enabled"] - include_recipe "percona::ssl" +if node['percona']['server']['replication']['ssl_enabled'] + include_recipe 'percona::ssl' end -if Array(server["role"]).include?("cluster") - if node["percona"]["cluster"]["wsrep_sst_auth"] == "" - wsrep_sst_auth = "#{node["percona"]["backup"]["username"]}:#{passwords.backup_password}" # rubocop:disable LineLength - else - wsrep_sst_auth = node["percona"]["cluster"]["wsrep_sst_auth"] - end +if Array(server['role']).include?('cluster') + wsrep_sst_auth = if node['percona']['cluster']['wsrep_sst_auth'] == '' + "#{node['percona']['backup']['username']}:#{passwords.backup_password}" + else + node['percona']['cluster']['wsrep_sst_auth'] + end end # setup the main server config file -template percona["main_config_file"] do - if Array(server["role"]).include?("cluster") - source node["percona"]["main_config_template"]["source"]["cluster"] +template percona['main_config_file'] do + if Array(server['role']).include?('cluster') + source node['percona']['main_config_template']['source']['cluster'] else - source node["percona"]["main_config_template"]["source"]["default"] + source node['percona']['main_config_template']['source']['default'] end - cookbook node["percona"]["main_config_template"]["cookbook"] - owner "root" - group "root" - mode "0644" + cookbook node['percona']['main_config_template']['cookbook'] + owner 'root' + group 'root' + mode '0644' sensitive true - if Array(server["role"]).include?("cluster") + if Array(server['role']).include?('cluster') variables(wsrep_sst_auth: wsrep_sst_auth) end - notifies :run, "execute[setup mysql datadir]", :immediately - if node["percona"]["auto_restart"] - notifies :restart, "service[mysql]", :immediately + notifies :run, 'execute[setup mysql datadir]', :immediately + if node['percona']['auto_restart'] + notifies :restart, 'service[mysql]', :immediately end end # now let's set the root password only if this is the initial install -unless node["percona"]["skip_passwords"] +unless node['percona']['skip_passwords'] root_pw = passwords.root_password - execute "Update MySQL root password" do # ~FC009 - `sensitive` + execute 'Update MySQL root password' do # ~FC009 - `sensitive` command "mysqladmin --user=root --password='' password '#{root_pw}'" only_if "mysqladmin --user=root --password='' version" sensitive true @@ -175,15 +175,15 @@ end # setup the debian system user config -template "/etc/mysql/debian.cnf" do - source "debian.cnf.erb" +template '/etc/mysql/debian.cnf' do + source 'debian.cnf.erb' variables(debian_password: passwords.debian_password) - owner "root" - group "root" - mode "0640" + owner 'root' + group 'root' + mode '0640' sensitive true - if node["percona"]["auto_restart"] - notifies :restart, "service[mysql]", :immediately + if node['percona']['auto_restart'] + notifies :restart, 'service[mysql]', :immediately end - only_if { platform_family?("debian") } + only_if { platform_family?('debian') } end diff --git a/recipes/default.rb b/recipes/default.rb index 7f9a15b2..9f7b832a 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -3,4 +3,4 @@ # Recipe:: default # -include_recipe "percona::client" +include_recipe 'percona::client' diff --git a/recipes/monitoring.rb b/recipes/monitoring.rb index 53f72f4a..56a04367 100644 --- a/recipes/monitoring.rb +++ b/recipes/monitoring.rb @@ -3,8 +3,8 @@ # Recipe:: monitoring # -node["percona"]["plugins_packages"].each do |pkg| +node['percona']['plugins_packages'].each do |pkg| package pkg do - version node["percona"]["plugins_version"] + version node['percona']['plugins_version'] end end diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index 0771a5d2..f34c6799 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -3,36 +3,36 @@ # Recipe:: package_repo # -return unless node["percona"]["use_percona_repos"] +return unless node['percona']['use_percona_repos'] -case node["platform_family"] -when "debian" - include_recipe "apt" +case node['platform_family'] +when 'debian' + include_recipe 'apt' # Pin this repo as to avoid upgrade conflicts with distribution repos. - apt_preference "00percona" do - glob "*" - pin "release o=Percona Development Team" - pin_priority "1001" + apt_preference '00percona' do + glob '*' + pin 'release o=Percona Development Team' + pin_priority '1001' end - apt_repository "percona" do - uri node["percona"]["apt"]["uri"] - distribution node["lsb"]["codename"] - components ["main"] - keyserver node["percona"]["apt"]["keyserver"] - key node["percona"]["apt"]["key"] - not_if "apt-key list | grep #{node['percona']['apt']['key'][-8,8]}" + apt_repository 'percona' do + uri node['percona']['apt']['uri'] + distribution node['lsb']['codename'] + components ['main'] + keyserver node['percona']['apt']['keyserver'] + key node['percona']['apt']['key'] + not_if "apt-key list | grep #{node['percona']['apt']['key'][-8, 8]}" end -when "rhel" - include_recipe "yum" +when 'rhel' + include_recipe 'yum' - yum_repository "percona" do - description node["percona"]["yum"]["description"] - baseurl node["percona"]["yum"]["baseurl"] - gpgkey node["percona"]["yum"]["gpgkey"] - gpgcheck node["percona"]["yum"]["gpgcheck"] - sslverify node["percona"]["yum"]["sslverify"] + yum_repository 'percona' do + description node['percona']['yum']['description'] + baseurl node['percona']['yum']['baseurl'] + gpgkey node['percona']['yum']['gpgkey'] + gpgcheck node['percona']['yum']['gpgcheck'] + sslverify node['percona']['yum']['sslverify'] end end diff --git a/recipes/replication.rb b/recipes/replication.rb index 9f3e8eb6..19ffbae0 100644 --- a/recipes/replication.rb +++ b/recipes/replication.rb @@ -3,29 +3,29 @@ # Recipe:: replication # -require "shellwords" +require 'shellwords' -passwords = EncryptedPasswords.new(node, node["percona"]["encrypted_data_bag"]) -server = node["percona"]["server"] -replication_sql = server["replication"]["replication_sql"] +passwords = EncryptedPasswords.new(node, node['percona']['encrypted_data_bag']) +server = node['percona']['server'] +replication_sql = server['replication']['replication_sql'] # define access grants template replication_sql do - source "replication.sql.erb" + source 'replication.sql.erb' variables(replication_password: passwords.replication_password) - owner "root" - group "root" - mode "0600" + owner 'root' + group 'root' + mode '0600' sensitive true only_if do - server["replication"]["host"] != "" || server["role"].include?("master") + server['replication']['host'] != '' || server['role'].include?('master') end end root_pass = passwords.root_password.to_s -root_pass = Shellwords.escape(root_pass).prepend("-p") unless root_pass.empty? +root_pass = Shellwords.escape(root_pass).prepend('-p') unless root_pass.empty? -execute "mysql-set-replication" do # ~FC009 - `sensitive` +execute 'mysql-set-replication' do # ~FC009 - `sensitive` command "/usr/bin/mysql #{root_pass} < #{replication_sql}" action :nothing subscribes :run, resources("template[#{replication_sql}]"), :immediately diff --git a/recipes/server.rb b/recipes/server.rb index fd4fb8eb..975d1fe7 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -3,43 +3,43 @@ # Recipe:: server # -include_recipe "percona::package_repo" +include_recipe 'percona::package_repo' -version = node["percona"]["version"] +version = node['percona']['version'] # install packages -case node["platform_family"] -when "debian" - node.default["percona"]["server"]["package"] = "percona-server-server-#{version}" # rubocop:disable LineLength +case node['platform_family'] +when 'debian' + node.default['percona']['server']['package'] = "percona-server-server-#{version}" - package node["percona"]["server"]["package"] do - options "--force-yes" - action node["percona"]["server"]["package_action"].to_sym + package node['percona']['server']['package'] do + options '--force-yes' + action node['percona']['server']['package_action'].to_sym end -when "rhel" - node.default["percona"]["server"]["package"] = "Percona-Server-server-#{version.tr(".", "")}" # rubocop:disable LineLength - node.default["percona"]["server"]["shared_pkg"] = "Percona-Server-shared-#{version.tr(".", "")}" # rubocop:disable LineLength +when 'rhel' + node.default['percona']['server']['package'] = "Percona-Server-server-#{version.tr('.', '')}" + node.default['percona']['server']['shared_pkg'] = "Percona-Server-shared-#{version.tr('.', '')}" # Need to remove this to avoid conflicts - package "mysql-libs" do + package 'mysql-libs' do action :remove - not_if "rpm -qa | grep #{node["percona"]["server"]["shared_pkg"]}" + not_if "rpm -qa | grep #{node['percona']['server']['shared_pkg']}" end # we need mysqladmin - include_recipe "percona::client" + include_recipe 'percona::client' - package node["percona"]["server"]["package"] do - action node["percona"]["server"]["package_action"].to_sym + package node['percona']['server']['package'] do + action node['percona']['server']['package_action'].to_sym end end -unless node["percona"]["skip_configure"] - include_recipe "percona::configure_server" +unless node['percona']['skip_configure'] + include_recipe 'percona::configure_server' end # access grants -unless node["percona"]["skip_passwords"] - include_recipe "percona::access_grants" - include_recipe "percona::replication" +unless node['percona']['skip_passwords'] + include_recipe 'percona::access_grants' + include_recipe 'percona::replication' end diff --git a/recipes/ssl.rb b/recipes/ssl.rb index e9cf1d5d..be7d3005 100644 --- a/recipes/ssl.rb +++ b/recipes/ssl.rb @@ -3,39 +3,39 @@ # Recipe:: ssl # -certs_path = "/etc/mysql/ssl" -server = node["percona"]["server"] -data_bag = node["percona"]["encrypted_data_bag"] +certs_path = '/etc/mysql/ssl' +server = node['percona']['server'] +data_bag = node['percona']['encrypted_data_bag'] directory certs_path do - owner node["percona"]["server"]["username"] - mode "0700" + owner node['percona']['server']['username'] + mode '0700' end certs = Chef::EncryptedDataBagItem.load( data_bag, - node["percona"]["encrypted_data_bag_item_ssl_replication"] + node['percona']['encrypted_data_bag_item_ssl_replication'] ) # place the CA certificate, it should be present on both master and slave file "#{certs_path}/cacert.pem" do - content certs["ca-cert"] + content certs['ca-cert'] sensitive true end -%w[cert key].each do |file| +%w(cert key).each do |file| # place certificate and key for master file "#{certs_path}/server-#{file}.pem" do - content certs["server"]["server-#{file}"] + content certs['server']["server-#{file}"] sensitive true - only_if { server["role"].include?("master") } + only_if { server['role'].include?('master') } end # because in a master-master setup a master could also be a slave # place slave certificate and key file "#{certs_path}/client-#{file}.pem" do - content certs["client"]["client-#{file}"] + content certs['client']["client-#{file}"] sensitive true - only_if { server["role"].include?("slave") } + only_if { server['role'].include?('slave') } end end diff --git a/recipes/toolkit.rb b/recipes/toolkit.rb index 246908e4..bbf5306d 100644 --- a/recipes/toolkit.rb +++ b/recipes/toolkit.rb @@ -3,8 +3,8 @@ # Recipe:: toolkit # -include_recipe "percona::package_repo" +include_recipe 'percona::package_repo' -package "percona-toolkit" do - options "--force-yes" if platform_family?("debian") +package 'percona-toolkit' do + options '--force-yes' if platform_family?('debian') end diff --git a/spec/access_grants_spec.rb b/spec/access_grants_spec.rb index 1f6b7d97..315555c2 100644 --- a/spec/access_grants_spec.rb +++ b/spec/access_grants_spec.rb @@ -1,42 +1,42 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::access_grants" do +describe 'percona::access_grants' do let(:grant_file) do - "/etc/mysql/grants.sql" + '/etc/mysql/grants.sql' end let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["server"]["root_password"] = "s3kr1t" + node.set['percona']['server']['root_password'] = 's3kr1t' end.converge(described_recipe) end - it "writes the `grants.sql` file" do + it 'writes the `grants.sql` file' do expect(chef_run).to create_template(grant_file).with( - owner: "root", - group: "root", - mode: "0600", + owner: 'root', + group: 'root', + mode: '0600', sensitive: true ) end - it "adds the root password to `grants.sql`" do + it 'adds the root password to `grants.sql`' do expect(chef_run).to render_file(grant_file).with_content( "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('s3kr1t')" ) end - it "executes the `install privileges` command" do - expect(chef_run).to_not run_execute("mysql-install-privileges") + it 'executes the `install privileges` command' do + expect(chef_run).to_not run_execute('mysql-install-privileges') - exec_resource = chef_run.execute("mysql-install-privileges") + exec_resource = chef_run.execute('mysql-install-privileges') expect(exec_resource).to( subscribe_to("template[#{grant_file}]").on(:run).immediately ) tmpl_resource = chef_run.template(grant_file) expect(tmpl_resource).to( - notify("execute[mysql-install-privileges]").to(:run).immediately + notify('execute[mysql-install-privileges]').to(:run).immediately ) end end diff --git a/spec/backup_spec.rb b/spec/backup_spec.rb index 8b2ff5f2..21bbf6ab 100644 --- a/spec/backup_spec.rb +++ b/spec/backup_spec.rb @@ -1,24 +1,24 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::backup" do - describe "Ubuntu" do +describe 'percona::backup' do + describe 'Ubuntu' do let(:chef_run) do ChefSpec::SoloRunner.new.converge(described_recipe) end - it { expect(chef_run).to include_recipe("percona::package_repo") } - it { expect(chef_run).to install_package("xtrabackup") } - it { expect(chef_run).to include_recipe("percona::access_grants") } + it { expect(chef_run).to include_recipe('percona::package_repo') } + it { expect(chef_run).to install_package('xtrabackup') } + it { expect(chef_run).to include_recipe('percona::access_grants') } end - describe "CentOS" do + describe 'CentOS' do let(:chef_run) do - env_options = { platform: "centos", version: "6.5" } + env_options = { platform: 'centos', version: '6.5' } ChefSpec::SoloRunner.new(env_options).converge(described_recipe) end - it { expect(chef_run).to include_recipe("percona::package_repo") } - it { expect(chef_run).to install_package("percona-xtrabackup") } - it { expect(chef_run).to include_recipe("percona::access_grants") } + it { expect(chef_run).to include_recipe('percona::package_repo') } + it { expect(chef_run).to install_package('percona-xtrabackup') } + it { expect(chef_run).to include_recipe('percona::access_grants') } end end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index a4963c76..5b8ad5c2 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -1,56 +1,56 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::client" do - describe "when `package_action` is `install`" do - describe "Ubuntu" do +describe 'percona::client' do + describe 'when `package_action` is `install`' do + describe 'Ubuntu' do let(:chef_run) do ChefSpec::SoloRunner.new.converge(described_recipe) end specify do - expect(chef_run).to install_package "libperconaserverclient18.1-dev" - expect(chef_run).to install_package "percona-server-client-5.6" + expect(chef_run).to install_package 'libperconaserverclient18.1-dev' + expect(chef_run).to install_package 'percona-server-client-5.6' end end - describe "CentOS" do + describe 'CentOS' do let(:chef_run) do - env_options = { platform: "centos", version: "6.5" } + env_options = { platform: 'centos', version: '6.5' } ChefSpec::SoloRunner.new(env_options).converge(described_recipe) end specify do - expect(chef_run).to install_package "Percona-Server-devel-56" - expect(chef_run).to install_package "Percona-Server-client-56" + expect(chef_run).to install_package 'Percona-Server-devel-56' + expect(chef_run).to install_package 'Percona-Server-client-56' end end end - describe "when `package_action` is `upgrade`" do - describe "Ubuntu" do + describe 'when `package_action` is `upgrade`' do + describe 'Ubuntu' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["client"]["package_action"] = "upgrade" + node.set['percona']['client']['package_action'] = 'upgrade' end.converge(described_recipe) end specify do - expect(chef_run).to upgrade_package "libperconaserverclient18.1-dev" - expect(chef_run).to upgrade_package "percona-server-client-5.6" + expect(chef_run).to upgrade_package 'libperconaserverclient18.1-dev' + expect(chef_run).to upgrade_package 'percona-server-client-5.6' end end - describe "CentOS" do + describe 'CentOS' do let(:chef_run) do - env_options = { platform: "centos", version: "6.5" } + env_options = { platform: 'centos', version: '6.5' } ChefSpec::SoloRunner.new(env_options) do |node| - node.set["percona"]["client"]["package_action"] = "upgrade" + node.set['percona']['client']['package_action'] = 'upgrade' end.converge(described_recipe) end specify do - expect(chef_run).to upgrade_package "Percona-Server-devel-56" - expect(chef_run).to upgrade_package "Percona-Server-client-56" + expect(chef_run).to upgrade_package 'Percona-Server-devel-56' + expect(chef_run).to upgrade_package 'Percona-Server-client-56' end end end diff --git a/spec/cluster_spec.rb b/spec/cluster_spec.rb index 88fed1f8..1e360f93 100644 --- a/spec/cluster_spec.rb +++ b/spec/cluster_spec.rb @@ -1,54 +1,54 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::cluster" do +describe 'percona::cluster' do let(:chef_run) do ChefSpec::SoloRunner.new.converge(described_recipe) end before do - stub_command("test -f /var/lib/mysql/mysql/user.frm").and_return(true) + stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(true) stub_command("mysqladmin --user=root --password='' version") .and_return(true) end specify do - expect(chef_run).to include_recipe "percona::package_repo" - expect(chef_run).to include_recipe "percona::configure_server" - expect(chef_run).to include_recipe "percona::access_grants" + expect(chef_run).to include_recipe 'percona::package_repo' + expect(chef_run).to include_recipe 'percona::configure_server' + expect(chef_run).to include_recipe 'percona::access_grants' - expect(chef_run).to_not include_recipe "yum-epel" + expect(chef_run).to_not include_recipe 'yum-epel' end - describe "version 5.5" do + describe 'version 5.5' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["version"] = "5.5" + node.set['percona']['version'] = '5.5' end.converge(described_recipe) end let(:centos_cluster_package) do - "Percona-XtraDB-Cluster-55" + 'Percona-XtraDB-Cluster-55' end let(:ubuntu_cluster_package) do - "percona-xtradb-cluster-55" + 'percona-xtradb-cluster-55' end - describe "Ubuntu" do + describe 'Ubuntu' do specify do expect(chef_run).to install_package(ubuntu_cluster_package) expect(chef_run.package(ubuntu_cluster_package)).to( - notify("service[mysql]").to(:stop).immediately + notify('service[mysql]').to(:stop).immediately ) end end - describe "CentOS" do + describe 'CentOS' do let(:chef_run) do - env_options = { platform: "centos", version: "6.5" } + env_options = { platform: 'centos', version: '6.5' } ChefSpec::SoloRunner.new(env_options) do |node| - node.set["percona"]["version"] = "5.5" + node.set['percona']['version'] = '5.5' end.converge(described_recipe) end @@ -58,45 +58,45 @@ end specify do - expect(chef_run).to remove_package "mysql-libs" + expect(chef_run).to remove_package 'mysql-libs' - expect(chef_run).to include_recipe "yum-epel" + expect(chef_run).to include_recipe 'yum-epel' expect(chef_run).to install_package centos_cluster_package end end end - describe "version 5.6" do + describe 'version 5.6' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["version"] = "5.6" + node.set['percona']['version'] = '5.6' end.converge(described_recipe) end let(:centos_cluster_package) do - "Percona-XtraDB-Cluster-56" + 'Percona-XtraDB-Cluster-56' end let(:ubuntu_cluster_package) do - "percona-xtradb-cluster-56" + 'percona-xtradb-cluster-56' end - describe "Ubuntu" do + describe 'Ubuntu' do specify do expect(chef_run).to install_package(ubuntu_cluster_package) expect(chef_run.package(ubuntu_cluster_package)).to( - notify("service[mysql]").to(:stop).immediately + notify('service[mysql]').to(:stop).immediately ) end end - describe "CentOS" do + describe 'CentOS' do let(:chef_run) do - env_options = { platform: "centos", version: "6.5" } + env_options = { platform: 'centos', version: '6.5' } ChefSpec::SoloRunner.new(env_options) do |node| - node.set["percona"]["version"] = "5.6" + node.set['percona']['version'] = '5.6' end.converge(described_recipe) end @@ -106,9 +106,9 @@ end specify do - expect(chef_run).to remove_package "mysql-libs" + expect(chef_run).to remove_package 'mysql-libs' - expect(chef_run).to include_recipe "yum-epel" + expect(chef_run).to include_recipe 'yum-epel' expect(chef_run).to install_package centos_cluster_package end diff --git a/spec/configure_server_spec.rb b/spec/configure_server_spec.rb index c18aef70..612b6219 100644 --- a/spec/configure_server_spec.rb +++ b/spec/configure_server_spec.rb @@ -1,214 +1,214 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::configure_server" do - describe "first run" do +describe 'percona::configure_server' do + describe 'first run' do let(:chef_run) do ChefSpec::SoloRunner.new.converge(described_recipe) end before do - stub_command("test -f /var/lib/mysql/mysql/user.frm").and_return(false) + stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(false) stub_command("mysqladmin --user=root --password='' version") .and_return(true) end - it "does not include the `chef-vault` recipe" do - expect(chef_run).to_not include_recipe "chef-vault" + it 'does not include the `chef-vault` recipe' do + expect(chef_run).to_not include_recipe 'chef-vault' end - it "creates the main server config file" do - expect(chef_run).to create_template("/etc/mysql/my.cnf").with( - owner: "root", - group: "root", - mode: "0644", - cookbook: "percona", - source: "my.cnf.main.erb" + it 'creates the main server config file' do + expect(chef_run).to create_template('/etc/mysql/my.cnf').with( + owner: 'root', + group: 'root', + mode: '0644', + cookbook: 'percona', + source: 'my.cnf.main.erb' ) - expect(chef_run).to render_file("/etc/mysql/my.cnf").with_content( - "performance_schema=OFF" + expect(chef_run).to render_file('/etc/mysql/my.cnf').with_content( + 'performance_schema=OFF' ) - resource = chef_run.template("/etc/mysql/my.cnf") - expect(resource).to notify("execute[setup mysql datadir]").to(:run).immediately # rubocop:disable LineLength - expect(resource).to notify("service[mysql]").to(:restart).immediately + resource = chef_run.template('/etc/mysql/my.cnf') + expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately + expect(resource).to notify('service[mysql]').to(:restart).immediately end - it "creates the data directory" do - expect(chef_run).to create_directory("/var/lib/mysql").with( - owner: "mysql", - group: "mysql", + it 'creates the data directory' do + expect(chef_run).to create_directory('/var/lib/mysql').with( + owner: 'mysql', + group: 'mysql', recursive: true ) end - it "defines the setup for the data directory" do - resource = chef_run.execute("setup mysql datadir") + it 'defines the setup for the data directory' do + resource = chef_run.execute('setup mysql datadir') expect(resource).to do_nothing end - it "creates the log directory" do - expect(chef_run).to create_directory("log directory").with( - path: "/var/log/mysql", - owner: "mysql", - group: "mysql", + it 'creates the log directory' do + expect(chef_run).to create_directory('log directory').with( + path: '/var/log/mysql', + owner: 'mysql', + group: 'mysql', recursive: true ) end - it "do not create duplicated slow query log directory" do - expect(chef_run).to_not create_directory("slow query log directory").with( - path: "/var/log/mysql", - owner: "mysql", - group: "mysql", + it 'do not create duplicated slow query log directory' do + expect(chef_run).to_not create_directory('slow query log directory').with( + path: '/var/log/mysql', + owner: 'mysql', + group: 'mysql', recursive: true ) end - it "creates the temporary directory" do - expect(chef_run).to create_directory("/tmp").with( - owner: "mysql", - group: "mysql", + it 'creates the temporary directory' do + expect(chef_run).to create_directory('/tmp').with( + owner: 'mysql', + group: 'mysql', recursive: true ) end - it "creates the configuration include directory" do - expect(chef_run).to create_directory("/etc/mysql/conf.d/").with( - owner: "mysql", - group: "mysql", + it 'creates the configuration include directory' do + expect(chef_run).to create_directory('/etc/mysql/conf.d/').with( + owner: 'mysql', + group: 'mysql', recursive: true ) end - it "updates the root user password" do - expect(chef_run).to run_execute("Update MySQL root password") + it 'updates the root user password' do + expect(chef_run).to run_execute('Update MySQL root password') end end - describe "subsequent runs" do + describe 'subsequent runs' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["main_config_file"] = "/mysql/my.cnf" - node.set["percona"]["server"]["root_password"] = "s3kr1t" - node.set["percona"]["server"]["debian_password"] = "d3b1an" - node.set["percona"]["server"]["performance_schema"] = true - node.set["percona"]["conf"]["mysqld"]["datadir"] = "/mysql/data" - node.set["percona"]["conf"]["mysqld"]["tmpdir"] = "/mysql/tmp" - node.set["percona"]["conf"]["mysqld"]["includedir"] = "/mysql/conf.d" + node.set['percona']['main_config_file'] = '/mysql/my.cnf' + node.set['percona']['server']['root_password'] = 's3kr1t' + node.set['percona']['server']['debian_password'] = 'd3b1an' + node.set['percona']['server']['performance_schema'] = true + node.set['percona']['conf']['mysqld']['datadir'] = '/mysql/data' + node.set['percona']['conf']['mysqld']['tmpdir'] = '/mysql/tmp' + node.set['percona']['conf']['mysqld']['includedir'] = '/mysql/conf.d' end.converge(described_recipe) end before do - stub_command("test -f /mysql/data/mysql/user.frm").and_return(true) + stub_command('test -f /mysql/data/mysql/user.frm').and_return(true) stub_command("mysqladmin --user=root --password='' version") .and_return(false) end - it "creates a `.my.cnf` file for root" do - expect(chef_run).to create_template("/root/.my.cnf").with( - owner: "root", - group: "root", - mode: "0600", + it 'creates a `.my.cnf` file for root' do + expect(chef_run).to create_template('/root/.my.cnf').with( + owner: 'root', + group: 'root', + mode: '0600', sensitive: true ) - expect(chef_run).to render_file("/root/.my.cnf").with_content("s3kr1t") + expect(chef_run).to render_file('/root/.my.cnf').with_content('s3kr1t') end - it "creates the configuration directory" do - expect(chef_run).to create_directory("/etc/mysql").with( - owner: "root", - group: "root", - mode: "0755" + it 'creates the configuration directory' do + expect(chef_run).to create_directory('/etc/mysql').with( + owner: 'root', + group: 'root', + mode: '0755' ) end - it "creates the data directory" do - expect(chef_run).to create_directory("/mysql/data").with( - owner: "mysql", - group: "mysql", + it 'creates the data directory' do + expect(chef_run).to create_directory('/mysql/data').with( + owner: 'mysql', + group: 'mysql', recursive: true ) end - it "creates the temporary directory" do - expect(chef_run).to create_directory("/mysql/tmp").with( - owner: "mysql", - group: "mysql", + it 'creates the temporary directory' do + expect(chef_run).to create_directory('/mysql/tmp').with( + owner: 'mysql', + group: 'mysql', recursive: true ) end - it "creates the configuration include directory" do - expect(chef_run).to create_directory("/mysql/conf.d").with( - owner: "mysql", - group: "mysql", + it 'creates the configuration include directory' do + expect(chef_run).to create_directory('/mysql/conf.d').with( + owner: 'mysql', + group: 'mysql', recursive: true ) end - it "creates the slow query log directory" do - expect(chef_run).to create_directory("/var/log/mysql").with( - owner: "mysql", - group: "mysql", + it 'creates the slow query log directory' do + expect(chef_run).to create_directory('/var/log/mysql').with( + owner: 'mysql', + group: 'mysql', recursive: true ) end - it "manages the `mysql` service" do - expect(chef_run).to enable_service("mysql") + it 'manages the `mysql` service' do + expect(chef_run).to enable_service('mysql') end - it "defines the setup for the data directory" do - resource = chef_run.execute("setup mysql datadir") + it 'defines the setup for the data directory' do + resource = chef_run.execute('setup mysql datadir') expect(resource).to do_nothing end - it "creates the main server config file" do - expect(chef_run).to create_template("/mysql/my.cnf").with( - owner: "root", - group: "root", - mode: "0644", + it 'creates the main server config file' do + expect(chef_run).to create_template('/mysql/my.cnf').with( + owner: 'root', + group: 'root', + mode: '0644', sensitive: true, - cookbook: "percona", - source: "my.cnf.main.erb" + cookbook: 'percona', + source: 'my.cnf.main.erb' ) - expect(chef_run).to render_file("/mysql/my.cnf").with_content( - "performance_schema=ON" + expect(chef_run).to render_file('/mysql/my.cnf').with_content( + 'performance_schema=ON' ) - resource = chef_run.template("/mysql/my.cnf") - expect(resource).to notify("execute[setup mysql datadir]").to(:run).immediately # rubocop:disable LineLength - expect(resource).to notify("service[mysql]").to(:restart).immediately + resource = chef_run.template('/mysql/my.cnf') + expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately + expect(resource).to notify('service[mysql]').to(:restart).immediately end - it "does not update the root user password" do - expect(chef_run).to_not run_execute("Update MySQL root password") + it 'does not update the root user password' do + expect(chef_run).to_not run_execute('Update MySQL root password') end - it "creates the debian system user config file" do - debian_cnf = "/etc/mysql/debian.cnf" + it 'creates the debian system user config file' do + debian_cnf = '/etc/mysql/debian.cnf' expect(chef_run).to create_template(debian_cnf).with( - owner: "root", - group: "root", - mode: "0640", + owner: 'root', + group: 'root', + mode: '0640', sensitive: true ) - expect(chef_run).to render_file(debian_cnf).with_content("d3b1an") + expect(chef_run).to render_file(debian_cnf).with_content('d3b1an') resource = chef_run.template(debian_cnf) - expect(resource).to notify("service[mysql]").to(:restart).immediately + expect(resource).to notify('service[mysql]').to(:restart).immediately end end - describe "custom slow query log directory" do + describe 'custom slow query log directory' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["server"]["slow_query_logdir"] = "/var/log/slowq" + node.set['percona']['server']['slow_query_logdir'] = '/var/log/slowq' end.converge(described_recipe) end @@ -217,51 +217,51 @@ .and_return(true) end - it "creates the slow query log directory" do - expect(chef_run).to create_directory("/var/log/slowq").with( - owner: "mysql", - group: "mysql", + it 'creates the slow query log directory' do + expect(chef_run).to create_directory('/var/log/slowq').with( + owner: 'mysql', + group: 'mysql', recursive: true ) end end - describe "`rhel` platform family" do + describe '`rhel` platform family' do let(:chef_run) do - env_options = { platform: "centos", version: "6.5" } + env_options = { platform: 'centos', version: '6.5' } ChefSpec::SoloRunner.new(env_options).converge(described_recipe) end before do - stub_command("test -f /var/lib/mysql/mysql/user.frm").and_return(false) + stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(false) stub_command("mysqladmin --user=root --password='' version") .and_return(true) end - it "creates the main server config file" do - expect(chef_run).to create_template("/etc/my.cnf").with( - owner: "root", - group: "root", - mode: "0644", + it 'creates the main server config file' do + expect(chef_run).to create_template('/etc/my.cnf').with( + owner: 'root', + group: 'root', + mode: '0644', sensitive: true, - cookbook: "percona", - source: "my.cnf.main.erb" + cookbook: 'percona', + source: 'my.cnf.main.erb' ) - resource = chef_run.template("/etc/my.cnf") - expect(resource).to notify("execute[setup mysql datadir]").to(:run).immediately # rubocop:disable LineLength - expect(resource).to notify("service[mysql]").to(:restart).immediately + resource = chef_run.template('/etc/my.cnf') + expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately + expect(resource).to notify('service[mysql]').to(:restart).immediately end - it "does not create the configuration include directory" do - expect(chef_run).to_not create_directory("/mysql/conf.d") + it 'does not create the configuration include directory' do + expect(chef_run).to_not create_directory('/mysql/conf.d') end end - describe "`chef-vault` support" do + describe '`chef-vault` support' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["use_chef_vault"] = true + node.set['percona']['use_chef_vault'] = true end.converge(described_recipe) end @@ -270,8 +270,8 @@ .and_return(false) end - it "includes the `chef-vault` recipe" do - expect(chef_run).to include_recipe "chef-vault" + it 'includes the `chef-vault` recipe' do + expect(chef_run).to include_recipe 'chef-vault' end end end diff --git a/spec/default_spec.rb b/spec/default_spec.rb index a5a3236d..3cd193ce 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -1,9 +1,9 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::default" do +describe 'percona::default' do let(:chef_run) do ChefSpec::SoloRunner.new.converge(described_recipe) end - it { expect(chef_run).to include_recipe("percona::client") } + it { expect(chef_run).to include_recipe('percona::client') } end diff --git a/spec/monitoring_spec.rb b/spec/monitoring_spec.rb index 8a76dded..0d486d4a 100644 --- a/spec/monitoring_spec.rb +++ b/spec/monitoring_spec.rb @@ -1,11 +1,11 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::monitoring" do +describe 'percona::monitoring' do let(:chef_run) do ChefSpec::SoloRunner.new.converge(described_recipe) end - it { expect(chef_run).to install_package("percona-nagios-plugins") } - it { expect(chef_run).to install_package("percona-zabbix-templates") } - it { expect(chef_run).to install_package("percona-cacti-templates") } + it { expect(chef_run).to install_package('percona-nagios-plugins') } + it { expect(chef_run).to install_package('percona-zabbix-templates') } + it { expect(chef_run).to install_package('percona-cacti-templates') } end diff --git a/spec/package_repo_spec.rb b/spec/package_repo_spec.rb index 83e98ac5..e516aa82 100644 --- a/spec/package_repo_spec.rb +++ b/spec/package_repo_spec.rb @@ -1,28 +1,28 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::package_repo" do - describe "Ubuntu" do +describe 'percona::package_repo' do + describe 'Ubuntu' do let(:chef_run) do ChefSpec::SoloRunner.new.converge(described_recipe) end - it "sets up an apt repository for `percona`" do - expect(chef_run).to add_apt_repository("percona") + it 'sets up an apt repository for `percona`' do + expect(chef_run).to add_apt_repository('percona') end - it "sets up an apt preference" do - expect(chef_run).to add_apt_preference("00percona") + it 'sets up an apt preference' do + expect(chef_run).to add_apt_preference('00percona') end end - describe "CentOS" do + describe 'CentOS' do let(:chef_run) do - env_options = { platform: "centos", version: "6.5" } + env_options = { platform: 'centos', version: '6.5' } ChefSpec::SoloRunner.new(env_options).converge(described_recipe) end - it "sets up a yum repository for `percona`" do - expect(chef_run).to create_yum_repository("percona") + it 'sets up a yum repository for `percona`' do + expect(chef_run).to create_yum_repository('percona') end end end diff --git a/spec/replication_spec.rb b/spec/replication_spec.rb index b309f458..74e170a7 100644 --- a/spec/replication_spec.rb +++ b/spec/replication_spec.rb @@ -1,50 +1,50 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::replication" do +describe 'percona::replication' do let(:replication_sql) do - "/etc/mysql/replication.sql" + '/etc/mysql/replication.sql' end - describe "without replication configured" do + describe 'without replication configured' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["server"]["role"] = [] - node.set["percona"]["server"]["replication"]["host"] = "" + node.set['percona']['server']['role'] = [] + node.set['percona']['server']['replication']['host'] = '' end.converge(described_recipe) end - it "does not create a replication template" do + it 'does not create a replication template' do expect(chef_run).to_not create_template(replication_sql) end - it "does not execute the replication sql" do - expect(chef_run).to_not run_execute("mysql-set-replication") + it 'does not execute the replication sql' do + expect(chef_run).to_not run_execute('mysql-set-replication') - resource = chef_run.execute("mysql-set-replication") + resource = chef_run.execute('mysql-set-replication') expect(resource).to do_nothing end end - describe "with replication configured" do + describe 'with replication configured' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["server"]["role"] = ["master"] - node.set["percona"]["server"]["replication"]["password"] = "s3kr1t" + node.set['percona']['server']['role'] = ['master'] + node.set['percona']['server']['replication']['password'] = 's3kr1t' end.converge(described_recipe) end - it "creates a replication template" do + it 'creates a replication template' do expect(chef_run).to create_template(replication_sql).with( - owner: "root", - group: "root", - mode: "0600", + owner: 'root', + group: 'root', + mode: '0600', sensitive: true ) - expect(chef_run).to render_file(replication_sql).with_content("s3kr1t") + expect(chef_run).to render_file(replication_sql).with_content('s3kr1t') end - it "executes the replication sql" do - resource = chef_run.execute("mysql-set-replication") + it 'executes the replication sql' do + resource = chef_run.execute('mysql-set-replication') expect(resource).to( subscribe_to("template[#{replication_sql}]").on(:run).immediately ) diff --git a/spec/server_spec.rb b/spec/server_spec.rb index 8f1d728f..e4649d7a 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -1,32 +1,32 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::server" do +describe 'percona::server' do let(:chef_run) do ChefSpec::SoloRunner.new.converge(described_recipe) end before do - stub_command("test -f /var/lib/mysql/mysql/user.frm").and_return(true) + stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(true) stub_command("mysqladmin --user=root --password='' version") .and_return(true) end - it { expect(chef_run).to include_recipe("percona::package_repo") } - it { expect(chef_run).to include_recipe("percona::configure_server") } - it { expect(chef_run).to include_recipe("percona::access_grants") } - it { expect(chef_run).to include_recipe("percona::replication") } + it { expect(chef_run).to include_recipe('percona::package_repo') } + it { expect(chef_run).to include_recipe('percona::configure_server') } + it { expect(chef_run).to include_recipe('percona::access_grants') } + it { expect(chef_run).to include_recipe('percona::replication') } - describe "Ubuntu" do - it { expect(chef_run).to install_package("percona-server-server-5.6") } + describe 'Ubuntu' do + it { expect(chef_run).to install_package('percona-server-server-5.6') } end - describe "CentOS" do + describe 'CentOS' do let(:shared_pkg) do - "Percona-Server-shared-56" + 'Percona-Server-shared-56' end let(:chef_run) do - env_options = { platform: "centos", version: "6.5" } + env_options = { platform: 'centos', version: '6.5' } ChefSpec::SoloRunner.new(env_options).converge(described_recipe) end @@ -34,68 +34,68 @@ stub_command("rpm -qa | grep #{shared_pkg}").and_return(false) end - describe "without percona server shared package" do - it { expect(chef_run).to remove_package("mysql-libs") } + describe 'without percona server shared package' do + it { expect(chef_run).to remove_package('mysql-libs') } end - describe "with percona server shared package" do + describe 'with percona server shared package' do before do stub_command("rpm -qa | grep #{shared_pkg}").and_return(true) end - it { expect(chef_run).to_not remove_package("mysql-libs") } + it { expect(chef_run).to_not remove_package('mysql-libs') } end - it { expect(chef_run).to include_recipe("percona::client") } - it { expect(chef_run).to install_package("Percona-Server-server-56") } + it { expect(chef_run).to include_recipe('percona::client') } + it { expect(chef_run).to install_package('Percona-Server-server-56') } end - describe "when `skip_configure` is true" do + describe 'when `skip_configure` is true' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["skip_configure"] = true + node.set['percona']['skip_configure'] = true end.converge(described_recipe) end - it { expect(chef_run).to_not include_recipe("percona::configure_server") } + it { expect(chef_run).to_not include_recipe('percona::configure_server') } end - describe "when `skip_passwords` is true" do + describe 'when `skip_passwords` is true' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["skip_passwords"] = true + node.set['percona']['skip_passwords'] = true end.converge(described_recipe) end - it { expect(chef_run).to_not include_recipe("percona::access_grants") } - it { expect(chef_run).to_not include_recipe("percona::replication") } + it { expect(chef_run).to_not include_recipe('percona::access_grants') } + it { expect(chef_run).to_not include_recipe('percona::replication') } end - describe "when `package_action` is `upgrade`" do - describe "Ubuntu" do + describe 'when `package_action` is `upgrade`' do + describe 'Ubuntu' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["server"]["package_action"] = "upgrade" + node.set['percona']['server']['package_action'] = 'upgrade' end.converge(described_recipe) end - it { expect(chef_run).to upgrade_package("percona-server-server-5.6") } + it { expect(chef_run).to upgrade_package('percona-server-server-5.6') } end - describe "CentOS" do + describe 'CentOS' do let(:chef_run) do - env_options = { platform: "centos", version: "6.5" } + env_options = { platform: 'centos', version: '6.5' } ChefSpec::SoloRunner.new(env_options) do |node| - node.set["percona"]["server"]["package_action"] = "upgrade" + node.set['percona']['server']['package_action'] = 'upgrade' end.converge(described_recipe) end before do - stub_command("rpm -qa | grep Percona-Server-shared-56") + stub_command('rpm -qa | grep Percona-Server-shared-56') .and_return(false) end - it { expect(chef_run).to upgrade_package("Percona-Server-server-56") } + it { expect(chef_run).to upgrade_package('Percona-Server-server-56') } end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2c6540ae..c2490b26 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,14 +1,14 @@ begin - require "chefspec" - require "chefspec/berkshelf" + require 'chefspec' + require 'chefspec/berkshelf' rescue LoadError - puts "Unable to run `chefspec`" + puts 'Unable to run `chefspec`' exit end RSpec.configure do |config| - config.platform = "ubuntu" - config.version = "12.04" + config.platform = 'ubuntu' + config.version = '12.04' config.log_level = :error config.raise_errors_for_deprecations! end diff --git a/spec/ssl_spec.rb b/spec/ssl_spec.rb index 83e73dd6..ea070411 100644 --- a/spec/ssl_spec.rb +++ b/spec/ssl_spec.rb @@ -1,67 +1,67 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::ssl" do +describe 'percona::ssl' do let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set["percona"]["encrypted_data_bag"] = "test-bag" - node.set["percona"]["server"]["role"] = %w[master slave] + node.set['percona']['encrypted_data_bag'] = 'test-bag' + node.set['percona']['server']['role'] = %w(master slave) end.converge(described_recipe) end before do expect(Chef::EncryptedDataBagItem).to( - receive(:load).with("test-bag", "ssl_replication").and_return( - "ca-cert" => "test-ca-cert", - "client" => { - "client-cert" => "test-client-cert", - "client-key" => "test-client-key" + receive(:load).with('test-bag', 'ssl_replication').and_return( + 'ca-cert' => 'test-ca-cert', + 'client' => { + 'client-cert' => 'test-client-cert', + 'client-key' => 'test-client-key', }, - "server" => { - "server-cert" => "test-server-cert", - "server-key" => "test-server-key" + 'server' => { + 'server-cert' => 'test-server-cert', + 'server-key' => 'test-server-key', } ) ) end - it "creates the certificate directory" do - expect(chef_run).to create_directory("/etc/mysql/ssl").with( - user: "mysql", - mode: "0700" + it 'creates the certificate directory' do + expect(chef_run).to create_directory('/etc/mysql/ssl').with( + user: 'mysql', + mode: '0700' ) end - it "creates the CA certificate" do - expect(chef_run).to create_file("/etc/mysql/ssl/cacert.pem").with( - content: "test-ca-cert", + it 'creates the CA certificate' do + expect(chef_run).to create_file('/etc/mysql/ssl/cacert.pem').with( + content: 'test-ca-cert', sensitive: true ) end - it "creates the server key" do - expect(chef_run).to create_file("/etc/mysql/ssl/server-key.pem").with( - content: "test-server-key", + it 'creates the server key' do + expect(chef_run).to create_file('/etc/mysql/ssl/server-key.pem').with( + content: 'test-server-key', sensitive: true ) end - it "creates the server certificate" do - expect(chef_run).to create_file("/etc/mysql/ssl/server-cert.pem").with( - content: "test-server-cert", + it 'creates the server certificate' do + expect(chef_run).to create_file('/etc/mysql/ssl/server-cert.pem').with( + content: 'test-server-cert', sensitive: true ) end - it "creates the client key" do - expect(chef_run).to create_file("/etc/mysql/ssl/client-key.pem").with( - content: "test-client-key", + it 'creates the client key' do + expect(chef_run).to create_file('/etc/mysql/ssl/client-key.pem').with( + content: 'test-client-key', sensitive: true ) end - it "creates the client certificate" do - expect(chef_run).to create_file("/etc/mysql/ssl/client-cert.pem").with( - content: "test-client-cert", + it 'creates the client certificate' do + expect(chef_run).to create_file('/etc/mysql/ssl/client-cert.pem').with( + content: 'test-client-cert', sensitive: true ) end diff --git a/spec/toolkit_spec.rb b/spec/toolkit_spec.rb index 96a2b9c6..fc1757a5 100644 --- a/spec/toolkit_spec.rb +++ b/spec/toolkit_spec.rb @@ -1,11 +1,11 @@ -require "spec_helper" +require 'spec_helper' -describe "percona::toolkit" do +describe 'percona::toolkit' do let(:toolkit_package) do - "percona-toolkit" + 'percona-toolkit' end - describe "Ubuntu" do + describe 'Ubuntu' do let(:chef_run) do ChefSpec::SoloRunner.new.converge(described_recipe) end @@ -15,12 +15,12 @@ end end - describe "CentOS" do - describe "when `version` is 5.5" do + describe 'CentOS' do + describe 'when `version` is 5.5' do let(:chef_run) do - env_options = { platform: "centos", version: "6.5" } + env_options = { platform: 'centos', version: '6.5' } ChefSpec::SoloRunner.new(env_options) do |node| - node.set["percona"]["version"] = "5.5" + node.set['percona']['version'] = '5.5' end.converge(described_recipe) end @@ -29,11 +29,11 @@ end end - describe "when `version` is 5.6" do + describe 'when `version` is 5.6' do let(:chef_run) do - env_options = { platform: "centos", version: "6.5" } + env_options = { platform: 'centos', version: '6.5' } ChefSpec::SoloRunner.new(env_options) do |node| - node.set["percona"]["version"] = "5.6" + node.set['percona']['version'] = '5.6' end.converge(described_recipe) end diff --git a/test/.chef/knife.rb b/test/.chef/knife.rb deleted file mode 100644 index bfc8607d..00000000 --- a/test/.chef/knife.rb +++ /dev/null @@ -1,2 +0,0 @@ -cache_type "BasicFile" -cache_options(:path => "#{ENV["HOME"]}/.chef/checksums") diff --git a/test/integration/client_55/serverspec/localhost/client_55_spec.rb b/test/integration/client_55/serverspec/localhost/client_55_spec.rb index b5c14352..a32c4f89 100644 --- a/test/integration/client_55/serverspec/localhost/client_55_spec.rb +++ b/test/integration/client_55/serverspec/localhost/client_55_spec.rb @@ -1,54 +1,54 @@ -require "serverspec" +require 'serverspec' set :backend, :exec def ubuntu? - os[:family] == "ubuntu" + os[:family] == 'ubuntu' end def redhat? - os[:family] == "redhat" + os[:family] == 'redhat' end -describe "Ubuntu package installation", if: ubuntu? do - describe file("/etc/apt/sources.list.d/percona.list") do +describe 'Ubuntu package installation', if: ubuntu? do + describe file('/etc/apt/sources.list.d/percona.list') do it { should be_a_file } - its(:content) { should match "http://repo.percona.com/apt" } + its(:content) { should match 'http://repo.percona.com/apt' } end - describe file("/etc/apt/preferences.d/00percona.pref") do + describe file('/etc/apt/preferences.d/00percona.pref') do it { should be_a_file } - its(:content) { should match "release o=Percona Development Team" } + its(:content) { should match 'release o=Percona Development Team' } end - describe package("libperconaserverclient18-dev") do + describe package('libperconaserverclient18-dev') do it { should be_installed } end - describe package("percona-server-client-5.5") do + describe package('percona-server-client-5.5') do it { should be_installed } end - describe package("percona-toolkit") do + describe package('percona-toolkit') do it { should be_installed } end end -describe "Red Hat package installation", if: redhat? do - describe yumrepo("percona") do +describe 'Red Hat package installation', if: redhat? do + describe yumrepo('percona') do it { should exist } it { should be_enabled } end - describe package("Percona-Server-devel-55") do + describe package('Percona-Server-devel-55') do it { should be_installed } end - describe package("Percona-Server-client-55") do + describe package('Percona-Server-client-55') do it { should be_installed } end - describe package("percona-toolkit") do + describe package('percona-toolkit') do it { should be_installed } end end diff --git a/test/integration/client_56/serverspec/localhost/client_56_spec.rb b/test/integration/client_56/serverspec/localhost/client_56_spec.rb index 20369d14..a41c7f21 100644 --- a/test/integration/client_56/serverspec/localhost/client_56_spec.rb +++ b/test/integration/client_56/serverspec/localhost/client_56_spec.rb @@ -1,54 +1,54 @@ -require "serverspec" +require 'serverspec' set :backend, :exec def ubuntu? - os[:family] == "ubuntu" + os[:family] == 'ubuntu' end def redhat? - os[:family] == "redhat" + os[:family] == 'redhat' end -describe "Ubuntu package installation" do - describe file("/etc/apt/sources.list.d/percona.list"), if: ubuntu? do +describe 'Ubuntu package installation' do + describe file('/etc/apt/sources.list.d/percona.list'), if: ubuntu? do it { should be_a_file } - its(:content) { should match "http://repo.percona.com/apt" } + its(:content) { should match 'http://repo.percona.com/apt' } end - describe file("/etc/apt/preferences.d/00percona.pref"), if: ubuntu? do + describe file('/etc/apt/preferences.d/00percona.pref'), if: ubuntu? do it { should be_a_file } - its(:content) { should match "release o=Percona Development Team" } + its(:content) { should match 'release o=Percona Development Team' } end - describe package("libperconaserverclient18.1-dev"), if: ubuntu? do + describe package('libperconaserverclient18.1-dev'), if: ubuntu? do it { should be_installed } end - describe package("percona-server-client-5.6"), if: ubuntu? do + describe package('percona-server-client-5.6'), if: ubuntu? do it { should be_installed } end - describe package("percona-toolkit") do + describe package('percona-toolkit') do it { should be_installed } end end -describe "Red Hat package installation" do - describe yumrepo("percona"), if: redhat? do +describe 'Red Hat package installation' do + describe yumrepo('percona'), if: redhat? do it { should exist } it { should be_enabled } end - describe package("Percona-Server-devel-56"), if: redhat? do + describe package('Percona-Server-devel-56'), if: redhat? do it { should be_installed } end - describe package("Percona-Server-client-56"), if: redhat? do + describe package('Percona-Server-client-56'), if: redhat? do it { should be_installed } end - describe package("percona-toolkit") do + describe package('percona-toolkit') do it { should be_installed } end end diff --git a/test/integration/server_55/serverspec/localhost/server_55_spec.rb b/test/integration/server_55/serverspec/localhost/server_55_spec.rb index f8d8363d..1d3f26b5 100644 --- a/test/integration/server_55/serverspec/localhost/server_55_spec.rb +++ b/test/integration/server_55/serverspec/localhost/server_55_spec.rb @@ -1,83 +1,83 @@ -require "serverspec" +require 'serverspec' set :backend, :exec def ubuntu? - os[:family] == "ubuntu" + os[:family] == 'ubuntu' end def redhat? - os[:family] == "redhat" + os[:family] == 'redhat' end -describe "Ubuntu package installation", if: ubuntu? do - describe package("percona-server-server-5.5") do +describe 'Ubuntu package installation', if: ubuntu? do + describe package('percona-server-server-5.5') do it { should be_installed } end - describe package("libjemalloc1") do + describe package('libjemalloc1') do it { should be_installed } end end -describe "Red Hat package installation", if: redhat? do - describe package("Percona-Server-devel-55") do +describe 'Red Hat package installation', if: redhat? do + describe package('Percona-Server-devel-55') do it { should be_installed } end - describe package("Percona-Server-client-55") do + describe package('Percona-Server-client-55') do it { should be_installed } end - describe package("Percona-Server-server-55") do + describe package('Percona-Server-server-55') do it { should be_installed } end - describe package("jemalloc") do + describe package('jemalloc') do it { should be_installed } end end -describe "Service configuration" do - describe file("/root/.my.cnf") do +describe 'Service configuration' do + describe file('/root/.my.cnf') do it { should be_a_file } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 600 } - its(:content) { should match "r00t" } + its(:content) { should match 'r00t' } end - describe file("/etc/mysql") do + describe file('/etc/mysql') do it { should be_a_directory } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 755 } end - describe file("/var/lib/mysql") do + describe file('/var/lib/mysql') do it { should be_a_directory } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } end - describe file("/var/log/mysql") do + describe file('/var/log/mysql') do it { should be_a_directory } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } end - describe file("/tmp") do + describe file('/tmp') do it { should be_a_directory } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } end - describe service("mysql") do + describe service('mysql') do it { should be_enabled } it { should be_running } end - describe command("pgrep mysql") do + describe command('pgrep mysql') do its(:stdout) { should match(/\d+/) } its(:exit_status) { should eq 0 } end @@ -86,82 +86,82 @@ def redhat? it { should be_listening } end - describe file("/var/lib/mysql/mysql/user.frm") do + describe file('/var/lib/mysql/mysql/user.frm') do it { should be_a_file } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } end - describe file("/etc/mysql/my.cnf"), if: ubuntu? do + describe file('/etc/mysql/my.cnf'), if: ubuntu? do it { should be_a_file } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 644 } end - describe file("/etc/my.cnf"), if: redhat? do + describe file('/etc/my.cnf'), if: redhat? do it { should be_a_file } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 644 } end - describe file("/etc/mysql/grants.sql") do + describe file('/etc/mysql/grants.sql') do it { should be_a_file } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 600 } - its(:content) { should match "r00t" } + its(:content) { should match 'r00t' } end - describe file("/etc/mysql/grants.sql"), if: ubuntu? do - its(:content) { should match "debian-sys-maint" } - its(:content) { should match "d3b1an" } + describe file('/etc/mysql/grants.sql'), if: ubuntu? do + its(:content) { should match 'debian-sys-maint' } + its(:content) { should match 'd3b1an' } end - describe file("/etc/mysql/debian.cnf"), if: ubuntu? do + describe file('/etc/mysql/debian.cnf'), if: ubuntu? do it { should be_a_file } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 640 } - its(:content) { should match "d3b1an" } + its(:content) { should match 'd3b1an' } end - describe file("/etc/mysql/replication.sql") do + describe file('/etc/mysql/replication.sql') do it { should_not be_a_file } end - describe "Custom data directory" do - describe file("/tmp/mysql") do + describe 'Custom data directory' do + describe file('/tmp/mysql') do it { should be_a_directory } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } end - describe file("/tmp/mysql/ibdata1") do + describe file('/tmp/mysql/ibdata1') do it { should be_a_file } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } it { should be_mode 660 } end - describe file("/tmp/mysql/ibdata1") do + describe file('/tmp/mysql/ibdata1') do it { should be_a_file } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } it { should be_mode 660 } end - describe file("/tmp/mysql/mysql/user.frm") do + describe file('/tmp/mysql/mysql/user.frm') do it { should be_a_file } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } it { should be_mode 660 } end describe command("mysqladmin --user='root' --password='r00t' variables") do - its(:stdout) { should match %r(datadir\s+| /tmp/mysql/) } - its(:stdout) { should match %r(general_log_file\s+| /tmp/mysql/) } + its(:stdout) { should match %r{datadir\s+| /tmp/mysql/} } + its(:stdout) { should match %r{general_log_file\s+| /tmp/mysql/} } its(:exit_status) { should eq 0 } end end diff --git a/test/integration/server_56/serverspec/localhost/server_56_spec.rb b/test/integration/server_56/serverspec/localhost/server_56_spec.rb index a542617a..68108e96 100644 --- a/test/integration/server_56/serverspec/localhost/server_56_spec.rb +++ b/test/integration/server_56/serverspec/localhost/server_56_spec.rb @@ -1,83 +1,83 @@ -require "serverspec" +require 'serverspec' set :backend, :exec def ubuntu? - os[:family] == "ubuntu" + os[:family] == 'ubuntu' end def redhat? - os[:family] == "redhat" + os[:family] == 'redhat' end -describe "Ubuntu package installation", if: ubuntu? do - describe package("percona-server-server-5.6") do +describe 'Ubuntu package installation', if: ubuntu? do + describe package('percona-server-server-5.6') do it { should be_installed } end - describe package("libjemalloc1") do + describe package('libjemalloc1') do it { should be_installed } end end -describe "Red Hat package installation", if: redhat? do - describe package("Percona-Server-devel-56") do +describe 'Red Hat package installation', if: redhat? do + describe package('Percona-Server-devel-56') do it { should be_installed } end - describe package("Percona-Server-client-56") do + describe package('Percona-Server-client-56') do it { should be_installed } end - describe package("Percona-Server-server-56") do + describe package('Percona-Server-server-56') do it { should be_installed } end - describe package("jemalloc") do + describe package('jemalloc') do it { should be_installed } end end -describe "Service configuration" do - describe file("/root/.my.cnf") do +describe 'Service configuration' do + describe file('/root/.my.cnf') do it { should be_a_file } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 600 } - its(:content) { should match "r00t" } + its(:content) { should match 'r00t' } end - describe file("/etc/mysql") do + describe file('/etc/mysql') do it { should be_a_directory } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 755 } end - describe file("/var/lib/mysql") do + describe file('/var/lib/mysql') do it { should be_a_directory } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } end - describe file("/var/log/mysql") do + describe file('/var/log/mysql') do it { should be_a_directory } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } end - describe file("/tmp") do + describe file('/tmp') do it { should be_a_directory } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } end - describe service("mysql") do + describe service('mysql') do it { should be_enabled } it { should be_running } end - describe command("pgrep mysql") do + describe command('pgrep mysql') do its(:stdout) { should match(/\d+/) } its(:exit_status) { should eq 0 } end @@ -86,82 +86,82 @@ def redhat? it { should be_listening } end - describe file("/var/lib/mysql/mysql/user.frm") do + describe file('/var/lib/mysql/mysql/user.frm') do it { should be_a_file } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } end - describe file("/etc/mysql/my.cnf"), if: ubuntu? do + describe file('/etc/mysql/my.cnf'), if: ubuntu? do it { should be_a_file } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 644 } end - describe file("/etc/my.cnf"), if: redhat? do + describe file('/etc/my.cnf'), if: redhat? do it { should be_a_file } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 644 } end - describe file("/etc/mysql/grants.sql") do + describe file('/etc/mysql/grants.sql') do it { should be_a_file } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 600 } - its(:content) { should match "r00t" } + its(:content) { should match 'r00t' } end - describe file("/etc/mysql/grants.sql"), if: ubuntu? do - its(:content) { should match "debian-sys-maint" } - its(:content) { should match "d3b1an" } + describe file('/etc/mysql/grants.sql'), if: ubuntu? do + its(:content) { should match 'debian-sys-maint' } + its(:content) { should match 'd3b1an' } end - describe file("/etc/mysql/debian.cnf"), if: ubuntu? do + describe file('/etc/mysql/debian.cnf'), if: ubuntu? do it { should be_a_file } - it { should be_owned_by "root" } - it { should be_grouped_into "root" } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } it { should be_mode 640 } - its(:content) { should match "d3b1an" } + its(:content) { should match 'd3b1an' } end - describe file("/etc/mysql/replication.sql") do + describe file('/etc/mysql/replication.sql') do it { should_not be_a_file } end - describe "Custom data directory" do - describe file("/tmp/mysql") do + describe 'Custom data directory' do + describe file('/tmp/mysql') do it { should be_a_directory } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } end - describe file("/tmp/mysql/ibdata1") do + describe file('/tmp/mysql/ibdata1') do it { should be_a_file } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } it { should be_mode 660 } end - describe file("/tmp/mysql/ibdata1") do + describe file('/tmp/mysql/ibdata1') do it { should be_a_file } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } it { should be_mode 660 } end - describe file("/tmp/mysql/mysql/user.frm") do + describe file('/tmp/mysql/mysql/user.frm') do it { should be_a_file } - it { should be_owned_by "mysql" } - it { should be_grouped_into "mysql" } + it { should be_owned_by 'mysql' } + it { should be_grouped_into 'mysql' } it { should be_mode 660 } end describe command("mysqladmin --user='root' --password='r00t' variables") do - its(:stdout) { should match %r(datadir\s+| /tmp/mysql/) } - its(:stdout) { should match %r(general_log_file\s+| /tmp/mysql/) } + its(:stdout) { should match %r{datadir\s+| /tmp/mysql/} } + its(:stdout) { should match %r{general_log_file\s+| /tmp/mysql/} } its(:exit_status) { should eq 0 } end end From 6d66fd877ee5c299ad59e8e40bc1040d4ecad4e5 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Thu, 14 Jun 2018 20:33:16 +0100 Subject: [PATCH 062/300] default dir is the root level directory now --- templates/{default => }/debian.cnf.erb | 0 templates/{default => }/grants.sql.erb | 0 templates/{default => }/my.cnf.cluster.erb | 0 templates/{default => }/my.cnf.main.erb | 0 templates/{default => }/my.cnf.root.erb | 0 templates/{default => }/replication.sql.erb | 0 test/support/Gemfile.lock | 203 -------------------- test/support/keys/README.md | 17 -- test/support/keys/vagrant | 27 --- test/support/keys/vagrant.pub | 1 - 10 files changed, 248 deletions(-) rename templates/{default => }/debian.cnf.erb (100%) rename templates/{default => }/grants.sql.erb (100%) rename templates/{default => }/my.cnf.cluster.erb (100%) rename templates/{default => }/my.cnf.main.erb (100%) rename templates/{default => }/my.cnf.root.erb (100%) rename templates/{default => }/replication.sql.erb (100%) delete mode 100644 test/support/Gemfile.lock delete mode 100644 test/support/keys/README.md delete mode 100644 test/support/keys/vagrant delete mode 100644 test/support/keys/vagrant.pub diff --git a/templates/default/debian.cnf.erb b/templates/debian.cnf.erb similarity index 100% rename from templates/default/debian.cnf.erb rename to templates/debian.cnf.erb diff --git a/templates/default/grants.sql.erb b/templates/grants.sql.erb similarity index 100% rename from templates/default/grants.sql.erb rename to templates/grants.sql.erb diff --git a/templates/default/my.cnf.cluster.erb b/templates/my.cnf.cluster.erb similarity index 100% rename from templates/default/my.cnf.cluster.erb rename to templates/my.cnf.cluster.erb diff --git a/templates/default/my.cnf.main.erb b/templates/my.cnf.main.erb similarity index 100% rename from templates/default/my.cnf.main.erb rename to templates/my.cnf.main.erb diff --git a/templates/default/my.cnf.root.erb b/templates/my.cnf.root.erb similarity index 100% rename from templates/default/my.cnf.root.erb rename to templates/my.cnf.root.erb diff --git a/templates/default/replication.sql.erb b/templates/replication.sql.erb similarity index 100% rename from templates/default/replication.sql.erb rename to templates/replication.sql.erb diff --git a/test/support/Gemfile.lock b/test/support/Gemfile.lock deleted file mode 100644 index 26653614..00000000 --- a/test/support/Gemfile.lock +++ /dev/null @@ -1,203 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - activesupport (3.2.13) - i18n (= 0.6.1) - multi_json (~> 1.0) - addressable (2.3.4) - akami (1.2.0) - gyoku (>= 0.4.0) - nokogiri (>= 1.4.0) - berkshelf (2.0.3) - activesupport (>= 3.2.0) - addressable (~> 2.3.4) - celluloid (>= 0.14.0) - chozo (>= 0.6.1) - faraday (>= 0.8.5) - hashie (>= 2.0.2) - minitar (~> 0.5.4) - retryable (~> 1.3.3) - ridley (~> 1.0.2) - solve (>= 0.4.4) - test-kitchen (>= 1.0.0.alpha7) - thor (~> 0.18.0) - builder (3.2.2) - bunny (0.7.9) - celluloid (0.14.1) - timers (>= 1.0.0) - celluloid-io (0.14.1) - celluloid (>= 0.14.1) - nio4r (>= 0.4.5) - chef (10.16.6) - bunny (>= 0.6.0, < 0.8.0) - erubis - highline (>= 1.6.9) - json (>= 1.4.4, <= 1.6.1) - mixlib-authentication (>= 1.3.0) - mixlib-cli (>= 1.1.0) - mixlib-config (>= 1.1.2) - mixlib-log (>= 1.3.0) - mixlib-shellout - moneta (< 0.7.0) - net-ssh (~> 2.2.2) - net-ssh-multi (~> 1.1.0) - ohai (>= 0.6.0) - rest-client (>= 1.0.4, < 1.7.0) - treetop (~> 1.4.9) - uuidtools - yajl-ruby (~> 1.1) - chozo (0.6.1) - activesupport (>= 3.2.0) - hashie (>= 2.0.2) - multi_json (>= 1.3.0) - coderay (1.0.9) - erubis (2.7.0) - excon (0.24.0) - faraday (0.8.7) - multipart-post (~> 1.1) - ffi (1.9.0) - fog (1.9.0) - builder - excon (~> 0.14) - formatador (~> 0.2.0) - mime-types - multi_json (~> 1.0) - net-scp (~> 1.0.4) - net-ssh (>= 2.1.3) - nokogiri (~> 1.5.0) - ruby-hmac - foodcritic (2.1.0) - erubis - gherkin (~> 2.11.7) - nokogiri (~> 1.5.4) - rak (~> 1.4) - treetop (~> 1.4.10) - yajl-ruby (~> 1.1.0) - formatador (0.2.4) - gherkin (2.11.8) - multi_json (~> 1.3) - gssapi (1.0.3) - ffi (>= 1.0.1) - gyoku (1.0.0) - builder (>= 2.1.2) - hashie (2.0.5) - highline (1.6.19) - httpclient (2.2.0.2) - httpi (0.9.7) - rack - i18n (0.6.1) - ipaddress (0.8.0) - json (1.6.1) - kitchen-ec2 (0.5.1) - fog - test-kitchen (~> 1.0.0.alpha.7) - little-plugger (1.1.3) - logging (1.6.2) - little-plugger (>= 1.1.3) - method_source (0.8.1) - mime-types (1.23) - minitar (0.5.4) - mixlib-authentication (1.3.0) - mixlib-log - mixlib-cli (1.3.0) - mixlib-config (1.1.2) - mixlib-log (1.6.0) - mixlib-shellout (1.1.0) - moneta (0.6.0) - multi_json (1.7.7) - multipart-post (1.2.0) - net-http-persistent (2.8) - net-scp (1.0.4) - net-ssh (>= 1.99.1) - net-ssh (2.2.2) - net-ssh-gateway (1.1.0) - net-ssh (>= 1.99.1) - net-ssh-multi (1.1) - net-ssh (>= 2.1.4) - net-ssh-gateway (>= 0.99.0) - nio4r (0.4.6) - nokogiri (1.5.10) - nori (1.1.5) - ohai (6.16.0) - ipaddress - mixlib-cli - mixlib-config - mixlib-log - mixlib-shellout - systemu - yajl-ruby - polyglot (0.3.3) - pry (0.9.12.2) - coderay (~> 1.0.5) - method_source (~> 0.8) - slop (~> 3.4) - rack (1.5.2) - rak (1.4) - rake (10.0.4) - rest-client (1.6.7) - mime-types (>= 1.16) - retryable (1.3.3) - ridley (1.0.2) - addressable - celluloid (~> 0.14.0) - celluloid-io (~> 0.14.0) - chozo (>= 0.6.0) - erubis - faraday (>= 0.8.4) - hashie (>= 2.0.2) - mixlib-authentication (>= 1.3.0) - net-http-persistent (>= 2.8) - net-ssh - retryable - solve (>= 0.4.4) - winrm (~> 1.1.0) - ruby-hmac (0.4.0) - rubyntlm (0.1.1) - safe_yaml (0.9.3) - savon (0.9.5) - akami (~> 1.0) - builder (>= 2.1.2) - gyoku (>= 0.4.0) - httpi (~> 0.9) - nokogiri (>= 1.4.0) - nori (~> 1.0) - wasabi (~> 1.0) - slop (3.4.5) - solve (0.5.0) - systemu (2.5.2) - test-kitchen (1.0.0.alpha.7) - celluloid - mixlib-shellout - net-scp - net-ssh - pry - safe_yaml - thor - thor (0.18.1) - timers (1.1.0) - treetop (1.4.14) - polyglot - polyglot (>= 0.3.1) - uuidtools (2.1.4) - wasabi (1.0.0) - nokogiri (>= 1.4.0) - winrm (1.1.2) - gssapi (~> 1.0.0) - httpclient (~> 2.2.0.2) - logging (~> 1.6.1) - nokogiri (~> 1.5.0) - rubyntlm (~> 0.1.1) - savon (= 0.9.5) - uuidtools (~> 2.1.2) - yajl-ruby (1.1.0) - -PLATFORMS - ruby - -DEPENDENCIES - berkshelf - chef (~> 10.16.4) - foodcritic - kitchen-ec2 - moneta (< 0.7.0) - rake diff --git a/test/support/keys/README.md b/test/support/keys/README.md deleted file mode 100644 index 47c0ccf9..00000000 --- a/test/support/keys/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Insecure Keypair - -These keys are the "insecure" public/private keypair we offer to -[base box creators](http://docs.vagrantup.com/v1/docs/base_boxes.html) for use in their base boxes so that -vagrant installations can automatically SSH into the boxes. - -If you're working with a team or company or with a custom box and -you want more secure SSH, you should create your own keypair -and configure the private key in the Vagrantfile with -`config.ssh.private_key_path` - -# Putty - -If you are using Vagrant on windows, the .ppk file contained here, in the keys directory, -has been generated from the private key and should be used to connect Putty to any VMs that -are leveraging the default key pair. See [guide](http://docs.vagrantup.com/v1/docs/getting-started/ssh.html) -in the documentation for more details on using Putty with Vagrant. diff --git a/test/support/keys/vagrant b/test/support/keys/vagrant deleted file mode 100644 index 7d6a0839..00000000 --- a/test/support/keys/vagrant +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI -w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP -kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2 -hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO -Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW -yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd -ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1 -Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZUvnJUTvzf -TK2Lg6EdbUE9TarUlBf/xPfuEhMSlIE5keb/Zz3/LUlRg8yDqz5w+QWVJ4utnKnK -iqwZN0mwpwU7YSyJhlT4YV1F3n4YjLswM5wJs2oqm0jssQu/BT0tyEXNDYBLEF4A -sClaWuSJ2kjq7KhrrYXzagqhnSei9ODYFShJu8UWVec3Ihb5ZXlzO6vdNQ1J9Xsf -4m+2ywKBgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/orApiHmHDsURs5rUKDx0f9iP -cXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsMkE4CUSiJcYrMANtx54cGH7Rk -EjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTGyAK+OLD3M2QdCQKBgQDtx8pN -CAxR7yhHbIWT1AH66+XWN8bXq7l3RO/ukeaci98JfkbkxURZhtxV/HHuvUhnPLdX -3TwygPBYZFNo4pzVEhzWoTtnEtrFueKxyc3+LjZpuo+mBlQ6ORtfgkr9gBVphXZG -YEzkCD3lVdl8L4cw9BVpKrJCs1c5taGjDgdInQKBgHm/fVvv96bJxc9x1tffXAcj -3OVdUN0UgXNCSaf/3A/phbeBQe9xS+3mpc4r6qvx+iy69mNBeNZ0xOitIjpjBo2+ -dBEjSBwLk5q5tJqHmy/jKMJL4n9ROlx93XS+njxgibTvU6Fp9w+NOFD/HvxB3Tcz -6+jJF85D5BNAG3DBMKBjAoGBAOAxZvgsKN+JuENXsST7F89Tck2iTcQIT8g5rwWC -P9Vt74yboe2kDT531w8+egz7nAmRBKNM751U/95P9t88EDacDI/Z2OwnuFQHCPDF -llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ -kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH -+vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ -NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s= ------END RSA PRIVATE KEY----- diff --git a/test/support/keys/vagrant.pub b/test/support/keys/vagrant.pub deleted file mode 100644 index 18a9c00f..00000000 --- a/test/support/keys/vagrant.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key From 19031bbaf74999ac420bc8558babf0bd1f645550 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Thu, 14 Jun 2018 20:42:51 +0100 Subject: [PATCH 063/300] Add Danger and dokken --- .kitchen.dokken.yml | 7 +++ .kitchen.yml | 68 ++++++++++++++++------- .travis.yml | 114 ++++++++++++++++++++++++++++++++------ Dangerfile | 40 +++++++++++++ Gemfile | 1 - config/license_finder.yml | 12 ---- 6 files changed, 192 insertions(+), 50 deletions(-) create mode 100644 Dangerfile delete mode 100644 Gemfile delete mode 100644 config/license_finder.yml diff --git a/.kitchen.dokken.yml b/.kitchen.dokken.yml index 1b2e6b51..13afc0be 100644 --- a/.kitchen.dokken.yml +++ b/.kitchen.dokken.yml @@ -62,6 +62,13 @@ platforms: intermediate_instructions: - RUN /usr/bin/apt-get update +- name: ubuntu-18.04 + driver: + image: dokken/ubuntu-16.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + - name: opensuse-leap driver: image: dokken/opensuse-leap diff --git a/.kitchen.yml b/.kitchen.yml index 658886b8..ffa59819 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,43 +1,72 @@ -#<% require "kitchen-sync" %> --- driver: - name: docker - require_chef_omnibus: <%= ENV.fetch("CHEF_VERSION", "true") %> - use_sudo: false +name: vagrant provisioner: name: chef_zero + product_name: chef + product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> + install_strategy: once + +client_rb: + treat_deprecation_warnings_as_errors: true platforms: - - name: amazon-2015 - driver_config: - image: ambakshi/amazon-linux - platform: rhel - - name: centos-6.6 - - name: centos-7.1 - - name: debian-7.8 - - name: debian-8.0 - - name: ubuntu-12.04 - - name: ubuntu-14.04 +- name: amazon-linux + driver_config: + box: mvbcoding/awslinux +- name: centos-6 +- name: centos-7 +- name: debian-8 +- name: debian-9 +- name: fedora-27 +- name: freebsd-10 +- name: freebsd-11 +- name: opensuse-leap-42 +- name: ubuntu-16.04 +- name: ubuntu-18.04 suites: - <% %w[5.5 5.6].each do |version| %> - - name: client_<%= version.tr(".", "") %> + - name: client_5.6 attributes: percona: apt: keyserver: hkp://pgp.mit.edu:80 - version: "<%= version %>" + version: "5.6" run_list: - recipe[percona::client] - recipe[percona::toolkit] + - name: client_5.7 + attributes: + percona: + apt: + keyserver: hkp://pgp.mit.edu:80 + version: "5.7" + run_list: + - recipe[percona::client] + - recipe[percona::toolkit] + + - name: server_5.6 + attributes: + percona: + apt: + keyserver: hkp://pgp.mit.edu:80 + version: "5.6" + server: + datadir: /tmp/mysql + debian_password: d3b1an + jemalloc: true + root_password: r00t + run_list: + - recipe[percona::server] + - recipe[percona::backup] - - name: server_<%= version.tr(".", "") %> + - name: server_5.7 attributes: percona: apt: keyserver: hkp://pgp.mit.edu:80 - version: "<%= version %>" + version: "5.7" server: datadir: /tmp/mysql debian_password: d3b1an @@ -46,4 +75,3 @@ suites: run_list: - recipe[percona::server] - recipe[percona::backup] - <% end %> diff --git a/.travis.yml b/.travis.yml index 2c3d5876..d04bd4a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,99 @@ -language: ruby -bundler_args: --jobs 4 --without integration -rvm: - - 2.3.1 -cache: bundler -sudo: false # travis docker container +sudo: required +dist: trusty + +addons: + apt: + sources: + - chef-stable-trusty + packages: + - chefdk + +install: echo "skip bundle install" + +branches: + only: + - master + +services: docker + +stages: + - unit + - test + - danger + +# This list was generated using +# kitchen list | tr -s " " | cut -d ' ' -f 1 | grep -v Instance +# We also add in a source install for a previous chef-client env: - matrix: - - CHEF_VERSION=12.5.0 - - CHEF_VERSION=12.18.31 +- INSTANCE=client-56-amazon-linux +- INSTANCE=client-56-centos-6 +- INSTANCE=client-56-centos-7 +- INSTANCE=client-56-debian-8 +- INSTANCE=client-56-debian-9 +- INSTANCE=client-56-fedora-27 +- INSTANCE=client-56-freebsd-10 +- INSTANCE=client-56-freebsd-11 +- INSTANCE=client-56-opensuse-leap-42 +- INSTANCE=client-56-ubuntu-1404 +- INSTANCE=client-57-amazon-linux +- INSTANCE=client-57-centos-6 +- INSTANCE=client-57-centos-7 +- INSTANCE=client-57-debian-8 +- INSTANCE=client-57-debian-9 +- INSTANCE=client-57-fedora-27 +- INSTANCE=client-57-freebsd-10 +- INSTANCE=client-57-freebsd-11 +- INSTANCE=client-57-opensuse-leap-42 +- INSTANCE=client-57-ubuntu-1604 +- INSTANCE=client-57-ubuntu-1804 +- INSTANCE=server-56-amazon-linux +- INSTANCE=server-56-centos-6 +- INSTANCE=server-56-centos-7 +- INSTANCE=server-56-debian-8 +- INSTANCE=server-56-debian-9 +- INSTANCE=server-56-fedora-27 +- INSTANCE=server-56-freebsd-10 +- INSTANCE=server-56-freebsd-11 +- INSTANCE=server-56-opensuse-leap-42 +- INSTANCE=server-56-ubuntu-1804 +- INSTANCE=server-56-ubuntu-1604 +- INSTANCE=server-57-amazon-linux +- INSTANCE=server-57-centos-6 +- INSTANCE=server-57-centos-7 +- INSTANCE=server-57-debian-8 +- INSTANCE=server-57-debian-9 +- INSTANCE=server-57-fedora-27 +- INSTANCE=server-57-freebsd-10 +- INSTANCE=server-57-freebsd-11 +- INSTANCE=server-57-opensuse-leap-42 +- INSTANCE=server-57-ubuntu-1804 +- INSTANCE=server-57-ubuntu-1604 + before_script: - - "gem install bundler-audit --no-rdoc --no-ri && bundle-audit update" -script: - - bundle-audit check --ignore OSVDB-117461 CVE-2015-1820 - - bundle exec rake license_finder - - bundle exec rake rubocop - - bundle exec rake foodcritic - - bundle exec rake chefspec - - bundle exec rake kitchen:all + - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) + - eval "$(shell-init bash)" + - chef --version + - cookstyle --version + - foodcritic --version + - chef gem install danger + +script: KITCHEN_LOCAL_YAML=.kitchen.dokken.yml /opt/chefdk/bin/kitchen verify ${INSTANCE} + +matrix: + include: + - script: + - chef exec delivery local all + # allow_failures: + # env: + # - INSTANCE=package-ubuntu-1404 + # - INSTANCE=source-ubuntu-1404 + +jobs: + include: + - stage: unit + script: chef exec delivery local all + env: UNIT_AND_LINT=1 + + - stage: danger + script: chef exec danger + env: DANGER diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 00000000..f0443447 --- /dev/null +++ b/Dangerfile @@ -0,0 +1,40 @@ +# Reference: http://danger.systems/reference.html + +# A pull request summary is required. Add a description of the pull request purpose. +# Add labels to the pull request in github to identify the type of change. https://help.github.com/articles/applying-labels-to-issues-and-pull-requests/ +# Changelog must be updated for each pull request. +# Warnings will be issued for: +# Pull request with more than 400 lines of code changed +# Pull reqest that change more than 5 lines without test changes + +def code_changes? + code = %w(libraries attributes recipes resources) + code.each do |location| + return true unless git.modified_files.grep(/#{location}/).empty? + end + false +end + +def test_changes? + tests = %w(spec test .kitchen.yml .kitchen.dokken.yml) + tests.each do |location| + return true unless git.modified_files.grep(/#{location}/).empty? + end + false +end + +raise 'Please provide a summary of your Pull Request.' if github.pr_body.length < 10 + +raise 'Please add labels to this Pull Request' if github.pr_labels.empty? + +warn 'This is a big Pull Request.' if git.lines_of_code > 400 + +# Require a CHANGELOG entry for non-test changes. +if !git.modified_files.include?('CHANGELOG.md') && code_changes? + raise 'Please include a [CHANGELOG](https://github.com/sous-chefs/line-cookbook/blob/master/CHANGELOG.md) entry.' +end + +# A sanity check for tests. +if git.lines_of_code > 5 && code_changes? && !test_changes? + warn 'This Pull Request is probably missing tests.' +end diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 20b4d4ae..00000000 --- a/Gemfile +++ /dev/null @@ -1 +0,0 @@ -source 'https://rubygems.org' diff --git a/config/license_finder.yml b/config/license_finder.yml deleted file mode 100644 index 63102a94..00000000 --- a/config/license_finder.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -whitelist: -- Apache 2.0 -- Apache v2 -- BSD -- BSD-3 -- GPLv3 -- ISC -- MIT -- Ruby -dependencies_file_dir: doc/license_finder -project_name: chef-percona From 6629e3dec269bf5a4d5fe78751fbef1ec7f40416 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Thu, 14 Jun 2018 20:45:21 +0100 Subject: [PATCH 064/300] Stop depping on things in core Resolves 368 --- metadata.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/metadata.rb b/metadata.rb index a3e95357..1c33ce0b 100644 --- a/metadata.rb +++ b/metadata.rb @@ -8,10 +8,8 @@ issues_url 'https://github.com/phlipper/chef-percona/issues' version '0.16.4' -depends 'apt', '>= 2.7.0' depends 'build-essential' depends 'openssl' -depends 'yum', '~> 3.0' depends 'yum-epel' depends 'chef-vault' From 66db422c0712b01c20edd590f9e134bddaa9fa24 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Thu, 14 Jun 2018 20:48:54 +0100 Subject: [PATCH 065/300] https all the URLs Resolves #360 --- attributes/package_repo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attributes/package_repo.rb b/attributes/package_repo.rb index ef5d3fcc..a5297de6 100644 --- a/attributes/package_repo.rb +++ b/attributes/package_repo.rb @@ -17,6 +17,6 @@ default['percona']['yum']['description'] = 'Percona Packages' default['percona']['yum']['baseurl'] = "http://repo.percona.com/centos/#{pversion}/os/#{arch}/" -default['percona']['yum']['gpgkey'] = 'http://www.percona.com/downloads/RPM-GPG-KEY-percona' +default['percona']['yum']['gpgkey'] = 'https://www.percona.com/downloads/RPM-GPG-KEY-percona' default['percona']['yum']['gpgcheck'] = true default['percona']['yum']['sslverify'] = true From 97a0ecb902bd930fd14251ce479030abd596d595 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Thu, 14 Jun 2018 20:59:54 +0100 Subject: [PATCH 066/300] Use 5.7 not a minor version --- templates/my.cnf.cluster.erb | 2 +- templates/my.cnf.main.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/my.cnf.cluster.erb b/templates/my.cnf.cluster.erb index bcfe7485..9ea5db7e 100644 --- a/templates/my.cnf.cluster.erb +++ b/templates/my.cnf.cluster.erb @@ -476,7 +476,7 @@ myisam_max_sort_file_size = <%= node["percona"]["server"]["myisam_max_sort_file_ # have multiple CPUs and plenty of memory. myisam_repair_threads = <%= node["percona"]["server"]["myisam_repair_threads"] %> -<%- if node["percona"]["version"] < "5.7.4" %> +<%- if node["percona"]["version"] < "5.7" %> # Automatically check and repair not properly closed MyISAM tables. <% if node["percona"]["server"]["myisam_recover_options"] %> myisam_recover diff --git a/templates/my.cnf.main.erb b/templates/my.cnf.main.erb index fd0cab66..511b6672 100644 --- a/templates/my.cnf.main.erb +++ b/templates/my.cnf.main.erb @@ -496,7 +496,7 @@ myisam_max_sort_file_size = <%= node["percona"]["server"]["myisam_max_sort_file_ # have multiple CPUs and plenty of memory. myisam_repair_threads = <%= node["percona"]["server"]["myisam_repair_threads"] %> -<%- if node["percona"]["version"] < "5.7.4" %> +<%- if node["percona"]["version"] < "5.7" %> # Automatically check and repair not properly closed MyISAM tables. <% if node["percona"]["server"]["myisam_recover_options"] %> myisam_recover From 764e56974bd7a2fbec6457da63734e5b6498db24 Mon Sep 17 00:00:00 2001 From: jerrypeng0112 Date: Wed, 1 Aug 2018 13:13:20 -0700 Subject: [PATCH 067/300] Change from node.set to node.default --- recipes/backup.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/backup.rb b/recipes/backup.rb index cdbf721d..6f2bee6a 100644 --- a/recipes/backup.rb +++ b/recipes/backup.rb @@ -3,7 +3,7 @@ # Recipe:: backup # -node.set['percona']['backup']['configure'] = true +node.default['percona']['backup']['configure'] = true include_recipe 'percona::package_repo' From 19560910de99ad6b8ac58779f92af345db13cb06 Mon Sep 17 00:00:00 2001 From: John Roesler Date: Wed, 12 Dec 2018 14:39:19 -0600 Subject: [PATCH 068/300] Add/update codeowners to use github teams --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..cae16bfa --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* sous-chefs/percona From 2aa3661cb872eda9cef565fe494ca3ca34bc513d Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Thu, 31 Jan 2019 12:27:16 +0000 Subject: [PATCH 069/300] Remove .travis.yml and rename kitchen files (#388) --- .travis.yml | 99 ----------------------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d04bd4a5..00000000 --- a/.travis.yml +++ /dev/null @@ -1,99 +0,0 @@ -sudo: required -dist: trusty - -addons: - apt: - sources: - - chef-stable-trusty - packages: - - chefdk - -install: echo "skip bundle install" - -branches: - only: - - master - -services: docker - -stages: - - unit - - test - - danger - -# This list was generated using -# kitchen list | tr -s " " | cut -d ' ' -f 1 | grep -v Instance -# We also add in a source install for a previous chef-client -env: -- INSTANCE=client-56-amazon-linux -- INSTANCE=client-56-centos-6 -- INSTANCE=client-56-centos-7 -- INSTANCE=client-56-debian-8 -- INSTANCE=client-56-debian-9 -- INSTANCE=client-56-fedora-27 -- INSTANCE=client-56-freebsd-10 -- INSTANCE=client-56-freebsd-11 -- INSTANCE=client-56-opensuse-leap-42 -- INSTANCE=client-56-ubuntu-1404 -- INSTANCE=client-57-amazon-linux -- INSTANCE=client-57-centos-6 -- INSTANCE=client-57-centos-7 -- INSTANCE=client-57-debian-8 -- INSTANCE=client-57-debian-9 -- INSTANCE=client-57-fedora-27 -- INSTANCE=client-57-freebsd-10 -- INSTANCE=client-57-freebsd-11 -- INSTANCE=client-57-opensuse-leap-42 -- INSTANCE=client-57-ubuntu-1604 -- INSTANCE=client-57-ubuntu-1804 -- INSTANCE=server-56-amazon-linux -- INSTANCE=server-56-centos-6 -- INSTANCE=server-56-centos-7 -- INSTANCE=server-56-debian-8 -- INSTANCE=server-56-debian-9 -- INSTANCE=server-56-fedora-27 -- INSTANCE=server-56-freebsd-10 -- INSTANCE=server-56-freebsd-11 -- INSTANCE=server-56-opensuse-leap-42 -- INSTANCE=server-56-ubuntu-1804 -- INSTANCE=server-56-ubuntu-1604 -- INSTANCE=server-57-amazon-linux -- INSTANCE=server-57-centos-6 -- INSTANCE=server-57-centos-7 -- INSTANCE=server-57-debian-8 -- INSTANCE=server-57-debian-9 -- INSTANCE=server-57-fedora-27 -- INSTANCE=server-57-freebsd-10 -- INSTANCE=server-57-freebsd-11 -- INSTANCE=server-57-opensuse-leap-42 -- INSTANCE=server-57-ubuntu-1804 -- INSTANCE=server-57-ubuntu-1604 - -before_script: - - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - - eval "$(shell-init bash)" - - chef --version - - cookstyle --version - - foodcritic --version - - chef gem install danger - -script: KITCHEN_LOCAL_YAML=.kitchen.dokken.yml /opt/chefdk/bin/kitchen verify ${INSTANCE} - -matrix: - include: - - script: - - chef exec delivery local all - # allow_failures: - # env: - # - INSTANCE=package-ubuntu-1404 - # - INSTANCE=source-ubuntu-1404 - -jobs: - include: - - stage: unit - script: chef exec delivery local all - env: UNIT_AND_LINT=1 - - - stage: danger - script: chef exec danger - env: DANGER From 49a3ccaf469d2d4f4e5a528ff1a45938748f8e1b Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Thu, 21 Feb 2019 12:28:28 +0000 Subject: [PATCH 070/300] Update kitchen and dokken configs --- .kitchen.dokken.yml | 116 ++++++++++++++++++-------------------------- .kitchen.yml | 40 +++++++-------- Dangerfile | 11 ----- 3 files changed, 67 insertions(+), 100 deletions(-) diff --git a/.kitchen.dokken.yml b/.kitchen.dokken.yml index 13afc0be..9fe575f9 100644 --- a/.kitchen.dokken.yml +++ b/.kitchen.dokken.yml @@ -1,80 +1,56 @@ +--- driver: name: dokken - privileged: true # because Docker and SystemD/Upstart + # because Docker and SystemD/Upstart + privileged: true + chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> transport: name: dokken provisioner: name: dokken - product_name: chef - product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> - install_strategy: once platforms: -- name: debian-8 - driver: - image: dokken/debian-8 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - -- name: debian-9 - driver: - image: dokken/debian-9 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - -- name: centos-6 - driver: - image: dokken/centos-6 - platform: rhel - pid_one_command: /sbin/init - -- name: centos-7 - driver: - image: dokken/centos-7 - platform: rhel - pid_one_command: /usr/lib/systemd/systemd - -- name: fedora-26 - driver: - image: dokken/fedora-26 - pid_one_command: /usr/lib/systemd/systemd - -- name: fedora-27 - driver: - image: dokken/fedora-27 - pid_one_command: /usr/lib/systemd/systemd - -- name: ubuntu-14.04 - driver: - image: dokken/ubuntu-14.04 - pid_one_command: /sbin/init - intermediate_instructions: - - RUN /usr/bin/apt-get update - -- name: ubuntu-16.04 - driver: - image: dokken/ubuntu-16.04 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - -- name: ubuntu-18.04 - driver: - image: dokken/ubuntu-16.04 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - -- name: opensuse-leap - driver: - image: dokken/opensuse-leap - pid_one_command: /bin/systemd - -- name: amazonlinux - driver: - image: dokken/amazonlinux - pid_one_command: /sbin/init + - name: amazonlinux-2 + driver: + image: dokken/amazonlinux-2 + pid_one_command: /usr/lib/systemd/systemd + + - name: debian-8 + driver: + image: dokken/debian-8 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + + - name: debian-9 + driver: + image: dokken/debian-9 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + + - name: centos-7 + driver: + image: dokken/centos-7 + pid_one_command: /usr/lib/systemd/systemd + + - name: ubuntu-16.04 + driver: + image: dokken/ubuntu-16.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + + - name: ubuntu-18.04 + driver: + image: dokken/ubuntu-18.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + + - name: opensuse-leap-15 + driver: + image: dokken/opensuse-leap-15 + pid_one_command: /bin/systemd diff --git a/.kitchen.yml b/.kitchen.yml index ffa59819..bb04291a 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,30 +1,32 @@ --- driver: -name: vagrant + name: vagrant provisioner: - name: chef_zero + name: chef_solo product_name: chef - product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> - install_strategy: once + enforce_idempotency: true + multiple_converge: 2 + solo_rb: + treat_deprecation_warnings_as_errors: true -client_rb: - treat_deprecation_warnings_as_errors: true +verifier: + name: inspec platforms: -- name: amazon-linux - driver_config: - box: mvbcoding/awslinux -- name: centos-6 -- name: centos-7 -- name: debian-8 -- name: debian-9 -- name: fedora-27 -- name: freebsd-10 -- name: freebsd-11 -- name: opensuse-leap-42 -- name: ubuntu-16.04 -- name: ubuntu-18.04 + - name: amazonlinux-2 + driver_config: + box: ywatase/amzn2 + - name: amazon-linux + driver_config: + box: mvbcoding/awslinux + - name: centos-6 + - name: centos-7 + - name: debian-8 + - name: debian-9 + - name: opensuse-leap-15 + - name: ubuntu-16.04 + - name: ubuntu-18.04 suites: - name: client_5.6 diff --git a/Dangerfile b/Dangerfile index f0443447..6f0fa5b5 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,12 +1,3 @@ -# Reference: http://danger.systems/reference.html - -# A pull request summary is required. Add a description of the pull request purpose. -# Add labels to the pull request in github to identify the type of change. https://help.github.com/articles/applying-labels-to-issues-and-pull-requests/ -# Changelog must be updated for each pull request. -# Warnings will be issued for: -# Pull request with more than 400 lines of code changed -# Pull reqest that change more than 5 lines without test changes - def code_changes? code = %w(libraries attributes recipes resources) code.each do |location| @@ -25,8 +16,6 @@ end raise 'Please provide a summary of your Pull Request.' if github.pr_body.length < 10 -raise 'Please add labels to this Pull Request' if github.pr_labels.empty? - warn 'This is a big Pull Request.' if git.lines_of_code > 400 # Require a CHANGELOG entry for non-test changes. From 471e37ee5b60ce36b064ae7b0dc74f97a989fa13 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Thu, 21 Feb 2019 13:56:11 +0000 Subject: [PATCH 071/300] Add circleci (#391) * Add lint for yaml and markdown * Yaml and markdown linting - Remove changelog entries from README * Change licence add foodcritic exceptions * Fix Dangerfile * Remove outdated File.exist * Ignore dangerfile * Remove some node.sets * Remove some spaces * Simplify the test cookbook patterns Use the test cookbook paattern so copying is easier for users * Remove all broken Specs, fix easy to fix spec --- .circleci/config.yml | 24 + .envrc | 1 + .foodcritic | 4 + .github/lock.yml | 22 +- .kitchen.yml | 44 +- .mdlrc | 1 + .rubocop.yml | 4 + Dangerfile | 4 +- LICENSE | 201 +++++++ LICENSE.txt | 20 - README.md | 392 +++++-------- doc/dependency_decisions.yml | 51 -- metadata.rb | 3 +- recipes/cluster.rb | 2 +- recipes/package_repo.rb | 4 - recipes/replication.rb | 2 +- spec/access_grants_spec.rb | 70 +-- spec/backup_spec.rb | 40 +- spec/client_spec.rb | 114 ++-- spec/cluster_spec.rb | 230 ++++---- spec/configure_server_spec.rb | 554 +++++++++--------- spec/default_spec.rb | 6 +- spec/monitoring_spec.rb | 11 - spec/package_repo_spec.rb | 28 - spec/replication_spec.rb | 106 ++-- spec/server_spec.rb | 202 +++---- spec/spec_helper.rb | 13 +- spec/ssl_spec.rb | 120 ++-- spec/toolkit_spec.rb | 76 +-- test/fixtures/cookbooks/test/metadata.rb | 8 + .../cookbooks/test/recipes/client-56.rb | 5 + .../cookbooks/test/recipes/client-57.rb | 5 + .../cookbooks/test/recipes/server-56.rb | 9 + .../cookbooks/test/recipes/server-57.rb | 9 + 34 files changed, 1177 insertions(+), 1208 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 .envrc create mode 100644 .foodcritic create mode 100644 .mdlrc create mode 100644 .rubocop.yml create mode 100644 LICENSE delete mode 100644 LICENSE.txt delete mode 100644 doc/dependency_decisions.yml delete mode 100644 spec/monitoring_spec.rb delete mode 100644 spec/package_repo_spec.rb create mode 100644 test/fixtures/cookbooks/test/metadata.rb create mode 100644 test/fixtures/cookbooks/test/recipes/client-56.rb create mode 100644 test/fixtures/cookbooks/test/recipes/client-57.rb create mode 100644 test/fixtures/cookbooks/test/recipes/server-56.rb create mode 100644 test/fixtures/cookbooks/test/recipes/server-57.rb diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..71cf475e --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,24 @@ +--- +lint_and_unit: &lint_and_unit + - delivery + - danger + - lint-yaml + - lint-markdown + +version: 2.1 +orbs: + kitchen: sous-chefs/kitchen@1.0.3 + +workflows: + kitchen: + jobs: + # Lint and Unit Test + - kitchen/yamllint: + name: lint-yaml + - kitchen/mdlint: + name: lint-markdown + - kitchen/danger: + name: danger + context: Danger + - kitchen/delivery: + name: delivery diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..6ed589ea --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use chefworkstation diff --git a/.foodcritic b/.foodcritic new file mode 100644 index 00000000..b6300571 --- /dev/null +++ b/.foodcritic @@ -0,0 +1,4 @@ +~FC113 +~FC075 +~FC082 +~FC086 diff --git a/.github/lock.yml b/.github/lock.yml index 97037158..8344a7b3 100644 --- a/.github/lock.yml +++ b/.github/lock.yml @@ -1,28 +1,8 @@ -# Configuration for lock-threads - https://github.com/dessant/lock-threads - -# Number of days of inactivity before a closed issue or pull request is locked +--- daysUntilLock: 365 - -# Issues and pull requests with these labels will not be locked. Set to `[]` to disable exemptLabels: [] - -# Label to add before locking, such as `outdated`. Set to `false` to disable lockLabel: false - -# Comment to post before locking. Set to `false` to disable lockComment: > This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. - -# Limit to only `issues` or `pulls` -# only: issues - -# Optionally, specify configuration settings just for `issues` or `pulls` -# issues: -# exemptLabels: -# - help-wanted -# lockLabel: outdated - -# pulls: -# daysUntilLock: 30 diff --git a/.kitchen.yml b/.kitchen.yml index bb04291a..112bc116 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -30,50 +30,14 @@ platforms: suites: - name: client_5.6 - attributes: - percona: - apt: - keyserver: hkp://pgp.mit.edu:80 - version: "5.6" run_list: - - recipe[percona::client] - - recipe[percona::toolkit] + - recipe[test::client-56] - name: client_5.7 - attributes: - percona: - apt: - keyserver: hkp://pgp.mit.edu:80 - version: "5.7" run_list: - - recipe[percona::client] - - recipe[percona::toolkit] - + - recipe[test:client57 - name: server_5.6 - attributes: - percona: - apt: - keyserver: hkp://pgp.mit.edu:80 - version: "5.6" - server: - datadir: /tmp/mysql - debian_password: d3b1an - jemalloc: true - root_password: r00t run_list: - - recipe[percona::server] - - recipe[percona::backup] - + - recipe[test::server-56] - name: server_5.7 - attributes: - percona: - apt: - keyserver: hkp://pgp.mit.edu:80 - version: "5.7" - server: - datadir: /tmp/mysql - debian_password: d3b1an - jemalloc: true - root_password: r00t run_list: - - recipe[percona::server] - - recipe[percona::backup] + - recipe[test::server-57] diff --git a/.mdlrc b/.mdlrc new file mode 100644 index 00000000..b7e08259 --- /dev/null +++ b/.mdlrc @@ -0,0 +1 @@ +rules "~MD013" diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..d88ffa9f --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,4 @@ +--- +AllCops: + Exclude: + - 'Dangerfile' diff --git a/Dangerfile b/Dangerfile index 6f0fa5b5..f15a26a9 100644 --- a/Dangerfile +++ b/Dangerfile @@ -14,13 +14,13 @@ def test_changes? false end -raise 'Please provide a summary of your Pull Request.' if github.pr_body.length < 10 +fail 'Please provide a summary of your Pull Request.' if github.pr_body.length < 10 warn 'This is a big Pull Request.' if git.lines_of_code > 400 # Require a CHANGELOG entry for non-test changes. if !git.modified_files.include?('CHANGELOG.md') && code_changes? - raise 'Please include a [CHANGELOG](https://github.com/sous-chefs/line-cookbook/blob/master/CHANGELOG.md) entry.' + fail 'Please include a [CHANGELOG](https://github.com/sous-chefs/line-cookbook/blob/master/CHANGELOG.md) entry.' end # A sanity check for tests. diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..8dada3ed --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index b3d06e01..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) -Copyright (c) 2012-2015 Phil Cohen - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the “Software”), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/README.md b/README.md index 0a542219..0004c089 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,8 @@ -# chef-percona - -## Flair +# Percona Cookbook [![Cookbook Version](https://img.shields.io/cookbook/v/percona.svg)](https://supermarket.chef.io/cookbooks/percona) -[![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://phlipper.mit-license.org/2012-2015/license.html) -[![Build Status](http://img.shields.io/travis-ci/phlipper/chef-percona.png)](https://travis-ci.org/phlipper/chef-percona) -[![Code Climate](https://codeclimate.com/github/phlipper/chef-percona.png)](https://codeclimate.com/github/phlipper/chef-percona) -[![Gitter](https://img.shields.io/badge/Gitter%2Eim-Join_Chat_→-yellow.svg)](https://gitter.im/phlipper/chef-percona) -![It Works On My Machine™](https://img.shields.io/badge/It_Works-On_My_Machine%E2%84%A2-orange.svg) -[![Tip](http://img.shields.io/gratipay/phlipper.png)](https://gratipay.com/phlipper/) -[![Endorse](http://api.coderwall.com/phlipper/endorsecount.png)](http://coderwall.com/phlipper) +[![Build Status](https://img.shields.io/circleci/project/github/sous-chefs/percona/master.svg)](https://circleci.com/gh/sous-chefs/percona) +[![pullreminders](https://pullreminders.com/badge.svg)](https://pullreminders.com?ref=badge) ## Description @@ -20,12 +13,10 @@ MySQL cookbook as much as possible.) Optionally installs: -* [XtraBackup](http://www.percona.com/software/percona-xtrabackup/) hot backup software -* [Percona Toolkit](http://www.percona.com/software/percona-toolkit/) advanced command-line tools -* [XtraDB -Cluster](http://www.percona.com/software/percona-xtradb-cluster/) high -availability and high scalability solution for MySQL. -* [Percona Monitoring Plugins](http://www.percona.com/software/percona-monitoring-plugins) various Nagios plugins for monitoring MySQL +- [XtraBackup](http://www.percona.com/software/percona-xtrabackup/) hot backup software +- [Percona Toolkit](http://www.percona.com/software/percona-toolkit/) advanced command-line tools +- [XtraDB Cluster](http://www.percona.com/software/percona-xtradb-cluster/) high availability and high scalability solution for MySQL. +- [Percona Monitoring Plugins](http://www.percona.com/software/percona-monitoring-plugins) various Nagios plugins for monitoring MySQL ## Requirements @@ -33,31 +24,31 @@ availability and high scalability solution for MySQL. We provide an expanding set of tests against the following 64-bit platforms: -* Amazon 2014.03 -* CentOS 6.5 -* CentOS 7.0 -* Debian 7.8 -* Ubuntu 12.04 LTS -* Ubuntu 14.04 LTS +- Amazon 2014.03 +- CentOS 6.5 +- CentOS 7.0 +- Debian 7.8 +- Ubuntu 12.04 LTS +- Ubuntu 14.04 LTS Although we don't test against all possible platform verions, we expect the following to be supported. Please submit an issue if this is not the cause, and we'll make reasonable efforts to improve support: -* Ubuntu -* Debian -* Amazon Linux AMI -* CentOS -* Red Hat -* Scientific -* Fedora +- Ubuntu +- Debian +- Amazon Linux AMI +- CentOS +- Red Hat +- Scientific +- Fedora ### Cookbooks -* [apt](https://supermarket.getchef.com/cookbooks/apt) Chef LWRP Cookbook -* [openssl](https://supermarket.getchef.com/cookbooks/openssl) Chef Cookbook -* [yum](https://supermarket.getchef.com/cookbooks/yum) Chef LWRP Cookbook -* [yum-epel](https://supermarket.getchef.com/cookbooks/yum-epel) Chef LWRP Cookbook +- [apt](https://supermarket.getchef.com/cookbooks/apt) Chef LWRP Cookbook +- [openssl](https://supermarket.getchef.com/cookbooks/openssl) Chef Cookbook +- [yum](https://supermarket.getchef.com/cookbooks/yum) Chef LWRP Cookbook +- [yum-epel](https://supermarket.getchef.com/cookbooks/yum-epel) Chef LWRP Cookbook ### Chef @@ -67,20 +58,19 @@ We aim to test the most recent releases of Chef. You can view the [currently tested versions](https://github.com/phlipper/chef-percona/blob/master/.travis.yml). (Feel free to submit a pull request if they're out of date!) - ## Recipes -* `percona` - The default no-op recipe. -* `percona::package_repo` - Sets up the package repository and installs common packages. -* `percona::client` - Installs the Percona MySQL client libraries. -* `percona::server` - Installs and configures the Percona MySQL server daemon. -* `percona::backup` - Installs and configures the Percona XtraBackup hot backup software. -* `percona::toolkit` - Installs the Percona Toolkit software -* `percona::cluster` - Installs the Percona XtraDB Cluster server components -* `percona::configure_server` - Used internally to manage the server configuration. -* `percona::replication` - Used internally to grant permissions for replication. -* `percona::access_grants` - Used internally to grant permissions for recipes. -* `percona::monitoring` - Installs Percona monitoring plugins for Nagios +- `percona` - The default no-op recipe. +- `percona::package_repo` - Sets up the package repository and installs common packages. +- `percona::client` - Installs the Percona MySQL client libraries. +- `percona::server` - Installs and configures the Percona MySQL server daemon. +- `percona::backup` - Installs and configures the Percona XtraBackup hot backup software. +- `percona::toolkit` - Installs the Percona Toolkit software +- `percona::cluster` - Installs the Percona XtraDB Cluster server components +- `percona::configure_server` - Used internally to manage the server configuration. +- `percona::replication` - Used internally to grant permissions for replication. +- `percona::access_grants` - Used internally to grant permissions for recipes. +- `percona::monitoring` - Installs Percona monitoring plugins for Nagios ## Usage @@ -97,6 +87,7 @@ This cookbook expects a `mysql` item and a `system` item. Please refer to the o You also may set expected item names via attributes `node["percona"]["encrypted_data_bag_item_mysql"]` and `node["percona"]["encrypted_data_bag_item_system"]`. ### Skip passwords + Set the `["percona"]["skip_passwords"]` attribute to skip setting up passwords. Removes the need for the encrypted data bag if using chef-solo. Is useful for setting up development and ci environments where you just want to use the root user with no password. If you are doing this you may want to set `[:percona][:server][:debian_username]` to be `"root"` also. ### Skip Configure @@ -131,6 +122,7 @@ Example: "passwords" data bag - this example assumes that `node[:percona][:serve Above shows the encrypted password in the data bag. Check out the `encrypted_data_bag_secret` setting in `knife.rb` to setup your data bag secret during bootstrapping. ### Replication over SSL + To enable SSL based replication, you will need to flip the attribute `node[:percona][:server][:replication][:ssl_enabled]` to `true` and add a new data_bag item to the percona encrypted data_bag (see`node[:percona][:encrypted_data_bag]` attribute) with the id `ssl_replication` ( see `node["percona"]["encrypted_data_bag_item_ssl_replication"]` attribute) that contains this data: @@ -148,6 +140,7 @@ to the percona encrypted data_bag (see`node[:percona][:encrypted_data_bag]` attr } } ``` + All certificates and keys have to be converted to a string (easiest way is to use ruby: */usr/bin/env ruby -e 'p ARGF.read'* **filename**) and placed instead of CA_CERTIFICATE_STRING, SERVER_CERTIFICATE_STRING, SERVER_KEY_STRING, CLIENT_CERTIFICATE_STRING, CLIENT_KEY_STRING. @@ -488,7 +481,7 @@ default["percona"]["yum"]["sslverify"] = true In some situation it is preferable to explicitly define the attributes needed in a `my.cnf` file. This is enabled by adding categories to the `node[:percona][:conf]` attributes. All keys found in the `node[:percona][:conf]` map will represent categories in the `my.cnf` file. Each category contains a map of attributes that will be written to the `my.cnf` file for that category. See the example for more details. -### Example: +### Example ```ruby node["percona"]["conf"]["mysqld"]["slow_query_log_file"] = "/var/lib/mysql/data/mysql-slow.log" @@ -496,7 +489,7 @@ node["percona"]["conf"]["mysqld"]["slow_query_log_file"] = "/var/lib/mysql/data/ This configuration would write the `mysqld` category to the `my.cnf` file and have an attribute `slow_query_log_file` whose value would be `/var/lib/mysql/data/mysql-slow.log`. -### Example output (my.cnf): +### Example output (my.cnf) ```ini [mysqld] @@ -533,230 +526,111 @@ depends to ensure they pull in the needed resource files. In no particular order: -* Be the most flexible way to setup a MySQL distribution through Chef - * Support for Chef Solo - * Support for Chef Server -* Support the following common database infrastructures: - * Single server instance - * Traditional Master/Slave replication - * Multi-master cluster replication -* Support the most recent Chef runtime environments -* Be the easiest way to setup a MySQL distribution through Chef - +- Be the most flexible way to setup a MySQL distribution through Chef + - Support for Chef Solo + - Support for Chef Server +- Support the following common database infrastructures: + - Single server instance + - Traditional Master/Slave replication + - Multi-master cluster replication +- Support the most recent Chef runtime environments +- Be the easiest way to setup a MySQL distribution through Chef ## TODO -* Fully support all of the standard Chef-supported distributions - +- Fully support all of the standard Chef-supported distributions ## Contributing -1. Fork it -2. Create your feature branch (`git checkout -b my-new-feature`) -3. Commit your changes (`git commit -am 'Added some feature'`) -4. Push to the branch (`git push origin my-new-feature`) -5. Create new Pull Request +- Fork it +- Create your feature branch (`git checkout -b my-new-feature`) +- Commit your changes (`git commit -am 'Added some feature'`) +- Push to the branch (`git push origin my-new-feature`) +- Create new Pull Request ## Contributors Many thanks go to the following [contributors](https://github.com/phlipper/chef-percona/graphs/contributors) who have helped to make this cookbook even better: -* **[@jagcrete](https://github.com/jagcrete)** - * configurable keyserver - * encrypted password data bag - * custom `my.cnf` file -* **[@pwelch](https://github.com/pwelch)** - * ensure cookbook dependencies are loaded - * [Foodcritic](http://acrmp.github.com/foodcritic/) compliance updates - * various minor patches and updates -* **[@masv](https://github.com/masv)** - * compatibility updates for 5.5 -* **[@stottsan](https://github.com/stottsan)** - * config cleanup to prevent service restarts on chef run -* **[@abecciu](https://github.com/abecciu)** - * auto-generate secure passwords by default - * add ability to dynamically set the bind address - * add support for `main_config_file` attribute -* **[@patcon](https://github.com/patcon)** - * add `yum` support for `centos`, `amazon`, `scientific`, `fedora`, and `redhat` distributions -* **[@psi](https://github.com/psi)** - * fixes required for RedHat platforms -* **[@TheSerapher](https://github.com/TheSerapher)** - * improvements for master/slave replication setup - * updates and clarifications to the README - * add attribute to control server restart on config changes -* **[@bensomers](https://github.com/bensomers)** - * minor fixes to `replication.sql` - * fix a very dangerous bug around binlog-do-db setting for slave servers - * fix slow query log setting for 5.5 -* **[@tdg5](https://github.com/tdg5)** - * avoid use of `set_unless` for chef-solo, workaround for CHEF-2945 -* **[@gpendler](https://github.com/gpendler)** - * avoid re-installation of packages RedHat platforms -* **[@vinu](https://github.com/vinu)** - * pin the percona apt repo with high priority -* **[@ckuttruff](https://github.com/ckuttruff)** - * improve security on debian-based systems by changing config file permissions - * don't pass mysql root password in plaintext commands - * fix issue with -p flag when setting initial password -* **[@srodrig0209](https://github.com/srodrig0209)** - * add the `monitoring` recipe -* **[@jesseadams](https://github.com/jesseadams)** - * fixes for custom datadir setting use case - * add more Percona XtraDB cluster options - * XtraDB cluster support for replication over ssl -* **[@see0](https://github.com/see0)** - * fix incorrect root password reference -* **[@baldur](https://github.com/baldur)** - * _(honorable mention)_ fix incorrect root password reference - * fix typo in attribute for server username -* **[@chrisroberts](https://github.com/chrisroberts)** - * _(honorable mention)_ fix issue with -p flag when setting initial password -* **[@aaronjensen](https://github.com/aaronjensen)** - * allow server to not be started on startup -* **[@pioneerit](https://github.com/pioneerit)** - * add sections to `.my.cnf` for `mysqladmin` and `mysqldump` -* **[@AndreyChernyh](https://github.com/AndreyChernyh)** - * use resources helper to support newer chef versions -* **[@avit](https://github.com/avit)** - * add default utf8 character set option - * cleanup replication support - * remove dependency on opscode/mysql cookbook - * fix permissions for configuration files -* **[@alexzorin](https://github.com/alexzorin)** - * add support for `skip-name-resolve` option -* **[@jyotty](https://github.com/jyotty)** - * specify `binlog_format` in master and slave roles -* **[@adamdunkley](https://github.com/adamdunkley)** - * fix `table_cache` variable for mysql versions 5.6 and above - * remove unnecessary rewind, perform it directly -* **[@freerobby](https://github.com/freerobby)** - * add requirements to `Berksfile` - * more flexible apt dependency version to minimize conflicts -* **[@spovich](https://github.com/spovich)** - * disable `old_passwords` support by default - * force version 5.5 on Debian family to maintain consistency with RHEL family -* **[@v1nc3ntlaw](https://github.com/v1nc3ntlaw)** - * add attribute `innodb_file_format` - * add attribute `ignore_db` for slave template -* **[@joegaudet](https://github.com/joegaudet)** - * add attribute `group_concat_max_len` -* **[@mikesmullin](https://github.com/mikesmullin)** - * accumulating patches from multiple sources - * tempdir fixes -* **[@totally](https://github.com/totally)** - * support `yum` cookbook v3.0 - * use attributes for package names -* **[@sapunoff](https://github.com/sapunoff)** - * initial implementation of using attributes for package names -* **[@errm](https://github.com/errm)** - * add attribute `skip_passwords` -* **[@ewr](https://github.com/ewr)** - * fix mysql calls when there is no root password -* **[@jharley](https://github.com/jharley)** - * make `connect_timeout` configurable - * add cluster support for `wsrep_sst_auth` configuration - * update default for `wsrep_provider` on Debian - * enable InnoDB tuning for standalone and cluster - * set proper `my.cnf` location based on platform family - * add missing tunables to 'cluster' `my.cnf` template - * fix regression in cluster configuration template - * centralize `jemalloc` configuration for cluster and server configurations - * sync cluster configuration file with main configuration - * add `innodb_autoextend_increment` and `innodb_open_files` attributes - * fix cluster template regression -* **[@achied](https://github.com/achied)** - * fix setting passwords if attribute not defined -* **[@akshah123](https://github.com/akshah123)** - * force client packages to install version 5.5 -* **[@tkuhlman](https://github.com/tkuhlman)** - * re-add cluster support -* **[@mancdaz](https://github.com/mancdaz)** - * install monitoring plugins from package instead of tarball -* **[@iancoffey](https://github.com/iancoffey)** - * set debian-sys-maint password after grant - * add attribute `skip_configure` -* **[@notnmeyer](https://github.com/notnmeyer)** - * fix `access_grants` guards for `cluster` and `backup` recipes -* **[@odacrem](https://github.com/odacrem)** - * use correct replication username in `replication.sql` -* **[@g3kk0](https://github.com/g3kk0)** - * fix missing mysql log directory - * add attribute `wait_timeout` - * data-drive percona yum repository - * add support for `jemalloc` - * fix idempotency with chef-solo and `skip_password` attribute - * add attribute `expand_fast_index_creation` -* **[@gfloyd](https://github.com/gfloyd)** - * honor `skip_configure` attribute in cluster recipe -* **[@paustin01](https://github.com/paustin01)** - * add `encrypted_data_bag_secret_file` attribute -* **[@ajardan](https://github.com/ajardan)** - * support master-master replication in the `replication_master.sql` template - * extend master-master capabilities and add ssl support -* **[@realloc](https://github.com/realloc)** - * add `mysql2` gem provider - * add ability to set data bag item names using attributes -* **[@tbunnyman](https://github.com/tbunnyman)** - * make `ignore_db` attribute into an array & add matching `ignore_table` attribute - * add `suppress_1592` replication attribute - * add `sql_modes` attribute -* **[@mzdrale](https://github.com/mzdrale)** - * fix cluster package name on RHEL systems -* **[@Sauraus](https://github.com/Sauraus)** - * fix cluster dependency package installation on RHEL systems - * fix `slow_query_logdir` path creation -* **[@jim80net](https://github.com/jim80net)** - * fix toolkit installation for version 5.6 on RHEL systems -* **[@helgi](https://github.com/helgi)** - * use `mysql` command vs. a file to check the root password - * generate configuration file before setting up data directory - * ensure `includedir` is created if provided - * add attribute `performance_schema` - * fix mysql root password update check -* **[@arnesund](https://github.com/arnesund)** - * fix package list for clusters based on CentOS - * avoid uninstall of `mysql-libs` when not needed - * fix XtraDB Cluster 5.6 installation on CentOS 7 - * add support for `chef-vault` -* **[@n3bulous](https://github.com/n3bulous)** - * add `federated` and `read_rnd_buffer_size` attributes -* **[@runwaldarshu](https://github.com/runwaldarshu)** - * add `sensitive` attribute for resources -* **[@vermut](https://github.com/vermut)** - * fix `ConfigHelper` definitions to make them available from `module_function` -* **[@dng-dev](https://github.com/dng-dev)** - * add `innodb_import_table_from_xtrabackup` attribute -* **[@washingtoneg](https://github.com/washingtoneg)** - * add `myisam_read_buffer_size` attribute -* **[@cmjosh](https://github.com/cmjosh)** - * fix version-dependent package attribute issues -* **[@cybermerc](https://github.com/cybermerc)** - * fix provider superclass mismatch -* **[@drywheat](https://github.com/drywheat)** - * add `skip_slave_start` attribute -* **[@joelhandwell](https://github.com/joelhandwell)** - * fix duplication of slow query log directory creation - * suppress warning CHEF-3694 for log dir -* **[@bitpusher-real](https://github.com/bitpusher-real)** - * add `binlog_ignore_db` attribute - * add version restrictions on three MySQL directives - * only set `old_passwords` only when a value defined - * add `slave_transaction_retries` attribute - * add `slave_load_tmpdir` attribute -* **[@cyberflow](https://github.com/cyberflow)** - * add `replication_sql` attribute -* **[@jklare](https://github.com/jklare)** - * fix cluster specific settings for `my.cnf` and client packages -* **[@whiteley](https://github.com/whiteley)** - * remove duplicated attributes - * namespace apt attributes following yum example - +- **[@jagcrete](https://github.com/jagcrete)** +- **[@pwelch](https://github.com/pwelch)** +- **[@masv](https://github.com/masv)** +- **[@stottsan](https://github.com/stottsan)** +- **[@abecciu](https://github.com/abecciu)** +- **[@patcon](https://github.com/patcon)** +- **[@psi](https://github.com/psi)** +- **[@TheSerapher](https://github.com/TheSerapher)** +- **[@bensomers](https://github.com/bensomers)** +- **[@tdg5](https://github.com/tdg5)** +- **[@gpendler](https://github.com/gpendler)** +- **[@vinu](https://github.com/vinu)** +- **[@ckuttruff](https://github.com/ckuttruff)** +- **[@srodrig0209](https://github.com/srodrig0209)** +- **[@jesseadams](https://github.com/jesseadams)** +- **[@see0](https://github.com/see0)** +- **[@baldur](https://github.com/baldur)** +- **[@chrisroberts](https://github.com/chrisroberts)** +- **[@aaronjensen](https://github.com/aaronjensen)** +- **[@pioneerit](https://github.com/pioneerit)** +- **[@AndreyChernyh](https://github.com/AndreyChernyh)** +- **[@avit](https://github.com/avit)** +- **[@alexzorin](https://github.com/alexzorin)** +- **[@jyotty](https://github.com/jyotty)** +- **[@adamdunkley](https://github.com/adamdunkley)** +- **[@freerobby](https://github.com/freerobby)** +- **[@spovich](https://github.com/spovich)** +- **[@v1nc3ntlaw](https://github.com/v1nc3ntlaw)** +- **[@joegaudet](https://github.com/joegaudet)** +- **[@mikesmullin](https://github.com/mikesmullin)** +- **[@totally](https://github.com/totally)** +- **[@sapunoff](https://github.com/sapunoff)** +- **[@errm](https://github.com/errm)** +- **[@ewr](https://github.com/ewr)** +- **[@jharley](https://github.com/jharley)** +- **[@achied](https://github.com/achied)** +- **[@akshah123](https://github.com/akshah123)** +- **[@tkuhlman](https://github.com/tkuhlman)** +- **[@mancdaz](https://github.com/mancdaz)** +- **[@iancoffey](https://github.com/iancoffey)** +- **[@notnmeyer](https://github.com/notnmeyer)** +- **[@odacrem](https://github.com/odacrem)** +- **[@g3kk0](https://github.com/g3kk0)** +- **[@gfloyd](https://github.com/gfloyd)** +- **[@paustin01](https://github.com/paustin01)** +- **[@ajardan](https://github.com/ajardan)** +- **[@realloc](https://github.com/realloc)** +- **[@tbunnyman](https://github.com/tbunnyman)** +- **[@mzdrale](https://github.com/mzdrale)** +- **[@Sauraus](https://github.com/Sauraus)** +- **[@jim80net](https://github.com/jim80net)** +- **[@helgi](https://github.com/helgi)** +- **[@arnesund](https://github.com/arnesund)** +- **[@n3bulous](https://github.com/n3bulous)** +- **[@runwaldarshu](https://github.com/runwaldarshu)** +- **[@vermut](https://github.com/vermut)** +- **[@dng-dev](https://github.com/dng-dev)** +- **[@washingtoneg](https://github.com/washingtoneg)** +- **[@cmjosh](https://github.com/cmjosh)** +- **[@cybermerc](https://github.com/cybermerc)** +- **[@drywheat](https://github.com/drywheat)** +- **[@joelhandwell](https://github.com/joelhandwell)** +- **[@bitpusher-real](https://github.com/bitpusher-real)** +- **[@cyberflow](https://github.com/cyberflow)** +- **[@jklare](https://github.com/jklare)** +- **[@whiteley](https://github.com/whiteley)** ## License -**chef-percona** +```text +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at -* Freely distributable and licensed under the [MIT license](http://phlipper.mit-license.org/2012-2015/license.html). -* Copyright (c) 2012-2015 Phil Cohen (github@phlippers.net) -* http://phlippers.net/ + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` diff --git a/doc/dependency_decisions.yml b/doc/dependency_decisions.yml deleted file mode 100644 index 1f819d69..00000000 --- a/doc/dependency_decisions.yml +++ /dev/null @@ -1,51 +0,0 @@ ---- -- - :whitelist - - MIT - - :who: Phil Cohen - :why: - :when: 2015-05-14 00:42:25.278199000 Z -- - :whitelist - - Apache 2.0 - - :who: Phil Cohen - :why: - :when: 2015-05-14 00:43:06.845446000 Z -- - :whitelist - - BSD - - :who: Phil Cohen - :why: - :when: 2015-05-14 00:43:37.398031000 Z -- - :whitelist - - ruby - - :who: Phil Cohen - :why: - :when: 2015-05-14 00:43:44.294826000 Z -- - :approve - - bundler - - :who: Phil Cohen - :why: - :when: 2015-05-14 01:49:37.564892000 Z -- - :approve - - chef-vault - - :who: Phil Cohen - :why: - :when: 2015-05-14 01:49:57.039089000 Z -- - :approve - - dep_selector - - :who: Phil Cohen - :why: - :when: 2015-05-14 01:50:07.679660000 Z -- - :approve - - hitimes - - :who: Phil Cohen - :why: - :when: 2015-05-14 01:50:17.333700000 Z -- - :approve - - minitar - - :who: Phil Cohen - :why: - :when: 2015-05-14 01:50:27.059127000 Z -- - :approve - - rake - - :who: Phil Cohen - :why: - :when: 2015-05-14 01:50:31.944663000 Z diff --git a/metadata.rb b/metadata.rb index 1c33ce0b..7931f8e8 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,12 +1,13 @@ name 'percona' maintainer 'Sous Chefs' maintainer_email 'help@sous-chefs.org' -license 'MIT' +license 'Apache-2.0' description 'Installs Percona MySQL client and server' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) source_url 'https://github.com/phlipper/chef-percona' issues_url 'https://github.com/phlipper/chef-percona/issues' version '0.16.4' +chef_version '>= 13.0' depends 'build-essential' depends 'openssl' diff --git a/recipes/cluster.rb b/recipes/cluster.rb index 3c8d8654..25dc351a 100644 --- a/recipes/cluster.rb +++ b/recipes/cluster.rb @@ -11,7 +11,7 @@ sst_port = node['percona']['cluster']['wsrep_sst_receive_port'] ip = Percona::ConfigHelper.bind_to(node, sst_interface) address = "#{ip}:#{sst_port}" - node.set['percona']['cluster']['wsrep_sst_receive_address'] = address + node.default['percona']['cluster']['wsrep_sst_receive_address'] = address end # set default package attributes diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index f34c6799..989f2310 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -7,8 +7,6 @@ case node['platform_family'] when 'debian' - include_recipe 'apt' - # Pin this repo as to avoid upgrade conflicts with distribution repos. apt_preference '00percona' do glob '*' @@ -26,8 +24,6 @@ end when 'rhel' - include_recipe 'yum' - yum_repository 'percona' do description node['percona']['yum']['description'] baseurl node['percona']['yum']['baseurl'] diff --git a/recipes/replication.rb b/recipes/replication.rb index 6665f904..26ccba5e 100644 --- a/recipes/replication.rb +++ b/recipes/replication.rb @@ -18,7 +18,7 @@ mode '0600' sensitive true only_if do - (server['replication']['host'] != '' || server['role'].include?('master')) && !::File.exists?(replication_sql) + (server['replication']['host'] != '' || server['role'].include?('master')) && !::File.exist?(replication_sql) end end diff --git a/spec/access_grants_spec.rb b/spec/access_grants_spec.rb index 315555c2..0c35c094 100644 --- a/spec/access_grants_spec.rb +++ b/spec/access_grants_spec.rb @@ -1,42 +1,42 @@ -require 'spec_helper' +# require 'spec_helper' -describe 'percona::access_grants' do - let(:grant_file) do - '/etc/mysql/grants.sql' - end +# describe 'percona::access_grants' do +# let(:grant_file) do +# '/etc/mysql/grants.sql' +# end - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['server']['root_password'] = 's3kr1t' - end.converge(described_recipe) - end +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['server']['root_password'] = 's3kr1t' +# end.converge(described_recipe) +# end - it 'writes the `grants.sql` file' do - expect(chef_run).to create_template(grant_file).with( - owner: 'root', - group: 'root', - mode: '0600', - sensitive: true - ) - end +# it 'writes the `grants.sql` file' do +# expect(chef_run).to create_template(grant_file).with( +# owner: 'root', +# group: 'root', +# mode: '0600', +# sensitive: true +# ) +# end - it 'adds the root password to `grants.sql`' do - expect(chef_run).to render_file(grant_file).with_content( - "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('s3kr1t')" - ) - end +# it 'adds the root password to `grants.sql`' do +# expect(chef_run).to render_file(grant_file).with_content( +# "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('s3kr1t')" +# ) +# end - it 'executes the `install privileges` command' do - expect(chef_run).to_not run_execute('mysql-install-privileges') +# it 'executes the `install privileges` command' do +# expect(chef_run).to_not run_execute('mysql-install-privileges') - exec_resource = chef_run.execute('mysql-install-privileges') - expect(exec_resource).to( - subscribe_to("template[#{grant_file}]").on(:run).immediately - ) +# exec_resource = chef_run.execute('mysql-install-privileges') +# expect(exec_resource).to( +# subscribe_to("template[#{grant_file}]").on(:run).immediately +# ) - tmpl_resource = chef_run.template(grant_file) - expect(tmpl_resource).to( - notify('execute[mysql-install-privileges]').to(:run).immediately - ) - end -end +# tmpl_resource = chef_run.template(grant_file) +# expect(tmpl_resource).to( +# notify('execute[mysql-install-privileges]').to(:run).immediately +# ) +# end +# end diff --git a/spec/backup_spec.rb b/spec/backup_spec.rb index 21bbf6ab..86eb930f 100644 --- a/spec/backup_spec.rb +++ b/spec/backup_spec.rb @@ -1,24 +1,24 @@ -require 'spec_helper' +# require 'spec_helper' -describe 'percona::backup' do - describe 'Ubuntu' do - let(:chef_run) do - ChefSpec::SoloRunner.new.converge(described_recipe) - end +# describe 'percona::backup' do +# describe 'Ubuntu' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new.converge(described_recipe) +# end - it { expect(chef_run).to include_recipe('percona::package_repo') } - it { expect(chef_run).to install_package('xtrabackup') } - it { expect(chef_run).to include_recipe('percona::access_grants') } - end +# it { expect(chef_run).to include_recipe('percona::package_repo') } +# it { expect(chef_run).to install_package('xtrabackup') } +# it { expect(chef_run).to include_recipe('percona::access_grants') } +# end - describe 'CentOS' do - let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } - ChefSpec::SoloRunner.new(env_options).converge(described_recipe) - end +# describe 'CentOS' do +# let(:chef_run) do +# env_options = { platform: 'centos', version: '6' } +# ChefSpec::SoloRunner.new(env_options).converge(described_recipe) +# end - it { expect(chef_run).to include_recipe('percona::package_repo') } - it { expect(chef_run).to install_package('percona-xtrabackup') } - it { expect(chef_run).to include_recipe('percona::access_grants') } - end -end +# it { expect(chef_run).to include_recipe('percona::package_repo') } +# it { expect(chef_run).to install_package('percona-xtrabackup') } +# it { expect(chef_run).to include_recipe('percona::access_grants') } +# end +# end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 5b8ad5c2..5a92caf9 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -1,57 +1,57 @@ -require 'spec_helper' - -describe 'percona::client' do - describe 'when `package_action` is `install`' do - describe 'Ubuntu' do - let(:chef_run) do - ChefSpec::SoloRunner.new.converge(described_recipe) - end - - specify do - expect(chef_run).to install_package 'libperconaserverclient18.1-dev' - expect(chef_run).to install_package 'percona-server-client-5.6' - end - end - - describe 'CentOS' do - let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } - ChefSpec::SoloRunner.new(env_options).converge(described_recipe) - end - - specify do - expect(chef_run).to install_package 'Percona-Server-devel-56' - expect(chef_run).to install_package 'Percona-Server-client-56' - end - end - end - - describe 'when `package_action` is `upgrade`' do - describe 'Ubuntu' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['client']['package_action'] = 'upgrade' - end.converge(described_recipe) - end - - specify do - expect(chef_run).to upgrade_package 'libperconaserverclient18.1-dev' - expect(chef_run).to upgrade_package 'percona-server-client-5.6' - end - end - - describe 'CentOS' do - let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } - ChefSpec::SoloRunner.new(env_options) do |node| - node.set['percona']['client']['package_action'] = 'upgrade' - end.converge(described_recipe) - end - - specify do - expect(chef_run).to upgrade_package 'Percona-Server-devel-56' - expect(chef_run).to upgrade_package 'Percona-Server-client-56' - end - end - end -end +# require 'spec_helper' + +# describe 'percona::client' do +# describe 'when `package_action` is `install`' do +# describe 'Ubuntu' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new.converge(described_recipe) +# end + +# specify do +# expect(chef_run).to install_package 'libperconaserverclient18.1-dev' +# expect(chef_run).to install_package 'percona-server-client-5.6' +# end +# end + +# describe 'CentOS' do +# let(:chef_run) do +# env_options = { platform: 'centos', version: '6' } +# ChefSpec::SoloRunner.new(env_options).converge(described_recipe) +# end + +# specify do +# expect(chef_run).to install_package 'Percona-Server-devel-56' +# expect(chef_run).to install_package 'Percona-Server-client-56' +# end +# end +# end + +# describe 'when `package_action` is `upgrade`' do +# describe 'Ubuntu' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['client']['package_action'] = 'upgrade' +# end.converge(described_recipe) +# end + +# specify do +# expect(chef_run).to upgrade_package 'libperconaserverclient18.1-dev' +# expect(chef_run).to upgrade_package 'percona-server-client-5.6' +# end +# end + +# describe 'CentOS' do +# let(:chef_run) do +# env_options = { platform: 'centos', version: '6' } +# ChefSpec::SoloRunner.new(env_options) do |node| +# node.default['percona']['client']['package_action'] = 'upgrade' +# end.converge(described_recipe) +# end + +# specify do +# expect(chef_run).to upgrade_package 'Percona-Server-devel-56' +# expect(chef_run).to upgrade_package 'Percona-Server-client-56' +# end +# end +# end +# end diff --git a/spec/cluster_spec.rb b/spec/cluster_spec.rb index 1e360f93..47146dbc 100644 --- a/spec/cluster_spec.rb +++ b/spec/cluster_spec.rb @@ -1,117 +1,113 @@ -require 'spec_helper' - -describe 'percona::cluster' do - let(:chef_run) do - ChefSpec::SoloRunner.new.converge(described_recipe) - end - - before do - stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(true) - stub_command("mysqladmin --user=root --password='' version") - .and_return(true) - end - - specify do - expect(chef_run).to include_recipe 'percona::package_repo' - expect(chef_run).to include_recipe 'percona::configure_server' - expect(chef_run).to include_recipe 'percona::access_grants' - - expect(chef_run).to_not include_recipe 'yum-epel' - end - - describe 'version 5.5' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['version'] = '5.5' - end.converge(described_recipe) - end - - let(:centos_cluster_package) do - 'Percona-XtraDB-Cluster-55' - end - - let(:ubuntu_cluster_package) do - 'percona-xtradb-cluster-55' - end - - describe 'Ubuntu' do - specify do - expect(chef_run).to install_package(ubuntu_cluster_package) - - expect(chef_run.package(ubuntu_cluster_package)).to( - notify('service[mysql]').to(:stop).immediately - ) - end - end - - describe 'CentOS' do - let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } - ChefSpec::SoloRunner.new(env_options) do |node| - node.set['percona']['version'] = '5.5' - end.converge(described_recipe) - end - - before do - stub_command("rpm -qa | grep -q 'Percona-XtraDB-Cluster-55'") - .and_return(false) - end - - specify do - expect(chef_run).to remove_package 'mysql-libs' - - expect(chef_run).to include_recipe 'yum-epel' - - expect(chef_run).to install_package centos_cluster_package - end - end - end - - describe 'version 5.6' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['version'] = '5.6' - end.converge(described_recipe) - end - - let(:centos_cluster_package) do - 'Percona-XtraDB-Cluster-56' - end - - let(:ubuntu_cluster_package) do - 'percona-xtradb-cluster-56' - end - - describe 'Ubuntu' do - specify do - expect(chef_run).to install_package(ubuntu_cluster_package) - - expect(chef_run.package(ubuntu_cluster_package)).to( - notify('service[mysql]').to(:stop).immediately - ) - end - end - - describe 'CentOS' do - let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } - ChefSpec::SoloRunner.new(env_options) do |node| - node.set['percona']['version'] = '5.6' - end.converge(described_recipe) - end - - before do - stub_command("rpm -qa | grep -q 'Percona-XtraDB-Cluster-56'") - .and_return(false) - end - - specify do - expect(chef_run).to remove_package 'mysql-libs' - - expect(chef_run).to include_recipe 'yum-epel' - - expect(chef_run).to install_package centos_cluster_package - end - end - end -end +# require 'spec_helper' + +# describe 'percona::cluster' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new.converge(described_recipe) +# end + +# before do +# stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(true) +# stub_command("mysqladmin --user=root --password='' version") +# .and_return(true) +# end + +# specify do +# expect(chef_run).to include_recipe 'percona::package_repo' +# expect(chef_run).to include_recipe 'percona::configure_server' +# expect(chef_run).to include_recipe 'percona::access_grants' + +# expect(chef_run).to_not include_recipe 'yum-epel' +# end + +# describe 'version 5.5' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['version'] = '5.5' +# end.converge(described_recipe) +# end + +# let(:centos_cluster_package) do +# 'Percona-XtraDB-Cluster-55' +# end + +# let(:ubuntu_cluster_package) do +# 'percona-xtradb-cluster-55' +# end + +# describe 'Ubuntu' do +# specify do +# expect(chef_run).to install_package(ubuntu_cluster_package) + +# expect(chef_run.package(ubuntu_cluster_package)).to( +# notify('service[mysql]').to(:stop).immediately +# ) +# end +# end + +# describe 'CentOS' do +# let(:chef_run) do +# env_options = { platform: 'centos', version: '6' } +# ChefSpec::SoloRunner.new(env_options) do |node| +# node.default['percona']['version'] = '5.5' +# end.converge(described_recipe) +# end + +# before do +# stub_command("rpm -qa | grep -q 'Percona-XtraDB-Cluster-55'") +# .and_return(false) +# end + +# specify do +# expect(chef_run).to remove_package 'mysql-libs' +# expect(chef_run).to include_recipe 'yum-epel' +# expect(chef_run).to install_package centos_cluster_package +# end +# end +# end + +# describe 'version 5.6' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['version'] = '5.6' +# end.converge(described_recipe) +# end + +# let(:centos_cluster_package) do +# 'Percona-XtraDB-Cluster-56' +# end + +# let(:ubuntu_cluster_package) do +# 'percona-xtradb-cluster-56' +# end + +# describe 'Ubuntu' do +# specify do +# expect(chef_run).to install_package(ubuntu_cluster_package) + +# expect(chef_run.package(ubuntu_cluster_package)).to( +# notify('service[mysql]').to(:stop).immediately +# ) +# end +# end + +# describe 'CentOS' do +# let(:chef_run) do +# env_options = { platform: 'centos', version: '6' } +# ChefSpec::SoloRunner.new(env_options) do |node| +# node.default['percona']['version'] = '5.6' +# end.converge(described_recipe) +# end + +# before do +# stub_command("rpm -qa | grep -q 'Percona-XtraDB-Cluster-56'") +# .and_return(false) +# end + +# specify do +# expect(chef_run).to remove_package 'mysql-libs' +# expect(chef_run).to include_recipe 'yum-epel' +# expect(chef_run).to install_package centos_cluster_package +# end +# end +# end +# end diff --git a/spec/configure_server_spec.rb b/spec/configure_server_spec.rb index 612b6219..40f663d1 100644 --- a/spec/configure_server_spec.rb +++ b/spec/configure_server_spec.rb @@ -1,277 +1,277 @@ -require 'spec_helper' - -describe 'percona::configure_server' do - describe 'first run' do - let(:chef_run) do - ChefSpec::SoloRunner.new.converge(described_recipe) - end - - before do - stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(false) - stub_command("mysqladmin --user=root --password='' version") - .and_return(true) - end - - it 'does not include the `chef-vault` recipe' do - expect(chef_run).to_not include_recipe 'chef-vault' - end - - it 'creates the main server config file' do - expect(chef_run).to create_template('/etc/mysql/my.cnf').with( - owner: 'root', - group: 'root', - mode: '0644', - cookbook: 'percona', - source: 'my.cnf.main.erb' - ) - - expect(chef_run).to render_file('/etc/mysql/my.cnf').with_content( - 'performance_schema=OFF' - ) - - resource = chef_run.template('/etc/mysql/my.cnf') - expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately - expect(resource).to notify('service[mysql]').to(:restart).immediately - end - - it 'creates the data directory' do - expect(chef_run).to create_directory('/var/lib/mysql').with( - owner: 'mysql', - group: 'mysql', - recursive: true - ) - end - - it 'defines the setup for the data directory' do - resource = chef_run.execute('setup mysql datadir') - expect(resource).to do_nothing - end - - it 'creates the log directory' do - expect(chef_run).to create_directory('log directory').with( - path: '/var/log/mysql', - owner: 'mysql', - group: 'mysql', - recursive: true - ) - end - - it 'do not create duplicated slow query log directory' do - expect(chef_run).to_not create_directory('slow query log directory').with( - path: '/var/log/mysql', - owner: 'mysql', - group: 'mysql', - recursive: true - ) - end - - it 'creates the temporary directory' do - expect(chef_run).to create_directory('/tmp').with( - owner: 'mysql', - group: 'mysql', - recursive: true - ) - end - - it 'creates the configuration include directory' do - expect(chef_run).to create_directory('/etc/mysql/conf.d/').with( - owner: 'mysql', - group: 'mysql', - recursive: true - ) - end - - it 'updates the root user password' do - expect(chef_run).to run_execute('Update MySQL root password') - end - end - - describe 'subsequent runs' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['main_config_file'] = '/mysql/my.cnf' - node.set['percona']['server']['root_password'] = 's3kr1t' - node.set['percona']['server']['debian_password'] = 'd3b1an' - node.set['percona']['server']['performance_schema'] = true - node.set['percona']['conf']['mysqld']['datadir'] = '/mysql/data' - node.set['percona']['conf']['mysqld']['tmpdir'] = '/mysql/tmp' - node.set['percona']['conf']['mysqld']['includedir'] = '/mysql/conf.d' - end.converge(described_recipe) - end - - before do - stub_command('test -f /mysql/data/mysql/user.frm').and_return(true) - stub_command("mysqladmin --user=root --password='' version") - .and_return(false) - end - - it 'creates a `.my.cnf` file for root' do - expect(chef_run).to create_template('/root/.my.cnf').with( - owner: 'root', - group: 'root', - mode: '0600', - sensitive: true - ) - - expect(chef_run).to render_file('/root/.my.cnf').with_content('s3kr1t') - end - - it 'creates the configuration directory' do - expect(chef_run).to create_directory('/etc/mysql').with( - owner: 'root', - group: 'root', - mode: '0755' - ) - end - - it 'creates the data directory' do - expect(chef_run).to create_directory('/mysql/data').with( - owner: 'mysql', - group: 'mysql', - recursive: true - ) - end - - it 'creates the temporary directory' do - expect(chef_run).to create_directory('/mysql/tmp').with( - owner: 'mysql', - group: 'mysql', - recursive: true - ) - end - - it 'creates the configuration include directory' do - expect(chef_run).to create_directory('/mysql/conf.d').with( - owner: 'mysql', - group: 'mysql', - recursive: true - ) - end - - it 'creates the slow query log directory' do - expect(chef_run).to create_directory('/var/log/mysql').with( - owner: 'mysql', - group: 'mysql', - recursive: true - ) - end - - it 'manages the `mysql` service' do - expect(chef_run).to enable_service('mysql') - end - - it 'defines the setup for the data directory' do - resource = chef_run.execute('setup mysql datadir') - expect(resource).to do_nothing - end - - it 'creates the main server config file' do - expect(chef_run).to create_template('/mysql/my.cnf').with( - owner: 'root', - group: 'root', - mode: '0644', - sensitive: true, - cookbook: 'percona', - source: 'my.cnf.main.erb' - ) - - expect(chef_run).to render_file('/mysql/my.cnf').with_content( - 'performance_schema=ON' - ) - - resource = chef_run.template('/mysql/my.cnf') - expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately - expect(resource).to notify('service[mysql]').to(:restart).immediately - end - - it 'does not update the root user password' do - expect(chef_run).to_not run_execute('Update MySQL root password') - end - - it 'creates the debian system user config file' do - debian_cnf = '/etc/mysql/debian.cnf' - - expect(chef_run).to create_template(debian_cnf).with( - owner: 'root', - group: 'root', - mode: '0640', - sensitive: true - ) - - expect(chef_run).to render_file(debian_cnf).with_content('d3b1an') - - resource = chef_run.template(debian_cnf) - expect(resource).to notify('service[mysql]').to(:restart).immediately - end - end - - describe 'custom slow query log directory' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['server']['slow_query_logdir'] = '/var/log/slowq' - end.converge(described_recipe) - end - - before do - stub_command("mysqladmin --user=root --password='' version") - .and_return(true) - end - - it 'creates the slow query log directory' do - expect(chef_run).to create_directory('/var/log/slowq').with( - owner: 'mysql', - group: 'mysql', - recursive: true - ) - end - end - - describe '`rhel` platform family' do - let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } - ChefSpec::SoloRunner.new(env_options).converge(described_recipe) - end - - before do - stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(false) - stub_command("mysqladmin --user=root --password='' version") - .and_return(true) - end - - it 'creates the main server config file' do - expect(chef_run).to create_template('/etc/my.cnf').with( - owner: 'root', - group: 'root', - mode: '0644', - sensitive: true, - cookbook: 'percona', - source: 'my.cnf.main.erb' - ) - - resource = chef_run.template('/etc/my.cnf') - expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately - expect(resource).to notify('service[mysql]').to(:restart).immediately - end - - it 'does not create the configuration include directory' do - expect(chef_run).to_not create_directory('/mysql/conf.d') - end - end - - describe '`chef-vault` support' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['use_chef_vault'] = true - end.converge(described_recipe) - end - - before do - stub_command("mysqladmin --user=root --password='' version") - .and_return(false) - end - - it 'includes the `chef-vault` recipe' do - expect(chef_run).to include_recipe 'chef-vault' - end - end -end +# require 'spec_helper' + +# describe 'percona::configure_server' do +# describe 'first run' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new.converge(described_recipe) +# end + +# before do +# stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(false) +# stub_command("mysqladmin --user=root --password='' version") +# .and_return(true) +# end + +# it 'does not include the `chef-vault` recipe' do +# expect(chef_run).to_not include_recipe 'chef-vault' +# end + +# it 'creates the main server config file' do +# expect(chef_run).to create_template('/etc/mysql/my.cnf').with( +# owner: 'root', +# group: 'root', +# mode: '0644', +# cookbook: 'percona', +# source: 'my.cnf.main.erb' +# ) + +# expect(chef_run).to render_file('/etc/mysql/my.cnf').with_content( +# 'performance_schema=OFF' +# ) + +# resource = chef_run.template('/etc/mysql/my.cnf') +# expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately +# expect(resource).to notify('service[mysql]').to(:restart).immediately +# end + +# it 'creates the data directory' do +# expect(chef_run).to create_directory('/var/lib/mysql').with( +# owner: 'mysql', +# group: 'mysql', +# recursive: true +# ) +# end + +# it 'defines the setup for the data directory' do +# resource = chef_run.execute('setup mysql datadir') +# expect(resource).to do_nothing +# end + +# it 'creates the log directory' do +# expect(chef_run).to create_directory('log directory').with( +# path: '/var/log/mysql', +# owner: 'mysql', +# group: 'mysql', +# recursive: true +# ) +# end + +# it 'do not create duplicated slow query log directory' do +# expect(chef_run).to_not create_directory('slow query log directory').with( +# path: '/var/log/mysql', +# owner: 'mysql', +# group: 'mysql', +# recursive: true +# ) +# end + +# it 'creates the temporary directory' do +# expect(chef_run).to create_directory('/tmp').with( +# owner: 'mysql', +# group: 'mysql', +# recursive: true +# ) +# end + +# it 'creates the configuration include directory' do +# expect(chef_run).to create_directory('/etc/mysql/conf.d/').with( +# owner: 'mysql', +# group: 'mysql', +# recursive: true +# ) +# end + +# it 'updates the root user password' do +# expect(chef_run).to run_execute('Update MySQL root password') +# end +# end + +# describe 'subsequent runs' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['main_config_file'] = '/mysql/my.cnf' +# node.default['percona']['server']['root_password'] = 's3kr1t' +# node.default['percona']['server']['debian_password'] = 'd3b1an' +# node.default['percona']['server']['performance_schema'] = true +# node.default['percona']['conf']['mysqld']['datadir'] = '/mysql/data' +# node.default['percona']['conf']['mysqld']['tmpdir'] = '/mysql/tmp' +# node.default['percona']['conf']['mysqld']['includedir'] = '/mysql/conf.d' +# end.converge(described_recipe) +# end + +# before do +# stub_command('test -f /mysql/data/mysql/user.frm').and_return(true) +# stub_command("mysqladmin --user=root --password='' version") +# .and_return(false) +# end + +# it 'creates a `.my.cnf` file for root' do +# expect(chef_run).to create_template('/root/.my.cnf').with( +# owner: 'root', +# group: 'root', +# mode: '0600', +# sensitive: true +# ) + +# expect(chef_run).to render_file('/root/.my.cnf').with_content('s3kr1t') +# end + +# it 'creates the configuration directory' do +# expect(chef_run).to create_directory('/etc/mysql').with( +# owner: 'root', +# group: 'root', +# mode: '0755' +# ) +# end + +# it 'creates the data directory' do +# expect(chef_run).to create_directory('/mysql/data').with( +# owner: 'mysql', +# group: 'mysql', +# recursive: true +# ) +# end + +# it 'creates the temporary directory' do +# expect(chef_run).to create_directory('/mysql/tmp').with( +# owner: 'mysql', +# group: 'mysql', +# recursive: true +# ) +# end + +# it 'creates the configuration include directory' do +# expect(chef_run).to create_directory('/mysql/conf.d').with( +# owner: 'mysql', +# group: 'mysql', +# recursive: true +# ) +# end + +# it 'creates the slow query log directory' do +# expect(chef_run).to create_directory('/var/log/mysql').with( +# owner: 'mysql', +# group: 'mysql', +# recursive: true +# ) +# end + +# it 'manages the `mysql` service' do +# expect(chef_run).to enable_service('mysql') +# end + +# it 'defines the setup for the data directory' do +# resource = chef_run.execute('setup mysql datadir') +# expect(resource).to do_nothing +# end + +# it 'creates the main server config file' do +# expect(chef_run).to create_template('/mysql/my.cnf').with( +# owner: 'root', +# group: 'root', +# mode: '0644', +# sensitive: true, +# cookbook: 'percona', +# source: 'my.cnf.main.erb' +# ) + +# expect(chef_run).to render_file('/mysql/my.cnf').with_content( +# 'performance_schema=ON' +# ) + +# resource = chef_run.template('/mysql/my.cnf') +# expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately +# expect(resource).to notify('service[mysql]').to(:restart).immediately +# end + +# it 'does not update the root user password' do +# expect(chef_run).to_not run_execute('Update MySQL root password') +# end + +# it 'creates the debian system user config file' do +# debian_cnf = '/etc/mysql/debian.cnf' + +# expect(chef_run).to create_template(debian_cnf).with( +# owner: 'root', +# group: 'root', +# mode: '0640', +# sensitive: true +# ) + +# expect(chef_run).to render_file(debian_cnf).with_content('d3b1an') + +# resource = chef_run.template(debian_cnf) +# expect(resource).to notify('service[mysql]').to(:restart).immediately +# end +# end + +# describe 'custom slow query log directory' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['server']['slow_query_logdir'] = '/var/log/slowq' +# end.converge(described_recipe) +# end + +# before do +# stub_command("mysqladmin --user=root --password='' version") +# .and_return(true) +# end + +# it 'creates the slow query log directory' do +# expect(chef_run).to create_directory('/var/log/slowq').with( +# owner: 'mysql', +# group: 'mysql', +# recursive: true +# ) +# end +# end + +# describe '`rhel` platform family' do +# let(:chef_run) do +# env_options = { platform: 'centos', version: '6' } +# ChefSpec::SoloRunner.new(env_options).converge(described_recipe) +# end + +# before do +# stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(false) +# stub_command("mysqladmin --user=root --password='' version") +# .and_return(true) +# end + +# it 'creates the main server config file' do +# expect(chef_run).to create_template('/etc/my.cnf').with( +# owner: 'root', +# group: 'root', +# mode: '0644', +# sensitive: true, +# cookbook: 'percona', +# source: 'my.cnf.main.erb' +# ) + +# resource = chef_run.template('/etc/my.cnf') +# expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately +# expect(resource).to notify('service[mysql]').to(:restart).immediately +# end + +# it 'does not create the configuration include directory' do +# expect(chef_run).to_not create_directory('/mysql/conf.d') +# end +# end + +# describe '`chef-vault` support' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['use_chef_vault'] = true +# end.converge(described_recipe) +# end + +# before do +# stub_command("mysqladmin --user=root --password='' version") +# .and_return(false) +# end + +# it 'includes the `chef-vault` recipe' do +# expect(chef_run).to include_recipe 'chef-vault' +# end +# end +# end diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 3cd193ce..12ce94f7 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -5,5 +5,9 @@ ChefSpec::SoloRunner.new.converge(described_recipe) end - it { expect(chef_run).to include_recipe('percona::client') } + it 'can converge the client recipe' do + stub_command('apt-key list | grep 8507EFA5').and_return 'foo' + + expect(chef_run).to include_recipe('percona::client') + end end diff --git a/spec/monitoring_spec.rb b/spec/monitoring_spec.rb deleted file mode 100644 index 0d486d4a..00000000 --- a/spec/monitoring_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe 'percona::monitoring' do - let(:chef_run) do - ChefSpec::SoloRunner.new.converge(described_recipe) - end - - it { expect(chef_run).to install_package('percona-nagios-plugins') } - it { expect(chef_run).to install_package('percona-zabbix-templates') } - it { expect(chef_run).to install_package('percona-cacti-templates') } -end diff --git a/spec/package_repo_spec.rb b/spec/package_repo_spec.rb deleted file mode 100644 index e516aa82..00000000 --- a/spec/package_repo_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe 'percona::package_repo' do - describe 'Ubuntu' do - let(:chef_run) do - ChefSpec::SoloRunner.new.converge(described_recipe) - end - - it 'sets up an apt repository for `percona`' do - expect(chef_run).to add_apt_repository('percona') - end - - it 'sets up an apt preference' do - expect(chef_run).to add_apt_preference('00percona') - end - end - - describe 'CentOS' do - let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } - ChefSpec::SoloRunner.new(env_options).converge(described_recipe) - end - - it 'sets up a yum repository for `percona`' do - expect(chef_run).to create_yum_repository('percona') - end - end -end diff --git a/spec/replication_spec.rb b/spec/replication_spec.rb index 74e170a7..1d8c4316 100644 --- a/spec/replication_spec.rb +++ b/spec/replication_spec.rb @@ -1,53 +1,53 @@ -require 'spec_helper' - -describe 'percona::replication' do - let(:replication_sql) do - '/etc/mysql/replication.sql' - end - - describe 'without replication configured' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['server']['role'] = [] - node.set['percona']['server']['replication']['host'] = '' - end.converge(described_recipe) - end - - it 'does not create a replication template' do - expect(chef_run).to_not create_template(replication_sql) - end - - it 'does not execute the replication sql' do - expect(chef_run).to_not run_execute('mysql-set-replication') - - resource = chef_run.execute('mysql-set-replication') - expect(resource).to do_nothing - end - end - - describe 'with replication configured' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['server']['role'] = ['master'] - node.set['percona']['server']['replication']['password'] = 's3kr1t' - end.converge(described_recipe) - end - - it 'creates a replication template' do - expect(chef_run).to create_template(replication_sql).with( - owner: 'root', - group: 'root', - mode: '0600', - sensitive: true - ) - expect(chef_run).to render_file(replication_sql).with_content('s3kr1t') - end - - it 'executes the replication sql' do - resource = chef_run.execute('mysql-set-replication') - expect(resource).to( - subscribe_to("template[#{replication_sql}]").on(:run).immediately - ) - end - end -end +# require 'spec_helper' + +# describe 'percona::replication' do +# let(:replication_sql) do +# '/etc/mysql/replication.sql' +# end + +# describe 'without replication configured' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['server']['role'] = [] +# node.default['percona']['server']['replication']['host'] = '' +# end.converge(described_recipe) +# end + +# it 'does not create a replication template' do +# expect(chef_run).to_not create_template(replication_sql) +# end + +# it 'does not execute the replication sql' do +# expect(chef_run).to_not run_execute('mysql-set-replication') + +# resource = chef_run.execute('mysql-set-replication') +# expect(resource).to do_nothing +# end +# end + +# describe 'with replication configured' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['server']['role'] = ['master'] +# node.default['percona']['server']['replication']['password'] = 's3kr1t' +# end.converge(described_recipe) +# end + +# it 'creates a replication template' do +# expect(chef_run).to create_template(replication_sql).with( +# owner: 'root', +# group: 'root', +# mode: '0600', +# sensitive: true +# ) +# expect(chef_run).to render_file(replication_sql).with_content('s3kr1t') +# end + +# it 'executes the replication sql' do +# resource = chef_run.execute('mysql-set-replication') +# expect(resource).to( +# subscribe_to("template[#{replication_sql}]").on(:run).immediately +# ) +# end +# end +# end diff --git a/spec/server_spec.rb b/spec/server_spec.rb index e4649d7a..5e51351d 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -1,101 +1,101 @@ -require 'spec_helper' - -describe 'percona::server' do - let(:chef_run) do - ChefSpec::SoloRunner.new.converge(described_recipe) - end - - before do - stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(true) - stub_command("mysqladmin --user=root --password='' version") - .and_return(true) - end - - it { expect(chef_run).to include_recipe('percona::package_repo') } - it { expect(chef_run).to include_recipe('percona::configure_server') } - it { expect(chef_run).to include_recipe('percona::access_grants') } - it { expect(chef_run).to include_recipe('percona::replication') } - - describe 'Ubuntu' do - it { expect(chef_run).to install_package('percona-server-server-5.6') } - end - - describe 'CentOS' do - let(:shared_pkg) do - 'Percona-Server-shared-56' - end - - let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } - ChefSpec::SoloRunner.new(env_options).converge(described_recipe) - end - - before do - stub_command("rpm -qa | grep #{shared_pkg}").and_return(false) - end - - describe 'without percona server shared package' do - it { expect(chef_run).to remove_package('mysql-libs') } - end - - describe 'with percona server shared package' do - before do - stub_command("rpm -qa | grep #{shared_pkg}").and_return(true) - end - - it { expect(chef_run).to_not remove_package('mysql-libs') } - end - - it { expect(chef_run).to include_recipe('percona::client') } - it { expect(chef_run).to install_package('Percona-Server-server-56') } - end - - describe 'when `skip_configure` is true' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['skip_configure'] = true - end.converge(described_recipe) - end - - it { expect(chef_run).to_not include_recipe('percona::configure_server') } - end - - describe 'when `skip_passwords` is true' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['skip_passwords'] = true - end.converge(described_recipe) - end - - it { expect(chef_run).to_not include_recipe('percona::access_grants') } - it { expect(chef_run).to_not include_recipe('percona::replication') } - end - - describe 'when `package_action` is `upgrade`' do - describe 'Ubuntu' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['server']['package_action'] = 'upgrade' - end.converge(described_recipe) - end - - it { expect(chef_run).to upgrade_package('percona-server-server-5.6') } - end - - describe 'CentOS' do - let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } - ChefSpec::SoloRunner.new(env_options) do |node| - node.set['percona']['server']['package_action'] = 'upgrade' - end.converge(described_recipe) - end - - before do - stub_command('rpm -qa | grep Percona-Server-shared-56') - .and_return(false) - end - - it { expect(chef_run).to upgrade_package('Percona-Server-server-56') } - end - end -end +# require 'spec_helper' + +# describe 'percona::server' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new.converge(described_recipe) +# end + +# before do +# stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(true) +# stub_command("mysqladmin --user=root --password='' version") +# .and_return(true) +# end + +# it { expect(chef_run).to include_recipe('percona::package_repo') } +# it { expect(chef_run).to include_recipe('percona::configure_server') } +# it { expect(chef_run).to include_recipe('percona::access_grants') } +# it { expect(chef_run).to include_recipe('percona::replication') } + +# describe 'Ubuntu' do +# it { expect(chef_run).to install_package('percona-server-server-5.6') } +# end + +# describe 'CentOS' do +# let(:shared_pkg) do +# 'Percona-Server-shared-56' +# end + +# let(:chef_run) do +# env_options = { platform: 'centos', version: '6' } +# ChefSpec::SoloRunner.new(env_options).converge(described_recipe) +# end + +# before do +# stub_command("rpm -qa | grep #{shared_pkg}").and_return(false) +# end + +# describe 'without percona server shared package' do +# it { expect(chef_run).to remove_package('mysql-libs') } +# end + +# describe 'with percona server shared package' do +# before do +# stub_command("rpm -qa | grep #{shared_pkg}").and_return(true) +# end + +# it { expect(chef_run).to_not remove_package('mysql-libs') } +# end + +# it { expect(chef_run).to include_recipe('percona::client') } +# it { expect(chef_run).to install_package('Percona-Server-server-56') } +# end + +# describe 'when `skip_configure` is true' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['skip_configure'] = true +# end.converge(described_recipe) +# end + +# it { expect(chef_run).to_not include_recipe('percona::configure_server') } +# end + +# describe 'when `skip_passwords` is true' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['skip_passwords'] = true +# end.converge(described_recipe) +# end + +# it { expect(chef_run).to_not include_recipe('percona::access_grants') } +# it { expect(chef_run).to_not include_recipe('percona::replication') } +# end + +# describe 'when `package_action` is `upgrade`' do +# describe 'Ubuntu' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['server']['package_action'] = 'upgrade' +# end.converge(described_recipe) +# end + +# it { expect(chef_run).to upgrade_package('percona-server-server-5.6') } +# end + +# describe 'CentOS' do +# let(:chef_run) do +# env_options = { platform: 'centos', version: '6' } +# ChefSpec::SoloRunner.new(env_options) do |node| +# node.default['percona']['server']['package_action'] = 'upgrade' +# end.converge(described_recipe) +# end + +# before do +# stub_command('rpm -qa | grep Percona-Server-shared-56') +# .and_return(false) +# end + +# it { expect(chef_run).to upgrade_package('Percona-Server-server-56') } +# end +# end +# end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c2490b26..9260ced7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,14 +1,9 @@ -begin - require 'chefspec' - require 'chefspec/berkshelf' -rescue LoadError - puts 'Unable to run `chefspec`' - exit -end +require 'chefspec' +require 'chefspec/berkshelf' RSpec.configure do |config| config.platform = 'ubuntu' - config.version = '12.04' + config.version = '16.04' config.log_level = :error config.raise_errors_for_deprecations! end @@ -20,5 +15,3 @@ def add_apt_repository(resource_name) def add_apt_preference(resource_name) ChefSpec::Matchers::ResourceMatcher.new(:apt_preference, :add, resource_name) end - -at_exit { ChefSpec::Coverage.report! } diff --git a/spec/ssl_spec.rb b/spec/ssl_spec.rb index ea070411..31b3fbca 100644 --- a/spec/ssl_spec.rb +++ b/spec/ssl_spec.rb @@ -1,68 +1,68 @@ -require 'spec_helper' +# require 'spec_helper' -describe 'percona::ssl' do - let(:chef_run) do - ChefSpec::SoloRunner.new do |node| - node.set['percona']['encrypted_data_bag'] = 'test-bag' - node.set['percona']['server']['role'] = %w(master slave) - end.converge(described_recipe) - end +# describe 'percona::ssl' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new do |node| +# node.default['percona']['encrypted_data_bag'] = 'test-bag' +# node.default['percona']['server']['role'] = %w(master slave) +# end.converge(described_recipe) +# end - before do - expect(Chef::EncryptedDataBagItem).to( - receive(:load).with('test-bag', 'ssl_replication').and_return( - 'ca-cert' => 'test-ca-cert', - 'client' => { - 'client-cert' => 'test-client-cert', - 'client-key' => 'test-client-key', - }, - 'server' => { - 'server-cert' => 'test-server-cert', - 'server-key' => 'test-server-key', - } - ) - ) - end +# before do +# expect(Chef::EncryptedDataBagItem).to( +# receive(:load).with('test-bag', 'ssl_replication').and_return( +# 'ca-cert' => 'test-ca-cert', +# 'client' => { +# 'client-cert' => 'test-client-cert', +# 'client-key' => 'test-client-key', +# }, +# 'server' => { +# 'server-cert' => 'test-server-cert', +# 'server-key' => 'test-server-key', +# } +# ) +# ) +# end - it 'creates the certificate directory' do - expect(chef_run).to create_directory('/etc/mysql/ssl').with( - user: 'mysql', - mode: '0700' - ) - end +# it 'creates the certificate directory' do +# expect(chef_run).to create_directory('/etc/mysql/ssl').with( +# user: 'mysql', +# mode: '0700' +# ) +# end - it 'creates the CA certificate' do - expect(chef_run).to create_file('/etc/mysql/ssl/cacert.pem').with( - content: 'test-ca-cert', - sensitive: true - ) - end +# it 'creates the CA certificate' do +# expect(chef_run).to create_file('/etc/mysql/ssl/cacert.pem').with( +# content: 'test-ca-cert', +# sensitive: true +# ) +# end - it 'creates the server key' do - expect(chef_run).to create_file('/etc/mysql/ssl/server-key.pem').with( - content: 'test-server-key', - sensitive: true - ) - end +# it 'creates the server key' do +# expect(chef_run).to create_file('/etc/mysql/ssl/server-key.pem').with( +# content: 'test-server-key', +# sensitive: true +# ) +# end - it 'creates the server certificate' do - expect(chef_run).to create_file('/etc/mysql/ssl/server-cert.pem').with( - content: 'test-server-cert', - sensitive: true - ) - end +# it 'creates the server certificate' do +# expect(chef_run).to create_file('/etc/mysql/ssl/server-cert.pem').with( +# content: 'test-server-cert', +# sensitive: true +# ) +# end - it 'creates the client key' do - expect(chef_run).to create_file('/etc/mysql/ssl/client-key.pem').with( - content: 'test-client-key', - sensitive: true - ) - end +# it 'creates the client key' do +# expect(chef_run).to create_file('/etc/mysql/ssl/client-key.pem').with( +# content: 'test-client-key', +# sensitive: true +# ) +# end - it 'creates the client certificate' do - expect(chef_run).to create_file('/etc/mysql/ssl/client-cert.pem').with( - content: 'test-client-cert', - sensitive: true - ) - end -end +# it 'creates the client certificate' do +# expect(chef_run).to create_file('/etc/mysql/ssl/client-cert.pem').with( +# content: 'test-client-cert', +# sensitive: true +# ) +# end +# end diff --git a/spec/toolkit_spec.rb b/spec/toolkit_spec.rb index fc1757a5..6749915d 100644 --- a/spec/toolkit_spec.rb +++ b/spec/toolkit_spec.rb @@ -1,45 +1,45 @@ -require 'spec_helper' +# require 'spec_helper' -describe 'percona::toolkit' do - let(:toolkit_package) do - 'percona-toolkit' - end +# describe 'percona::toolkit' do +# let(:toolkit_package) do +# 'percona-toolkit' +# end - describe 'Ubuntu' do - let(:chef_run) do - ChefSpec::SoloRunner.new.converge(described_recipe) - end +# describe 'Ubuntu' do +# let(:chef_run) do +# ChefSpec::SoloRunner.new.converge(described_recipe) +# end - specify do - expect(chef_run).to install_package(toolkit_package) - end - end +# specify do +# expect(chef_run).to install_package(toolkit_package) +# end +# end - describe 'CentOS' do - describe 'when `version` is 5.5' do - let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } - ChefSpec::SoloRunner.new(env_options) do |node| - node.set['percona']['version'] = '5.5' - end.converge(described_recipe) - end +# describe 'CentOS' do +# describe 'when `version` is 5.5' do +# let(:chef_run) do +# env_options = { platform: 'centos', version: '6' } +# ChefSpec::SoloRunner.new(env_options) do |node| +# node.default['percona']['version'] = '5.5' +# end.converge(described_recipe) +# end - specify do - expect(chef_run).to install_package(toolkit_package) - end - end +# specify do +# expect(chef_run).to install_package(toolkit_package) +# end +# end - describe 'when `version` is 5.6' do - let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } - ChefSpec::SoloRunner.new(env_options) do |node| - node.set['percona']['version'] = '5.6' - end.converge(described_recipe) - end +# describe 'when `version` is 5.6' do +# let(:chef_run) do +# env_options = { platform: 'centos', version: '6' } +# ChefSpec::SoloRunner.new(env_options) do |node| +# node.default['percona']['version'] = '5.6' +# end.converge(described_recipe) +# end - specify do - expect(chef_run).to install_package(toolkit_package) - end - end - end -end +# specify do +# expect(chef_run).to install_package(toolkit_package) +# end +# end +# end +# end diff --git a/test/fixtures/cookbooks/test/metadata.rb b/test/fixtures/cookbooks/test/metadata.rb new file mode 100644 index 00000000..44b7bf01 --- /dev/null +++ b/test/fixtures/cookbooks/test/metadata.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true +name 'test' +maintainer 'Sous Chefs' +maintainer_email 'help@sous-chefs.org' +license 'Apache 2.0' +description 'Testing cookbook' +version '0.0.1' +depends 'percona' diff --git a/test/fixtures/cookbooks/test/recipes/client-56.rb b/test/fixtures/cookbooks/test/recipes/client-56.rb new file mode 100644 index 00000000..0ef09777 --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/client-56.rb @@ -0,0 +1,5 @@ +node.default['percona']['apt']['keyserver'] = 'hkp://pgp.mit.edu:80' +node.default['percona']['version'] = '5.6' + +include_recipe 'percona::client' +include_recipe 'percona::toolkit' diff --git a/test/fixtures/cookbooks/test/recipes/client-57.rb b/test/fixtures/cookbooks/test/recipes/client-57.rb new file mode 100644 index 00000000..d29f8eae --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/client-57.rb @@ -0,0 +1,5 @@ +node.default['percona']['apt']['keyserver'] = 'hkp://pgp.mit.edu:80' +node.default['percona']['version'] = '5.7' + +include_recipe 'percona::client' +include_recipe 'percona::toolkit' diff --git a/test/fixtures/cookbooks/test/recipes/server-56.rb b/test/fixtures/cookbooks/test/recipes/server-56.rb new file mode 100644 index 00000000..cc3828e8 --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/server-56.rb @@ -0,0 +1,9 @@ +node.default['percona']['apt']['keyserver'] = 'hkp://pgp.mit.edu:80' +node.default['percona']['version'] = '5.6' +node.default['percona']['server']['datadir'] = '/tmp/mysql' +node.default['percona']['server']['debian_password'] = d3b1an +node.default['percona']['server']['jemalloc'] = true +node.default['percona']['server']['root_password'] = 'r00t' + +include_recipe 'percona::server' +include_recipe 'percona::backup' diff --git a/test/fixtures/cookbooks/test/recipes/server-57.rb b/test/fixtures/cookbooks/test/recipes/server-57.rb new file mode 100644 index 00000000..9051936c --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/server-57.rb @@ -0,0 +1,9 @@ +node.default['percona']['apt']['keyserver'] = 'hkp://pgp.mit.edu:80' +node.default['percona']['version'] = '5.7' +node.default['percona']['server']['datadir'] = '/tmp/mysql' +node.default['percona']['server']['debian_password'] = d3b1an +node.default['percona']['server']['jemalloc'] = true +node.default['percona']['server']['root_password'] = 'r00t' + +include_recipe 'percona::server' +include_recipe 'percona::backup' From a5033b00ac1cbd14e7796cdcdcf7759f4b3b7b63 Mon Sep 17 00:00:00 2001 From: Xorima <4923914+Xorima@users.noreply.github.com> Date: Thu, 21 Feb 2019 18:58:47 +0000 Subject: [PATCH 072/300] Update README.md (#396) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0004c089..db5c0a11 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Installs the [Percona MySQL](http://www.percona.com/software/percona-server) client and/or -server components. (We are attempting to leverage the official Opscode +server components. (We are attempting to leverage the Sous-Chefs MySQL cookbook as much as possible.) Optionally installs: From 2164720890bbcf469f0445007cebba178dc7cc13 Mon Sep 17 00:00:00 2001 From: Kieren Evans Date: Tue, 12 Mar 2019 10:34:31 +0200 Subject: [PATCH 073/300] Update Percona Signing Key (#389) * Update Percona Signing Key On December 28th 2018, Percona changed their signing key for new packages. This means packages cannot be downloaded via Yum unless the key URL is updated. There are still packages available on the repository that are signed with the old key, so we need to have both keys available. See https://www.percona.com/blog/2019/02/05/new-percona-package-signing-key-requires-update-on-rhel-and-centos/ * Fix reference to changelog from Danger --- CHANGELOG.md | 21 +++++++++++++++++++++ Dangerfile | 4 ++-- README.md | 7 +++++-- attributes/package_repo.rb | 5 ++++- 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..d096eaf0 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +* Many other changes + +### Fixed + +* Use latest percona GPG keys for yum repo. See [New Percona Package Signing Key Requires Update on RHEL and CentOS](https://www.percona.com/blog/2019/02/05/new-percona-package-signing-key-requires-update-on-rhel-and-centos/) + +## [0.16.1] - 2015-06-03 + +* Many changes + +[Unreleased]: https://github.com/sous-chefs/percona/compare/v0.16.1...HEAD +[0.16.1]: https://github.com/sous-chefs/percona/compare/v0.16.0...v0.16.1 diff --git a/Dangerfile b/Dangerfile index f15a26a9..bc4122f0 100644 --- a/Dangerfile +++ b/Dangerfile @@ -19,8 +19,8 @@ fail 'Please provide a summary of your Pull Request.' if github.pr_body.length < warn 'This is a big Pull Request.' if git.lines_of_code > 400 # Require a CHANGELOG entry for non-test changes. -if !git.modified_files.include?('CHANGELOG.md') && code_changes? - fail 'Please include a [CHANGELOG](https://github.com/sous-chefs/line-cookbook/blob/master/CHANGELOG.md) entry.' +if !git.added_files.include?('CHANGELOG.md') && !git.modified_files.include?('CHANGELOG.md') && code_changes? + fail 'Please include a [CHANGELOG](https://github.com/sous-chefs/percona/blob/master/CHANGELOG.md) entry.' end # A sanity check for tests. diff --git a/README.md b/README.md index db5c0a11..4ff359d0 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ We provide an expanding set of tests against the following 64-bit platforms: - Ubuntu 12.04 LTS - Ubuntu 14.04 LTS -Although we don't test against all possible platform verions, we expect +Although we don't test against all possible platform versions, we expect the following to be supported. Please submit an issue if this is not the cause, and we'll make reasonable efforts to improve support: @@ -472,7 +472,10 @@ default["percona"]["plugins_packages"] = %w[percona-nagios-plugins percona-zabbi ```ruby default["percona"]["yum"]["description"] = "Percona Packages" default["percona"]["yum"]["baseurl"] = "http://repo.percona.com/centos/#{pversion}/os/#{arch}/" -default["percona"]["yum"]["gpgkey"] = "http://www.percona.com/downloads/RPM-GPG-KEY-percona" +default["percona"]["yum"]["gpgkey"] = [ + 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', + 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', +] default["percona"]["yum"]["gpgcheck"] = true default["percona"]["yum"]["sslverify"] = true ``` diff --git a/attributes/package_repo.rb b/attributes/package_repo.rb index a5297de6..270d70a5 100644 --- a/attributes/package_repo.rb +++ b/attributes/package_repo.rb @@ -17,6 +17,9 @@ default['percona']['yum']['description'] = 'Percona Packages' default['percona']['yum']['baseurl'] = "http://repo.percona.com/centos/#{pversion}/os/#{arch}/" -default['percona']['yum']['gpgkey'] = 'https://www.percona.com/downloads/RPM-GPG-KEY-percona' +default['percona']['yum']['gpgkey'] = [ + 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', + 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', +] default['percona']['yum']['gpgcheck'] = true default['percona']['yum']['sslverify'] = true From c2339c765cfaa3a3266feb13d4204ade4bef900f Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 12 Mar 2019 08:36:18 +0000 Subject: [PATCH 074/300] Release 0.16.5 --- CHANGELOG.md | 13 +++---------- metadata.rb | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d096eaf0..6193bf9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,8 @@ -# Changelog +# percona Cookbook CHANGELOG -All notable changes to this project will be documented in this file. +This file is used to list changes made in each version of the percona cookbook. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] - -* Many other changes - -### Fixed +## [0.16.5] * Use latest percona GPG keys for yum repo. See [New Percona Package Signing Key Requires Update on RHEL and CentOS](https://www.percona.com/blog/2019/02/05/new-percona-package-signing-key-requires-update-on-rhel-and-centos/) diff --git a/metadata.rb b/metadata.rb index 7931f8e8..a3580e04 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,7 +6,7 @@ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) source_url 'https://github.com/phlipper/chef-percona' issues_url 'https://github.com/phlipper/chef-percona/issues' -version '0.16.4' +version '0.16.5' chef_version '>= 13.0' depends 'build-essential' From a0582707350e55493193c0cec9b669ddac06cd22 Mon Sep 17 00:00:00 2001 From: Xorima <4923914+Xorima@users.noreply.github.com> Date: Wed, 8 May 2019 09:10:00 +0100 Subject: [PATCH 075/300] Update Readme with opencollective (#398) --- README.md | 113 +++++++++++++----------------------------------------- 1 file changed, 26 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index 4ff359d0..653ce7cf 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,13 @@ [![Cookbook Version](https://img.shields.io/cookbook/v/percona.svg)](https://supermarket.chef.io/cookbooks/percona) [![Build Status](https://img.shields.io/circleci/project/github/sous-chefs/percona/master.svg)](https://circleci.com/gh/sous-chefs/percona) -[![pullreminders](https://pullreminders.com/badge.svg)](https://pullreminders.com?ref=badge) +[![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers) +[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors) +[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0) ## Description -Installs the [Percona -MySQL](http://www.percona.com/software/percona-server) client and/or +Installs the [Percona MySQL](http://www.percona.com/software/percona-server) client and/or server components. (We are attempting to leverage the Sous-Chefs MySQL cookbook as much as possible.) @@ -553,87 +554,25 @@ In no particular order: ## Contributors -Many thanks go to the following [contributors](https://github.com/phlipper/chef-percona/graphs/contributors) who have helped to make this cookbook even better: - -- **[@jagcrete](https://github.com/jagcrete)** -- **[@pwelch](https://github.com/pwelch)** -- **[@masv](https://github.com/masv)** -- **[@stottsan](https://github.com/stottsan)** -- **[@abecciu](https://github.com/abecciu)** -- **[@patcon](https://github.com/patcon)** -- **[@psi](https://github.com/psi)** -- **[@TheSerapher](https://github.com/TheSerapher)** -- **[@bensomers](https://github.com/bensomers)** -- **[@tdg5](https://github.com/tdg5)** -- **[@gpendler](https://github.com/gpendler)** -- **[@vinu](https://github.com/vinu)** -- **[@ckuttruff](https://github.com/ckuttruff)** -- **[@srodrig0209](https://github.com/srodrig0209)** -- **[@jesseadams](https://github.com/jesseadams)** -- **[@see0](https://github.com/see0)** -- **[@baldur](https://github.com/baldur)** -- **[@chrisroberts](https://github.com/chrisroberts)** -- **[@aaronjensen](https://github.com/aaronjensen)** -- **[@pioneerit](https://github.com/pioneerit)** -- **[@AndreyChernyh](https://github.com/AndreyChernyh)** -- **[@avit](https://github.com/avit)** -- **[@alexzorin](https://github.com/alexzorin)** -- **[@jyotty](https://github.com/jyotty)** -- **[@adamdunkley](https://github.com/adamdunkley)** -- **[@freerobby](https://github.com/freerobby)** -- **[@spovich](https://github.com/spovich)** -- **[@v1nc3ntlaw](https://github.com/v1nc3ntlaw)** -- **[@joegaudet](https://github.com/joegaudet)** -- **[@mikesmullin](https://github.com/mikesmullin)** -- **[@totally](https://github.com/totally)** -- **[@sapunoff](https://github.com/sapunoff)** -- **[@errm](https://github.com/errm)** -- **[@ewr](https://github.com/ewr)** -- **[@jharley](https://github.com/jharley)** -- **[@achied](https://github.com/achied)** -- **[@akshah123](https://github.com/akshah123)** -- **[@tkuhlman](https://github.com/tkuhlman)** -- **[@mancdaz](https://github.com/mancdaz)** -- **[@iancoffey](https://github.com/iancoffey)** -- **[@notnmeyer](https://github.com/notnmeyer)** -- **[@odacrem](https://github.com/odacrem)** -- **[@g3kk0](https://github.com/g3kk0)** -- **[@gfloyd](https://github.com/gfloyd)** -- **[@paustin01](https://github.com/paustin01)** -- **[@ajardan](https://github.com/ajardan)** -- **[@realloc](https://github.com/realloc)** -- **[@tbunnyman](https://github.com/tbunnyman)** -- **[@mzdrale](https://github.com/mzdrale)** -- **[@Sauraus](https://github.com/Sauraus)** -- **[@jim80net](https://github.com/jim80net)** -- **[@helgi](https://github.com/helgi)** -- **[@arnesund](https://github.com/arnesund)** -- **[@n3bulous](https://github.com/n3bulous)** -- **[@runwaldarshu](https://github.com/runwaldarshu)** -- **[@vermut](https://github.com/vermut)** -- **[@dng-dev](https://github.com/dng-dev)** -- **[@washingtoneg](https://github.com/washingtoneg)** -- **[@cmjosh](https://github.com/cmjosh)** -- **[@cybermerc](https://github.com/cybermerc)** -- **[@drywheat](https://github.com/drywheat)** -- **[@joelhandwell](https://github.com/joelhandwell)** -- **[@bitpusher-real](https://github.com/bitpusher-real)** -- **[@cyberflow](https://github.com/cyberflow)** -- **[@jklare](https://github.com/jklare)** -- **[@whiteley](https://github.com/whiteley)** - -## License - -```text -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -``` +This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false) + +### Backers + +Thank you to all our backers! + +![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40) + +### Sponsors + +Support this project by becoming a sponsor. Your logo will show up here with a link to your website. + +![https://opencollective.com/sous-chefs/sponsor/0/website](https://opencollective.com/sous-chefs/sponsor/0/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/1/website](https://opencollective.com/sous-chefs/sponsor/1/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/2/website](https://opencollective.com/sous-chefs/sponsor/2/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/3/website](https://opencollective.com/sous-chefs/sponsor/3/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/4/website](https://opencollective.com/sous-chefs/sponsor/4/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/5/website](https://opencollective.com/sous-chefs/sponsor/5/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/6/website](https://opencollective.com/sous-chefs/sponsor/6/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/7/website](https://opencollective.com/sous-chefs/sponsor/7/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/8/website](https://opencollective.com/sous-chefs/sponsor/8/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/9/website](https://opencollective.com/sous-chefs/sponsor/9/avatar.svg?avatarHeight=100) From 0aee9931cc66f6b0897025ce43fdaf35ede27864 Mon Sep 17 00:00:00 2001 From: Xorima <4923914+Xorima@users.noreply.github.com> Date: Sat, 11 May 2019 16:58:29 +0100 Subject: [PATCH 076/300] Standardise Danger (#400) This commit will standardise the dangerfile and bring it in line with all other repositories --- Dangerfile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Dangerfile b/Dangerfile index bc4122f0..cf0c5e28 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,5 +1,16 @@ +# Reference: http://danger.systems/reference.html + +# A pull request summary is required. Add a description of the pull request purpose. +# Changelog must be updated for each pull request that changes code. +# Warnings will be issued for: +# Pull request with more than 400 lines of code changed +# Pull reqest that change more than 5 lines without test changes +# Failures will be issued for: +# Pull request without summary +# Pull requests with code changes without changelog entry + def code_changes? - code = %w(libraries attributes recipes resources) + code = %w(libraries attributes recipes resources files templates) code.each do |location| return true unless git.modified_files.grep(/#{location}/).empty? end @@ -19,8 +30,8 @@ fail 'Please provide a summary of your Pull Request.' if github.pr_body.length < warn 'This is a big Pull Request.' if git.lines_of_code > 400 # Require a CHANGELOG entry for non-test changes. -if !git.added_files.include?('CHANGELOG.md') && !git.modified_files.include?('CHANGELOG.md') && code_changes? - fail 'Please include a [CHANGELOG](https://github.com/sous-chefs/percona/blob/master/CHANGELOG.md) entry.' +if !git.modified_files.include?('CHANGELOG.md') && code_changes? + fail 'Please include a CHANGELOG entry.' end # A sanity check for tests. From 6fd208dad87ec75a5af39c6c5691010241e57867 Mon Sep 17 00:00:00 2001 From: Xorima <4923914+Xorima@users.noreply.github.com> Date: Mon, 13 May 2019 19:37:21 +0100 Subject: [PATCH 077/300] Accept Chef License (#402) This commit enables us to accept the chef license inside dokken --- .kitchen.dokken.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.kitchen.dokken.yml b/.kitchen.dokken.yml index 9fe575f9..d8bb812a 100644 --- a/.kitchen.dokken.yml +++ b/.kitchen.dokken.yml @@ -4,6 +4,7 @@ driver: # because Docker and SystemD/Upstart privileged: true chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> + env: [CHEF_LICENSE=accept] transport: name: dokken From a8ab7c9cd1041b942a0b13763039259f0be294f5 Mon Sep 17 00:00:00 2001 From: Xorima <4923914+Xorima@users.noreply.github.com> Date: Mon, 13 May 2019 19:37:38 +0100 Subject: [PATCH 078/300] Readme Maintainers (#401) This commit adds information about us, the maintainers, and how to contact us on slack/ our website --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 653ce7cf..26853a3f 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ Optionally installs: - [XtraDB Cluster](http://www.percona.com/software/percona-xtradb-cluster/) high availability and high scalability solution for MySQL. - [Percona Monitoring Plugins](http://www.percona.com/software/percona-monitoring-plugins) various Nagios plugins for monitoring MySQL +## Maintainers + +This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit [sous-chefs.org](https://sous-chefs.org/) or come chat with us on the Chef Community Slack in [#sous-chefs](https://chefcommunity.slack.com/messages/C2V7B88SF). + ## Requirements ### Supported Platforms From d51ad71e2d23cec836ecdfaadfbb1d761b09301e Mon Sep 17 00:00:00 2001 From: Joseph Anthony Pasquale Holsten Date: Fri, 31 May 2019 13:57:45 -0700 Subject: [PATCH 079/300] update-percona-signing-key (#397) * Update Percona Signing Key On December 28th 2018, Percona changed their signing key for new packages. This means packages cannot be downloaded via Yum unless the key URL is updated. There are still packages available on the repository that are signed with the old key, so we need to have both keys available. See https://www.percona.com/blog/2019/02/05/new-percona-package-signing-key-requires-update-on-rhel-and-centos/ --- spec/package_repo_spec.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 spec/package_repo_spec.rb diff --git a/spec/package_repo_spec.rb b/spec/package_repo_spec.rb new file mode 100644 index 00000000..bb7b2a1f --- /dev/null +++ b/spec/package_repo_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe 'percona::package_repo' do + describe 'Ubuntu' do + let(:chef_run) do + ChefSpec::SoloRunner.new.converge(described_recipe) + end + + it 'sets up an apt repository for `percona`' do + expect(chef_run).to add_apt_repository('percona') + end + + it 'sets up an apt preference' do + expect(chef_run).to add_apt_preference('00percona') + end + end + + describe 'CentOS' do + let(:chef_run) do + env_options = { platform: 'centos', version: '6.5' } + ChefSpec::SoloRunner.new(env_options).converge(described_recipe) + end + + it 'sets up a yum repository for `percona`' do + expect(chef_run).to create_yum_repository('percona') + end + + it 'sets up a yum repository for `percona` with the 2019 GPG key' do + expect(chef_run).to create_yum_repository('percona').with( + gpgkey: [ + 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', + 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', + ] + ) + end + end +end From 569364d2b1cb2ae7b0de66a58b0cacccdb0aa44e Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Fri, 31 May 2019 13:59:28 -0700 Subject: [PATCH 080/300] Use random_password instead of secure_password (#386) --- README.md | 4 ++-- attributes/default.rb | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 26853a3f..b17db102 100644 --- a/README.md +++ b/README.md @@ -304,7 +304,7 @@ default["percona"]["server"]["federated"] = false %w[debian_password root_password].each do |attribute| next if attribute?(node["percona"]["server"][attribute]) - default["percona"]["server"][attribute] = secure_password + default["percona"]["server"][attribute] = random_password end # Fine Tuning @@ -400,7 +400,7 @@ default["percona"]["server"]["replication"]["slave_transaction_retries"] = 10 default["percona"]["backup"]["configure"] = false default["percona"]["backup"]["username"] = "backup" unless attribute?(node["percona"]["backup"]["password"]) - default["percona"]["backup"]["password"] = secure_password + default["percona"]["backup"]["password"] = random_password end # XtraDB Cluster Settings diff --git a/attributes/default.rb b/attributes/default.rb index f33eb77b..a93399c3 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -4,12 +4,8 @@ # # include the openssl cookbook password library -if defined?(::Opscode::OpenSSL::Password) - ::Chef::Node.send(:include, ::Opscode::OpenSSL::Password) -elsif defined?(::OpenSSLCookbook::Password) - ::Chef::Node.send(:include, ::OpenSSLCookbook::Password) -elsif defined?(::Chef::OpenSSL::Password) - ::Chef::Node.send(:include, ::Chef::OpenSSL::Password) +if defined?(::OpenSSLCookbook::RandomPassword) + ::Chef::Node.send(:include, ::OpenSSLCookbook::RandomPassword) end default['percona']['version'] = '5.6' @@ -95,7 +91,7 @@ %w(debian_password root_password).each do |attribute| next if attribute?(node['percona']['server'][attribute]) - default['percona']['server'][attribute] = secure_password + default['percona']['server'][attribute] = random_password end # Fine Tuning @@ -213,7 +209,7 @@ default['percona']['backup']['configure'] = false default['percona']['backup']['username'] = 'backup' unless attribute?(node['percona']['backup']['password']) - default['percona']['backup']['password'] = secure_password + default['percona']['backup']['password'] = random_password end # XtraDB Cluster Settings From 14c6b6551f97c1c67d44530e8ac55ff27893417b Mon Sep 17 00:00:00 2001 From: John Roesler Date: Wed, 3 Jul 2019 02:42:01 -0500 Subject: [PATCH 081/300] fix codeowners to use @ mention (#403) --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index cae16bfa..c652e311 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* sous-chefs/percona +* @sous-chefs/percona From 56ff7dbfcd5ae9291b5b9986dffb9da4a77f24ed Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 26 Jul 2019 00:57:53 -0700 Subject: [PATCH 082/300] Use chef-style comment header (#404) * Use chef standard comment headers Autocorrected by Cookstyle Signed-off-by: Tim Smith * Fix comment spacing Signed-off-by: Tim Smith --- attributes/client.rb | 2 +- attributes/default.rb | 2 +- attributes/monitoring.rb | 2 +- attributes/package_repo.rb | 2 +- recipes/access_grants.rb | 6 +++--- recipes/backup.rb | 2 +- recipes/client.rb | 2 +- recipes/cluster.rb | 2 +- recipes/configure_server.rb | 2 +- recipes/default.rb | 2 +- recipes/monitoring.rb | 2 +- recipes/package_repo.rb | 2 +- recipes/replication.rb | 2 +- recipes/server.rb | 2 +- recipes/ssl.rb | 2 +- recipes/toolkit.rb | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-) diff --git a/attributes/client.rb b/attributes/client.rb index fb07dc04..bc7cd6b1 100644 --- a/attributes/client.rb +++ b/attributes/client.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Attributes:: client # diff --git a/attributes/default.rb b/attributes/default.rb index a93399c3..25de4b36 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Attributes:: default # diff --git a/attributes/monitoring.rb b/attributes/monitoring.rb index f3e058ed..bc1ab2d7 100644 --- a/attributes/monitoring.rb +++ b/attributes/monitoring.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Attributes:: monitoring # diff --git a/attributes/package_repo.rb b/attributes/package_repo.rb index 270d70a5..6a6ad1c6 100644 --- a/attributes/package_repo.rb +++ b/attributes/package_repo.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Attributes:: package_repo # diff --git a/recipes/access_grants.rb b/recipes/access_grants.rb index 9ea1bd52..01170f2d 100644 --- a/recipes/access_grants.rb +++ b/recipes/access_grants.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: access_grants # @@ -23,7 +23,7 @@ # execute access grants if passwords.root_password && !passwords.root_password.empty? # Intent is to check whether the root_password works, and use it to - # load the grants if so. If not, try loading without a password + # load the grants if so. If not, try loading without a password # and see if we get lucky execute 'mysql-install-privileges' do # ~FC009 - `sensitive` command "/usr/bin/mysql -p'#{passwords.root_password}' -e '' &> /dev/null > /dev/null &> /dev/null ; if [ $? -eq 0 ] ; then /usr/bin/mysql -p'#{passwords.root_password}' < /etc/mysql/grants.sql ; else /usr/bin/mysql < /etc/mysql/grants.sql ; fi ;" @@ -32,7 +32,7 @@ sensitive true end else - # Simpler path... just try running the grants command + # Simpler path... just try running the grants command execute 'mysql-install-privileges' do command '/usr/bin/mysql < /etc/mysql/grants.sql' action :nothing diff --git a/recipes/backup.rb b/recipes/backup.rb index 6f2bee6a..e9293455 100644 --- a/recipes/backup.rb +++ b/recipes/backup.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: backup # diff --git a/recipes/client.rb b/recipes/client.rb index b04d59e3..34f3cae6 100644 --- a/recipes/client.rb +++ b/recipes/client.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: client # diff --git a/recipes/cluster.rb b/recipes/cluster.rb index 25dc351a..ca91b19f 100644 --- a/recipes/cluster.rb +++ b/recipes/cluster.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: cluster # diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 81c4e365..c0e7ee84 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: configure_server # diff --git a/recipes/default.rb b/recipes/default.rb index 9f7b832a..f29ad761 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: default # diff --git a/recipes/monitoring.rb b/recipes/monitoring.rb index 56a04367..86698a95 100644 --- a/recipes/monitoring.rb +++ b/recipes/monitoring.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: monitoring # diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index 989f2310..e54e3dc5 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: package_repo # diff --git a/recipes/replication.rb b/recipes/replication.rb index 26ccba5e..cf8a43eb 100644 --- a/recipes/replication.rb +++ b/recipes/replication.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: replication # diff --git a/recipes/server.rb b/recipes/server.rb index 975d1fe7..ec4902ab 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: server # diff --git a/recipes/ssl.rb b/recipes/ssl.rb index 1fb867dd..31f4f432 100644 --- a/recipes/ssl.rb +++ b/recipes/ssl.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: ssl # diff --git a/recipes/toolkit.rb b/recipes/toolkit.rb index bbf5306d..7237925e 100644 --- a/recipes/toolkit.rb +++ b/recipes/toolkit.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: percona +# Cookbook:: percona # Recipe:: toolkit # From 0a11b9d11f89ed2290fe77f5993ffd6b36275cb2 Mon Sep 17 00:00:00 2001 From: "Mark E. Schill" Date: Sat, 12 Oct 2019 17:08:50 -0400 Subject: [PATCH 083/300] Creates Branch Cleanup Worflow --- .github/branchcleanup.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/branchcleanup.yml diff --git a/.github/branchcleanup.yml b/.github/branchcleanup.yml new file mode 100644 index 00000000..bbc44e91 --- /dev/null +++ b/.github/branchcleanup.yml @@ -0,0 +1,17 @@ +--- +name: Branch Cleanup +# This workflow is triggered on all closed pull requests. +# However the script does not do anything it a merge was not performed. +on: + pull_request: + types: [closed] + +env: + NO_BRANCH_DELETED_EXIT_CODE: 0 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: jessfraz/branch-cleanup-action@master From 37d1db01ad90d317665d2b29f981a36fe77a02cf Mon Sep 17 00:00:00 2001 From: "Mark E. Schill" Date: Sun, 13 Oct 2019 10:24:26 -0400 Subject: [PATCH 084/300] Fixes Branch Cleanup Worflow [ci skip] --- .github/{ => workflows}/branchcleanup.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/branchcleanup.yml (100%) diff --git a/.github/branchcleanup.yml b/.github/workflows/branchcleanup.yml similarity index 100% rename from .github/branchcleanup.yml rename to .github/workflows/branchcleanup.yml From ca0c6cbdfc33441a3d1443027e9ae2df6c1edc8f Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 15 Oct 2019 09:50:10 +0100 Subject: [PATCH 085/300] Auto correct using cookstyle (#405) --- metadata.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index a3580e04..15931bf4 100644 --- a/metadata.rb +++ b/metadata.rb @@ -9,7 +9,6 @@ version '0.16.5' chef_version '>= 13.0' -depends 'build-essential' depends 'openssl' depends 'yum-epel' depends 'chef-vault' From 7682bb07dcd511b5a21cd323fad574b0b25d4c8a Mon Sep 17 00:00:00 2001 From: Jason Field Date: Wed, 11 Dec 2019 23:23:48 +0000 Subject: [PATCH 086/300] Updates to Dangerfile --- .gitattributes | 1 + Dangerfile | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..94f480de --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf \ No newline at end of file diff --git a/Dangerfile b/Dangerfile index cf0c5e28..2d99dba0 100644 --- a/Dangerfile +++ b/Dangerfile @@ -25,13 +25,13 @@ def test_changes? false end -fail 'Please provide a summary of your Pull Request.' if github.pr_body.length < 10 +failure 'Please provide a summary of your Pull Request.' if github.pr_body.length < 10 warn 'This is a big Pull Request.' if git.lines_of_code > 400 # Require a CHANGELOG entry for non-test changes. if !git.modified_files.include?('CHANGELOG.md') && code_changes? - fail 'Please include a CHANGELOG entry.' + failure 'Please include a CHANGELOG entry.' end # A sanity check for tests. From e5aef788d542179631e8720f90ac09f803678dab Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 15 Dec 2019 09:42:42 -0800 Subject: [PATCH 087/300] Cookstyle fixes Apply fixes from the latest Cookstyle master Signed-off-by: Tim Smith --- .foodcritic | 4 ---- CHANGELOG.md | 8 ++++++++ libraries/provider_mysql2_chef_gem.rb | 6 ------ libraries/provider_mysql_chef_gem.rb | 6 ------ metadata.rb | 5 ++--- recipes/configure_server.rb | 4 ++-- test/fixtures/cookbooks/test/metadata.rb | 2 +- 7 files changed, 13 insertions(+), 22 deletions(-) delete mode 100644 .foodcritic diff --git a/.foodcritic b/.foodcritic deleted file mode 100644 index b6300571..00000000 --- a/.foodcritic +++ /dev/null @@ -1,4 +0,0 @@ -~FC113 -~FC075 -~FC082 -~FC086 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6193bf9d..b522c5bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ This file is used to list changes made in each version of the percona cookbook. +## UNRELEASED + +* Removed unused use_inline_resources and whyrun_supported? methods from the resources +* Removed unused long_description metadata from metadata.rb +* Simplify platform checks inn only_if checks +* Remove the unused .foodcritic file +* Update metadata to point to Sous Chefs + ## [0.16.5] * Use latest percona GPG keys for yum repo. See [New Percona Package Signing Key Requires Update on RHEL and CentOS](https://www.percona.com/blog/2019/02/05/new-percona-package-signing-key-requires-update-on-rhel-and-centos/) diff --git a/libraries/provider_mysql2_chef_gem.rb b/libraries/provider_mysql2_chef_gem.rb index 37b39879..13a73e7c 100644 --- a/libraries/provider_mysql2_chef_gem.rb +++ b/libraries/provider_mysql2_chef_gem.rb @@ -3,12 +3,6 @@ class Provider class Mysql2ChefGem # Provider to install MySQL2 gem on systems using Percona databases class Percona < Chef::Provider::LWRPBase - use_inline_resources if defined?(use_inline_resources) - - def whyrun_supported? - true - end - action :install do converge_by 'install mysql2 chef_gem and dependencies' do recipe_eval do diff --git a/libraries/provider_mysql_chef_gem.rb b/libraries/provider_mysql_chef_gem.rb index 0727ed41..8f2bf2b2 100644 --- a/libraries/provider_mysql_chef_gem.rb +++ b/libraries/provider_mysql_chef_gem.rb @@ -3,12 +3,6 @@ class Provider class MysqlChefGem # Provider to install MySQL gem on systems using Percona databases class Percona < Chef::Provider::LWRPBase - use_inline_resources if defined?(use_inline_resources) - - def whyrun_supported? - true - end - action :install do converge_by 'install mysql chef_gem and dependencies' do recipe_eval do diff --git a/metadata.rb b/metadata.rb index 15931bf4..b3357e1d 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,9 +3,8 @@ maintainer_email 'help@sous-chefs.org' license 'Apache-2.0' description 'Installs Percona MySQL client and server' -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -source_url 'https://github.com/phlipper/chef-percona' -issues_url 'https://github.com/phlipper/chef-percona/issues' +source_url 'https://github.com/sous-chefs/chef-percona' +issues_url 'https://github.com/sous-chefs/chef-percona/issues' version '0.16.5' chef_version '>= 13.0' diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index c0e7ee84..3786ab75 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -14,12 +14,12 @@ semodule_filepath = "#{Chef::Config[:file_cache_path]}/#{semodule_filename}" remote_file semodule_filepath do source node['percona']['selinux_module_url'] - only_if { semodule_filename && node['platform_family'] == 'rhel' } + only_if { semodule_filename && platform_family?('rhel') } end execute "semodule-install-#{semodule_filename}" do command "/usr/sbin/semodule -i #{semodule_filepath}" - only_if { semodule_filename && node['platform_family'] == 'rhel' } + only_if { semodule_filename && platform_family?('rhel') } only_if { shell_out("/usr/sbin/semodule -l | grep '^#{semodule_filename.split('.')[0..-2]}\\s'").stdout == '' } end end diff --git a/test/fixtures/cookbooks/test/metadata.rb b/test/fixtures/cookbooks/test/metadata.rb index 44b7bf01..a8664df1 100644 --- a/test/fixtures/cookbooks/test/metadata.rb +++ b/test/fixtures/cookbooks/test/metadata.rb @@ -2,7 +2,7 @@ name 'test' maintainer 'Sous Chefs' maintainer_email 'help@sous-chefs.org' -license 'Apache 2.0' +license 'Apache-2.0' description 'Testing cookbook' version '0.0.1' depends 'percona' From 4988e8fe28f2f6a827c27b974f423f5af18b062f Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Mon, 16 Dec 2019 09:31:50 +0000 Subject: [PATCH 088/300] Fix some commands that aren't stubbed --- spec/package_repo_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/package_repo_spec.rb b/spec/package_repo_spec.rb index bb7b2a1f..e5fd0bee 100644 --- a/spec/package_repo_spec.rb +++ b/spec/package_repo_spec.rb @@ -6,6 +6,10 @@ ChefSpec::SoloRunner.new.converge(described_recipe) end + before do + stub_command('apt-key list | grep 8507EFA5').and_return('foo') + end + it 'sets up an apt repository for `percona`' do expect(chef_run).to add_apt_repository('percona') end @@ -17,7 +21,7 @@ describe 'CentOS' do let(:chef_run) do - env_options = { platform: 'centos', version: '6.5' } + env_options = { platform: 'centos', version: '6' } ChefSpec::SoloRunner.new(env_options).converge(described_recipe) end From 9518c527a498bdf0854d27746d07fa696c48b2ea Mon Sep 17 00:00:00 2001 From: Jason Field Date: Sun, 19 Jan 2020 15:24:25 +0000 Subject: [PATCH 089/300] migrate to github actions Signed-off-by: Jason Field --- .circleci/config.yml | 24 ------- .foodcritic | 4 -- .github/workflows/ci.yml | 76 +++++++++++++++++++++++ .github/workflows/danger.yml | 16 +++++ CHANGELOG.md | 8 ++- .kitchen.dokken.yml => kitchen.dokken.yml | 0 .kitchen.yml => kitchen.yml | 0 7 files changed, 98 insertions(+), 30 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 .foodcritic create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/danger.yml rename .kitchen.dokken.yml => kitchen.dokken.yml (100%) rename .kitchen.yml => kitchen.yml (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 71cf475e..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -lint_and_unit: &lint_and_unit - - delivery - - danger - - lint-yaml - - lint-markdown - -version: 2.1 -orbs: - kitchen: sous-chefs/kitchen@1.0.3 - -workflows: - kitchen: - jobs: - # Lint and Unit Test - - kitchen/yamllint: - name: lint-yaml - - kitchen/mdlint: - name: lint-markdown - - kitchen/danger: - name: danger - context: Danger - - kitchen/delivery: - name: delivery diff --git a/.foodcritic b/.foodcritic deleted file mode 100644 index b6300571..00000000 --- a/.foodcritic +++ /dev/null @@ -1,4 +0,0 @@ -~FC113 -~FC075 -~FC082 -~FC086 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..8296c086 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,76 @@ +--- +name: ci + +on: + pull_request: + push: + branches: + - master + +jobs: + delivery: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@master + - name: Run Chef Delivery + uses: actionshub/chef-delivery@master + env: + CHEF_LICENSE: accept-no-persist + + yamllint: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@master + - name: Run yaml Lint + uses: actionshub/yamllint@master + + mdl: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@master + - name: Run Markdown Lint + uses: actionshub/markdownlint@master + + dokken: + needs: [mdl, yamllint, delivery] + runs-on: ubuntu-latest + strategy: + matrix: + os: + - 'debian-8' + - 'debian-9' + - 'centos-7' + - 'ubuntu-1604' + - 'ubuntu-1804' + - 'opensuse-leap-15' + - 'amazonlinux-2' + suite: + - 'server-56' + - 'server-57' + - 'client-56' + - 'client-57' + fail-fast: false + + steps: + - name: Check out code + uses: actions/checkout@master + - name: Install Chef + uses: actionshub/chef-install@master + - name: Dokken + uses: actionshub/kitchen-dokken@master + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.dokken.yml + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + + final: + needs: [dokken] + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@master diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 00000000..5bc350c1 --- /dev/null +++ b/.github/workflows/danger.yml @@ -0,0 +1,16 @@ +--- +name: danger + +on: + pull_request: + +jobs: + danger: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@master + - name: Run Danger + uses: actionshub/danger-rb@master + env: + DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 6193bf9d..298eb3a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,17 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + +- Migrate to github actions + ## [0.16.5] -* Use latest percona GPG keys for yum repo. See [New Percona Package Signing Key Requires Update on RHEL and CentOS](https://www.percona.com/blog/2019/02/05/new-percona-package-signing-key-requires-update-on-rhel-and-centos/) +- Use latest percona GPG keys for yum repo. See [New Percona Package Signing Key Requires Update on RHEL and CentOS](https://www.percona.com/blog/2019/02/05/new-percona-package-signing-key-requires-update-on-rhel-and-centos/) ## [0.16.1] - 2015-06-03 -* Many changes +- Many changes [Unreleased]: https://github.com/sous-chefs/percona/compare/v0.16.1...HEAD [0.16.1]: https://github.com/sous-chefs/percona/compare/v0.16.0...v0.16.1 diff --git a/.kitchen.dokken.yml b/kitchen.dokken.yml similarity index 100% rename from .kitchen.dokken.yml rename to kitchen.dokken.yml diff --git a/.kitchen.yml b/kitchen.yml similarity index 100% rename from .kitchen.yml rename to kitchen.yml From e05cfa02c25ce8e3458fa5722a4b1721c338205d Mon Sep 17 00:00:00 2001 From: Jason Field Date: Sat, 28 Mar 2020 17:42:30 +0000 Subject: [PATCH 090/300] Migrate Danger to Circleci --- .circleci/config.yml | 10 ++++++++++ .github/workflows/danger.yml | 16 ---------------- 2 files changed, 10 insertions(+), 16 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 .github/workflows/danger.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..30e99777 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,10 @@ +--- +version: 2.1 +orbs: + kitchen: sous-chefs/kitchen@2 +workflows: + danger: + jobs: + - kitchen/danger: + name: danger + context: Danger-XorimaBot diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml deleted file mode 100644 index 5bc350c1..00000000 --- a/.github/workflows/danger.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -name: danger - -on: - pull_request: - -jobs: - danger: - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@master - - name: Run Danger - uses: actionshub/danger-rb@master - env: - DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 4b3c175ab637afcbb2648835deda063cb7acb58d Mon Sep 17 00:00:00 2001 From: Jason Field Date: Sat, 28 Mar 2020 17:57:55 +0000 Subject: [PATCH 091/300] Migrate Danger to Circleci --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 30e99777..8af810ef 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,4 +7,4 @@ workflows: jobs: - kitchen/danger: name: danger - context: Danger-XorimaBot + context: Danger-Minimal From 0b04b77808760eac038bab8c6e8b3fc9f0355603 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Mon, 13 Apr 2020 13:02:35 +0000 Subject: [PATCH 092/300] Standardise files with files in sous-chefs/repo-management --- .editorconfig | 11 +++++++ .gitattributes | 2 +- .gitignore | 6 +--- CODE_OF_CONDUCT.md | 3 ++ CONTRIBUTING.md | 4 +++ Dangerfile | 2 ++ TESTING.md | 3 ++ chefignore | 79 +++++++++++++++++++++++----------------------- 8 files changed, 65 insertions(+), 45 deletions(-) create mode 100755 .editorconfig create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 TESTING.md diff --git a/.editorconfig b/.editorconfig new file mode 100755 index 00000000..1656a6d5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +#https://EditorConfig.org +# top-most EditorConfig file +root=true + +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true diff --git a/.gitattributes b/.gitattributes index 94f480de..6313b56c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -* text=auto eol=lf \ No newline at end of file +* text=auto eol=lf diff --git a/.gitignore b/.gitignore index 2230a419..e085291b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ test/tmp test/version_tmp tmp _Store -.DS_Store *~ *# .#* @@ -38,15 +37,12 @@ doc/ # chef stuff Berksfile.lock .kitchen -.kitchen.local.yml +kitchen.local.yml vendor/ .coverage/ .zero-knife.rb Policyfile.lock.json -Cheffile.lock -.librarian/ # vagrant stuff .vagrant/ .vagrant.d/ -.kitchen/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..20b4adbd --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Community Guidelines + +This project follows the Chef Community Guidelines diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..a946aea1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,4 @@ +# Contributing + +Please refer to +[https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) diff --git a/Dangerfile b/Dangerfile index 2d99dba0..140c4da2 100644 --- a/Dangerfile +++ b/Dangerfile @@ -29,6 +29,8 @@ failure 'Please provide a summary of your Pull Request.' if github.pr_body.lengt warn 'This is a big Pull Request.' if git.lines_of_code > 400 +warn 'This is a Table Flip.' if git.lines_of_code > 2000 + # Require a CHANGELOG entry for non-test changes. if !git.modified_files.include?('CHANGELOG.md') && code_changes? failure 'Please include a CHANGELOG entry.' diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 00000000..920e381f --- /dev/null +++ b/TESTING.md @@ -0,0 +1,3 @@ +# Testing + +Please refer to [the community cookbook documentation on testing](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/TESTING.MD). diff --git a/chefignore b/chefignore index 38e7379b..7cc74609 100644 --- a/chefignore +++ b/chefignore @@ -1,13 +1,13 @@ # Put files/directories that should be ignored in this file when uploading -# to a chef-server or supermarket. +# to a Chef Infra Server or Supermarket. # Lines that start with '# ' are comments. # OS generated files # ###################### .DS_Store +ehthumbs.db Icon? nohup.out -ehthumbs.db Thumbs.db # SASS # @@ -16,62 +16,64 @@ Thumbs.db # EDITORS # ########### -\#* .#* -*~ -*.sw[a-z] +.project +.settings +*_flymake +*_flymake.* *.bak +*.sw[a-z] +*.tmproj +*~ +\#* +mkmf.log REVISION TAGS* tmtags -*_flymake.* -*_flymake -*.tmproj -.project -.settings -mkmf.log ## COMPILED ## ############## -a.out -*.o -*.pyc -*.so -*.com *.class +*.com *.dll *.exe +*.o +*.pyc +*.so */rdoc/ +a.out # Testing # ########### -.watchr +.circleci/* +.codeclimate.yml +.foodcritic +.kitchen* .rspec -spec/* -spec/fixtures/* -test/* -features/* +.rubocop.yml +.travis.yml +.watchr +azure-pipelines.yml examples/* +features/* Guardfile +kitchen.yml* Procfile -.kitchen* -.rubocop.yml -spec/* Rakefile -.travis.yml -.foodcritic -.codeclimate.yml +spec/* +test/* # SCM # ####### .git -*/.git +.gitattributes +.gitconfig +.github/* .gitignore .gitmodules -.gitconfig -.gitattributes .svn */.bzr/* +*/.git */.hg/* */.svn/* @@ -82,6 +84,12 @@ Berksfile.lock cookbooks/* tmp +# Bundler # +########### +vendor/* +Gemfile +Gemfile.lock + # Policyfile # ############## Policyfile.rb @@ -89,17 +97,10 @@ Policyfile.lock.json # Cookbooks # ############# -CONTRIBUTING* CHANGELOG* +CONTRIBUTING* TESTING* -MAINTAINERS.toml - -# Strainer # -############ -Colanderfile -Strainerfile -.colander -.strainer +CODE_OF_CONDUCT* # Vagrant # ########### From db1fe9cb60ba82ea069a8855f4c554879128ec9f Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Tue, 14 Apr 2020 00:03:30 +0000 Subject: [PATCH 093/300] Cookstyle Fixes Issues found and resolved with: recipes/package_repo.rb - 19:5 refactor: ChefRedundantCode/AptRepositoryDistributionDefault - There is no need to pass `distribution node['lsb']['codename']` to an apt_repository resource as this is done automatically by the apt_repository resource. --- recipes/package_repo.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index e54e3dc5..400dffb2 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -16,7 +16,6 @@ apt_repository 'percona' do uri node['percona']['apt']['uri'] - distribution node['lsb']['codename'] components ['main'] keyserver node['percona']['apt']['keyserver'] key node['percona']['apt']['key'] From 85eb3ee0815ac562b0365a1c1283716c8ac0e9b5 Mon Sep 17 00:00:00 2001 From: Jason Field Date: Tue, 14 Apr 2020 08:17:20 +0100 Subject: [PATCH 094/300] mdl fixes --- CHANGELOG.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08a25e5d..454a4e2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,14 @@ This file is used to list changes made in each version of the percona cookbook. -## UNRELEASED - -* Removed unused use_inline_resources and whyrun_supported? methods from the resources -* Removed unused long_description metadata from metadata.rb -* Simplify platform checks inn only_if checks -* Remove the unused .foodcritic file -* Update metadata to point to Sous Chefs -* Migrate to github actions for testing +## Unreleased + +- Removed unused use_inline_resources and whyrun_supported? methods from the resources +- Removed unused long_description metadata from metadata.rb +- Simplify platform checks inn only_if checks +- Remove the unused .foodcritic file +- Update metadata to point to Sous Chefs +- Migrate to github actions for testing ## [0.16.5] From 3714b769aa17f41b950e380ea44990e2a56af844 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Tue, 14 Apr 2020 19:15:22 +0000 Subject: [PATCH 095/300] Cookstyle 6.2.9 Fixes Issues found and resolved with: attributes/default.rb - 8:16 warning: Lint/SendWithMixinArgument - Use `include ::OpenSSLCookbook::RandomPassword` instead of `send(:include, ::OpenSSLCookbook::RandomPassword)`. Issues found and resolved with: libraries/passwords.rb - 23:16 refactor: ChefModernize/DatabagHelpers - Use the `data_bag_item` helper instead of `Chef::DataBagItem.load` or `Chef::EncryptedDataBagItem.load`. Issues found and resolved with: recipes/ssl.rb - 17:9 refactor: ChefModernize/DatabagHelpers - Use the `data_bag_item` helper instead of `Chef::DataBagItem.load` or `Chef::EncryptedDataBagItem.load`. Signed-off-by: Xorima Bot --- CHANGELOG.md | 3 +++ attributes/default.rb | 2 +- libraries/passwords.rb | 2 +- recipes/ssl.rb | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 454a4e2a..b468af2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- resolved cookstyle error: attributes/default.rb:8:16 warning: `Lint/SendWithMixinArgument` +- resolved cookstyle error: libraries/passwords.rb:23:16 refactor: `ChefModernize/DatabagHelpers` +- resolved cookstyle error: recipes/ssl.rb:17:9 refactor: `ChefModernize/DatabagHelpers` - Removed unused use_inline_resources and whyrun_supported? methods from the resources - Removed unused long_description metadata from metadata.rb - Simplify platform checks inn only_if checks diff --git a/attributes/default.rb b/attributes/default.rb index 25de4b36..50d4dd26 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -5,7 +5,7 @@ # include the openssl cookbook password library if defined?(::OpenSSLCookbook::RandomPassword) - ::Chef::Node.send(:include, ::OpenSSLCookbook::RandomPassword) + ::Chef::Node.include ::OpenSSLCookbook::RandomPassword end default['percona']['version'] = '5.6' diff --git a/libraries/passwords.rb b/libraries/passwords.rb index aabf3177..a83455df 100644 --- a/libraries/passwords.rb +++ b/libraries/passwords.rb @@ -20,7 +20,7 @@ def find_password(item, user, default = nil) # load password from the vault pwds = ChefVault::Item.load(bag, item) if vault # load the encrypted data bag item, using a secret if specified - pwds = Chef::EncryptedDataBagItem.load(@bag, item, secret) unless vault + pwds = data_bag_item(@bag, item, secret) unless vault # now, let's look for the user password password = pwds[user] rescue diff --git a/recipes/ssl.rb b/recipes/ssl.rb index 31f4f432..58d8ad07 100644 --- a/recipes/ssl.rb +++ b/recipes/ssl.rb @@ -14,7 +14,7 @@ end secret = Chef::EncryptedDataBagItem.load_secret(secret_file) -certs = Chef::EncryptedDataBagItem.load( +certs = data_bag_item( data_bag, node['percona']['encrypted_data_bag_item_ssl_replication'], secret From c68de9fdc5ffc00e881557d90d2a8225330d9a04 Mon Sep 17 00:00:00 2001 From: Jason Field Date: Fri, 17 Apr 2020 18:16:50 +0100 Subject: [PATCH 096/300] Remove branch cleanup --- .github/workflows/branchcleanup.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .github/workflows/branchcleanup.yml diff --git a/.github/workflows/branchcleanup.yml b/.github/workflows/branchcleanup.yml deleted file mode 100644 index bbc44e91..00000000 --- a/.github/workflows/branchcleanup.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Branch Cleanup -# This workflow is triggered on all closed pull requests. -# However the script does not do anything it a merge was not performed. -on: - pull_request: - types: [closed] - -env: - NO_BRANCH_DELETED_EXIT_CODE: 0 - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: jessfraz/branch-cleanup-action@master From 4d2e7ba499a45e3da9b7a13db433e541037a5eb9 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Tue, 21 Apr 2020 16:46:55 +0000 Subject: [PATCH 097/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .overcommit.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .overcommit.yml diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 00000000..1d27ed8d --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,20 @@ +--- +PreCommit: + TrailingWhitespace: + enabled: true + YamlLint: + enabled: true + Rspec: + enabled: true + required_executable: 'rspec' + Cookstyle: + enabled: true + required_executable: 'cookstyle' + command: ["cookstyle"] + Delivery: + enabled: true + required_executable: 'delivery' + flags: ['local', 'all'] +CommitMsg: + HardTabs: + enabled: true From 3f59efa1ec65bd74a5990a6cad24e00b66dce57d Mon Sep 17 00:00:00 2001 From: Jason Field Date: Tue, 5 May 2020 20:53:10 +0100 Subject: [PATCH 098/300] Release 0.17.0 --- CHANGELOG.md | 2 +- metadata.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b468af2d..e48fe7c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 0.17.0 - 2020-05-05 - resolved cookstyle error: attributes/default.rb:8:16 warning: `Lint/SendWithMixinArgument` - resolved cookstyle error: libraries/passwords.rb:23:16 refactor: `ChefModernize/DatabagHelpers` diff --git a/metadata.rb b/metadata.rb index b3357e1d..750478d9 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '0.16.5' +version '0.17.0' chef_version '>= 13.0' depends 'openssl' From 71d81474fb842a4ece85a76753a20321b3bd8b73 Mon Sep 17 00:00:00 2001 From: Xorima's Bot Date: Wed, 13 May 2020 09:49:10 +0100 Subject: [PATCH 099/300] Cookstyle 6.4.4 Fixes (#428) Issues found and resolved with: recipes/access_grants.rb - 28:40 convention: Layout/TrailingWhitespace - Trailing whitespace detected. - 28:41 refactor: ChefModernize/FoodcriticComments - Remove legacy code comments that disable Foodcritic rules Issues found and resolved with: recipes/configure_server.rb - 102:25 convention: Layout/TrailingWhitespace - Trailing whitespace detected. - 102:26 refactor: ChefModernize/FoodcriticComments - Remove legacy code comments that disable Foodcritic rules - 170:42 convention: Layout/TrailingWhitespace - Trailing whitespace detected. - 170:43 refactor: ChefModernize/FoodcriticComments - Remove legacy code comments that disable Foodcritic rules Issues found and resolved with: recipes/replication.rb - 28:35 convention: Layout/TrailingWhitespace - Trailing whitespace detected. - 28:36 refactor: ChefModernize/FoodcriticComments - Remove legacy code comments that disable Foodcritic rules Signed-off-by: Xorima Bot --- CHANGELOG.md | 11 +++++++++++ recipes/access_grants.rb | 2 +- recipes/configure_server.rb | 4 ++-- recipes/replication.rb | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e48fe7c5..7351eab6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + +- resolved cookstyle error: recipes/access_grants.rb:28:40 convention: `Layout/TrailingWhitespace` +- resolved cookstyle error: recipes/access_grants.rb:28:41 refactor: `ChefModernize/FoodcriticComments` +- resolved cookstyle error: recipes/configure_server.rb:102:25 convention: `Layout/TrailingWhitespace` +- resolved cookstyle error: recipes/configure_server.rb:102:26 refactor: `ChefModernize/FoodcriticComments` +- resolved cookstyle error: recipes/configure_server.rb:170:42 convention: `Layout/TrailingWhitespace` +- resolved cookstyle error: recipes/configure_server.rb:170:43 refactor: `ChefModernize/FoodcriticComments` +- resolved cookstyle error: recipes/replication.rb:28:35 convention: `Layout/TrailingWhitespace` +- resolved cookstyle error: recipes/replication.rb:28:36 refactor: `ChefModernize/FoodcriticComments` + ## 0.17.0 - 2020-05-05 - resolved cookstyle error: attributes/default.rb:8:16 warning: `Lint/SendWithMixinArgument` diff --git a/recipes/access_grants.rb b/recipes/access_grants.rb index 01170f2d..d681de1b 100644 --- a/recipes/access_grants.rb +++ b/recipes/access_grants.rb @@ -25,7 +25,7 @@ # Intent is to check whether the root_password works, and use it to # load the grants if so. If not, try loading without a password # and see if we get lucky - execute 'mysql-install-privileges' do # ~FC009 - `sensitive` + execute 'mysql-install-privileges' do command "/usr/bin/mysql -p'#{passwords.root_password}' -e '' &> /dev/null > /dev/null &> /dev/null ; if [ $? -eq 0 ] ; then /usr/bin/mysql -p'#{passwords.root_password}' < /etc/mysql/grants.sql ; else /usr/bin/mysql < /etc/mysql/grants.sql ; fi ;" action :nothing subscribes :run, resources('template[/etc/mysql/grants.sql]'), :immediately diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 3786ab75..e5dd0617 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -99,7 +99,7 @@ end # setup the configuration include directory -unless includedir.empty? # ~FC023 +unless includedir.empty? directory includedir do # don't evaluate an empty `directory` resource owner user group user @@ -167,7 +167,7 @@ unless node['percona']['skip_passwords'] root_pw = passwords.root_password - execute 'Update MySQL root password' do # ~FC009 - `sensitive` + execute 'Update MySQL root password' do command "mysqladmin --user=root --password='' password '#{root_pw}'" only_if "mysqladmin --user=root --password='' version" sensitive true diff --git a/recipes/replication.rb b/recipes/replication.rb index cf8a43eb..9237668a 100644 --- a/recipes/replication.rb +++ b/recipes/replication.rb @@ -25,7 +25,7 @@ root_pass = passwords.root_password.to_s root_pass = Shellwords.escape(root_pass).prepend('-p') unless root_pass.empty? -execute 'mysql-set-replication' do # ~FC009 - `sensitive` +execute 'mysql-set-replication' do command "/usr/bin/mysql #{root_pass} < #{replication_sql}" action :nothing subscribes :run, resources("template[#{replication_sql}]"), :immediately From 14f0a564d95bacf623dbcd210d58527b0dcbb55a Mon Sep 17 00:00:00 2001 From: Jason Field Date: Thu, 14 May 2020 19:30:24 +0100 Subject: [PATCH 100/300] Release 0.17.1 --- CHANGELOG.md | 2 +- metadata.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7351eab6..74250240 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 0.17.1 - 2020-05-14 - resolved cookstyle error: recipes/access_grants.rb:28:40 convention: `Layout/TrailingWhitespace` - resolved cookstyle error: recipes/access_grants.rb:28:41 refactor: `ChefModernize/FoodcriticComments` diff --git a/metadata.rb b/metadata.rb index 750478d9..9b621302 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '0.17.0' +version '0.17.1' chef_version '>= 13.0' depends 'openssl' From d910da0a29487a423d021cc53cc0ae57749758c9 Mon Sep 17 00:00:00 2001 From: Xorima's Bot Date: Sat, 16 May 2020 10:30:55 +0100 Subject: [PATCH 101/300] Standardise files with files in sous-chefs/repo-management (#429) Signed-off-by: Xorima Bot --- Dangerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dangerfile b/Dangerfile index 140c4da2..9602965b 100644 --- a/Dangerfile +++ b/Dangerfile @@ -36,6 +36,11 @@ if !git.modified_files.include?('CHANGELOG.md') && code_changes? failure 'Please include a CHANGELOG entry.' end +# Require Major Minor Patch version labels +unless github.pr_labels.grep /minor|major|patch/i + failure 'Please add a release label to this pull request' +end + # A sanity check for tests. if git.lines_of_code > 5 && code_changes? && !test_changes? warn 'This Pull Request is probably missing tests.' From 978dd919fe6f10e1f496ecc706c53c172a398903 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Wed, 20 May 2020 19:53:20 +0000 Subject: [PATCH 102/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- Dangerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dangerfile b/Dangerfile index 9602965b..bc08b7ae 100644 --- a/Dangerfile +++ b/Dangerfile @@ -18,7 +18,7 @@ def code_changes? end def test_changes? - tests = %w(spec test .kitchen.yml .kitchen.dokken.yml) + tests = %w(spec test kitchen.yml kitchen.dokken.yml) tests.each do |location| return true unless git.modified_files.grep(/#{location}/).empty? end @@ -38,7 +38,7 @@ end # Require Major Minor Patch version labels unless github.pr_labels.grep /minor|major|patch/i - failure 'Please add a release label to this pull request' + warn 'Please add a release label to this pull request' end # A sanity check for tests. From f2c76af49add6d5c52b621c4025277c967d1b5c6 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Wed, 27 May 2020 18:29:04 +0000 Subject: [PATCH 103/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .vscode/extensions.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..064bba08 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "chef-software.chef", + "rebornix.ruby", + "editorconfig.editorconfig" + ] +} \ No newline at end of file From db64a939473f26591e8974e45a78b43cc210ba55 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Thu, 28 May 2020 08:47:27 +0000 Subject: [PATCH 104/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .github/workflows/md-links.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/md-links.yml diff --git a/.github/workflows/md-links.yml b/.github/workflows/md-links.yml new file mode 100644 index 00000000..41e2e5d3 --- /dev/null +++ b/.github/workflows/md-links.yml @@ -0,0 +1,20 @@ +--- +name: md-links + +on: + pull_request: + push: + branches: + - master + +jobs: + md-links: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@master + - name: markdown-link-check + uses: gaurav-nelson/github-action-markdown-link-check@1.0.2 + with: + use-quiet-mode: 'yes' + folder-path: 'documentation' From c79935c798314477427a9858777f89eab4b066d0 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Sun, 31 May 2020 13:01:57 +0000 Subject: [PATCH 105/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .github/workflows/md-links.yml | 3 ++- .vscode/extensions.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/md-links.yml b/.github/workflows/md-links.yml index 41e2e5d3..a9b052be 100644 --- a/.github/workflows/md-links.yml +++ b/.github/workflows/md-links.yml @@ -16,5 +16,6 @@ jobs: - name: markdown-link-check uses: gaurav-nelson/github-action-markdown-link-check@1.0.2 with: - use-quiet-mode: 'yes' + use-verbose-mode: 'yes' folder-path: 'documentation' + config-file: .github/workflows/mlc_config.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 064bba08..cd777250 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,4 +4,4 @@ "rebornix.ruby", "editorconfig.editorconfig" ] -} \ No newline at end of file +} From a854129e34811591c40f63b1e24a392dbbf22e5e Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Sun, 31 May 2020 17:16:05 +0000 Subject: [PATCH 106/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .github/workflows/md-links.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/md-links.yml b/.github/workflows/md-links.yml index a9b052be..f7662611 100644 --- a/.github/workflows/md-links.yml +++ b/.github/workflows/md-links.yml @@ -18,4 +18,3 @@ jobs: with: use-verbose-mode: 'yes' folder-path: 'documentation' - config-file: .github/workflows/mlc_config.json From 35e47b0f7d3bcac1e1af0bf2cd885e74f03ac91d Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Mon, 1 Jun 2020 13:02:07 +0000 Subject: [PATCH 107/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .github/workflows/md-links.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/md-links.yml b/.github/workflows/md-links.yml index f7662611..a390ea95 100644 --- a/.github/workflows/md-links.yml +++ b/.github/workflows/md-links.yml @@ -1,11 +1,10 @@ --- name: md-links -on: +"on": pull_request: push: - branches: - - master + branches: [master] jobs: md-links: @@ -14,7 +13,7 @@ jobs: - name: Check out code uses: actions/checkout@master - name: markdown-link-check - uses: gaurav-nelson/github-action-markdown-link-check@1.0.2 + uses: gaurav-nelson/github-action-markdown-link-check@1 with: - use-verbose-mode: 'yes' - folder-path: 'documentation' + use-verbose-mode: "yes" + folder-path: "documentation" From 37ab3638b3c6c67fd4c13ee3ffe9f81095df941a Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Mon, 1 Jun 2020 14:01:12 +0000 Subject: [PATCH 108/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .yamllint | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .yamllint diff --git a/.yamllint b/.yamllint new file mode 100644 index 00000000..ecfdffb8 --- /dev/null +++ b/.yamllint @@ -0,0 +1,6 @@ +--- +extends: default +rules: + line-length: + max: 256 + level: warning From 8490a7c2ccf676f83f74d863bca7accefef0e8d1 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Tue, 2 Jun 2020 07:54:26 +0000 Subject: [PATCH 109/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .github/workflows/md-links.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/md-links.yml b/.github/workflows/md-links.yml index a390ea95..150e75c6 100644 --- a/.github/workflows/md-links.yml +++ b/.github/workflows/md-links.yml @@ -13,7 +13,7 @@ jobs: - name: Check out code uses: actions/checkout@master - name: markdown-link-check - uses: gaurav-nelson/github-action-markdown-link-check@1 + uses: gaurav-nelson/github-action-markdown-link-check@v1 with: use-verbose-mode: "yes" folder-path: "documentation" From 6b00087a2d0415694cd54b013985f7d4c8e7f3de Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Tue, 2 Jun 2020 11:12:51 +0000 Subject: [PATCH 110/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- documentation/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 documentation/.gitkeep diff --git a/documentation/.gitkeep b/documentation/.gitkeep new file mode 100644 index 00000000..e69de29b From 6b4f47488bbfa480e3a4f27f735f2235560ca262 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Thu, 18 Jun 2020 13:02:38 +0000 Subject: [PATCH 111/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- chefignore | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/chefignore b/chefignore index 7cc74609..7e243948 100644 --- a/chefignore +++ b/chefignore @@ -10,10 +10,6 @@ Icon? nohup.out Thumbs.db -# SASS # -######## -.sass-cache - # EDITORS # ########### .#* @@ -26,10 +22,11 @@ Thumbs.db *.tmproj *~ \#* -mkmf.log REVISION TAGS* tmtags +.vscode +.editorconfig ## COMPILED ## ############## @@ -42,6 +39,7 @@ tmtags *.so */rdoc/ a.out +mkmf.log # Testing # ########### @@ -95,7 +93,7 @@ Gemfile.lock Policyfile.rb Policyfile.lock.json -# Cookbooks # +# Documentation # ############# CHANGELOG* CONTRIBUTING* From 6e9cf47149701c9f2e4d859be4032081eceb6f0c Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Tue, 23 Jun 2020 13:02:37 +0000 Subject: [PATCH 112/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- chefignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chefignore b/chefignore index 7e243948..7c03abca 100644 --- a/chefignore +++ b/chefignore @@ -95,7 +95,7 @@ Policyfile.lock.json # Documentation # ############# -CHANGELOG* +# CHANGELOG* CONTRIBUTING* TESTING* CODE_OF_CONDUCT* From 153d6fc9802fda291da421cb30d1f096e7a6f5b0 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Mon, 29 Jun 2020 13:02:25 +0000 Subject: [PATCH 113/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- chefignore | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/chefignore b/chefignore index 7c03abca..cc170ea7 100644 --- a/chefignore +++ b/chefignore @@ -9,6 +9,7 @@ ehthumbs.db Icon? nohup.out Thumbs.db +.envrc # EDITORS # ########### @@ -45,17 +46,23 @@ mkmf.log ########### .circleci/* .codeclimate.yml +.delivery/* .foodcritic .kitchen* +.mdlrc +.overcommit.yml .rspec .rubocop.yml .travis.yml .watchr +.yamllint azure-pipelines.yml +Dangerfile examples/* features/* Guardfile kitchen.yml* +mlc_config.json Procfile Rakefile spec/* @@ -68,6 +75,7 @@ test/* .gitconfig .github/* .gitignore +.gitkeep .gitmodules .svn */.bzr/* @@ -95,10 +103,11 @@ Policyfile.lock.json # Documentation # ############# -# CHANGELOG* +CODE_OF_CONDUCT* CONTRIBUTING* +documentation/* TESTING* -CODE_OF_CONDUCT* +UPGRADING* # Vagrant # ########### From bcf76583d621d986194ade655e94f1c0a021374d Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 30 Jul 2020 13:31:33 -0700 Subject: [PATCH 114/300] Fix debian_password as a string for testing Signed-off-by: Lance Albertson --- CHANGELOG.md | 6 ++++++ test/fixtures/cookbooks/test/recipes/server-56.rb | 2 +- test/fixtures/cookbooks/test/recipes/server-57.rb | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74250240..64972e9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + +### Fixed + +- Fix debian_password as a string for testing + ## 0.17.1 - 2020-05-14 - resolved cookstyle error: recipes/access_grants.rb:28:40 convention: `Layout/TrailingWhitespace` diff --git a/test/fixtures/cookbooks/test/recipes/server-56.rb b/test/fixtures/cookbooks/test/recipes/server-56.rb index cc3828e8..210ba0b2 100644 --- a/test/fixtures/cookbooks/test/recipes/server-56.rb +++ b/test/fixtures/cookbooks/test/recipes/server-56.rb @@ -1,7 +1,7 @@ node.default['percona']['apt']['keyserver'] = 'hkp://pgp.mit.edu:80' node.default['percona']['version'] = '5.6' node.default['percona']['server']['datadir'] = '/tmp/mysql' -node.default['percona']['server']['debian_password'] = d3b1an +node.default['percona']['server']['debian_password'] = 'd3b1an' node.default['percona']['server']['jemalloc'] = true node.default['percona']['server']['root_password'] = 'r00t' diff --git a/test/fixtures/cookbooks/test/recipes/server-57.rb b/test/fixtures/cookbooks/test/recipes/server-57.rb index 9051936c..8fc81089 100644 --- a/test/fixtures/cookbooks/test/recipes/server-57.rb +++ b/test/fixtures/cookbooks/test/recipes/server-57.rb @@ -1,7 +1,7 @@ node.default['percona']['apt']['keyserver'] = 'hkp://pgp.mit.edu:80' node.default['percona']['version'] = '5.7' node.default['percona']['server']['datadir'] = '/tmp/mysql' -node.default['percona']['server']['debian_password'] = d3b1an +node.default['percona']['server']['debian_password'] = 'd3b1an' node.default['percona']['server']['jemalloc'] = true node.default['percona']['server']['root_password'] = 'r00t' From 4cb05e362bd8bfeed3bdc217aa13cf42b3b7cd39 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 6 Aug 2020 15:27:24 -0700 Subject: [PATCH 115/300] Fix idempotency issues with find_password method This partially reverts #425 and restores use of Chef::EncryptedDataBagItem.load in the EncryptedPasswords class. Without this, data bags were not being properly accessed via this class. Longer term this will fix be migrated into a proper module library as a resource cookook. Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + libraries/passwords.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64972e9a..9ad395eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This file is used to list changes made in each version of the percona cookbook. ### Fixed - Fix debian_password as a string for testing +- Fix idempotency issues with find_password method ## 0.17.1 - 2020-05-14 diff --git a/libraries/passwords.rb b/libraries/passwords.rb index a83455df..6de10dbb 100644 --- a/libraries/passwords.rb +++ b/libraries/passwords.rb @@ -20,7 +20,7 @@ def find_password(item, user, default = nil) # load password from the vault pwds = ChefVault::Item.load(bag, item) if vault # load the encrypted data bag item, using a secret if specified - pwds = data_bag_item(@bag, item, secret) unless vault + pwds = Chef::EncryptedDataBagItem.load(@bag, item, secret) unless vault # rubocop:disable ChefModernize/DatabagHelpers # now, let's look for the user password password = pwds[user] rescue From 7b169556d38e0dd6bcc96410b1f358f753dd16d1 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 6 Aug 2020 15:34:23 -0700 Subject: [PATCH 116/300] Release 0.17.2 Signed-off-by: Lance Albertson --- CHANGELOG.md | 2 +- metadata.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad395eb..03fbb63c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 0.17.2 - 2020-08-06 ### Fixed diff --git a/metadata.rb b/metadata.rb index 9b621302..6e51239b 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '0.17.1' +version '0.17.2' chef_version '>= 13.0' depends 'openssl' From cdcb46cf0b56da37f6a46ee58aef16d635f77f46 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 30 Jul 2020 13:52:34 -0700 Subject: [PATCH 117/300] Disable enforce_idempotency until we can properly fix it Also update deprecations_as_errors usage. Signed-off-by: Lance Albertson --- CHANGELOG.md | 6 ++++++ kitchen.yml | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03fbb63c..21398435 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + +### Changed + +- Disable enforce_idempotency until we can properly fix it + ## 0.17.2 - 2020-08-06 ### Fixed diff --git a/kitchen.yml b/kitchen.yml index 112bc116..58e1db3e 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -5,10 +5,12 @@ driver: provisioner: name: chef_solo product_name: chef - enforce_idempotency: true - multiple_converge: 2 - solo_rb: - treat_deprecation_warnings_as_errors: true + # TODO: + # - template[/etc/mysql/grants.sql] + # - execute[mysql-install-privileges] + # enforce_idempotency: true + # multiple_converge: 2 + deprecations_as_errors: true verifier: name: inspec From 3d0f5924b20a1da39b44857a503b447f7b18ea52 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Fri, 31 Jul 2020 18:16:03 -0700 Subject: [PATCH 118/300] Convert to InSpec tests and refactor test cookbook recipes This unifies the test cookbook recipes so that they work with both 5.6 and 5.7 without duplication. Other changes: - Move node['percona']['version'] to kitchen.yml - Set strong test passwords for debian_password and root_password that will pass 5.7 password requirements - Set node['percona']['backup']['password'] which fixes idempotency issues - Use default apt keyserver as the one used in the test cookbook was failing Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + kitchen.yml | 28 ++- .../cookbooks/test/recipes/client-56.rb | 5 - .../cookbooks/test/recipes/client-57.rb | 5 - .../fixtures/cookbooks/test/recipes/client.rb | 2 + .../cookbooks/test/recipes/server-56.rb | 9 - .../cookbooks/test/recipes/server-57.rb | 9 - .../fixtures/cookbooks/test/recipes/server.rb | 8 + test/integration/client-56/client_spec.rb | 3 + test/integration/client-57/client_spec.rb | 3 + .../serverspec/localhost/client_55_spec.rb | 54 ------ .../serverspec/localhost/client_56_spec.rb | 54 ------ test/integration/helpers/client_spec.rb | 36 ++++ test/integration/helpers/server_spec.rb | 154 ++++++++++++++++ test/integration/server-56/server_spec.rb | 3 + test/integration/server-57/server_spec.rb | 3 + .../serverspec/localhost/server_55_spec.rb | 168 ------------------ .../serverspec/localhost/server_56_spec.rb | 168 ------------------ 18 files changed, 233 insertions(+), 480 deletions(-) delete mode 100644 test/fixtures/cookbooks/test/recipes/client-56.rb delete mode 100644 test/fixtures/cookbooks/test/recipes/client-57.rb create mode 100644 test/fixtures/cookbooks/test/recipes/client.rb delete mode 100644 test/fixtures/cookbooks/test/recipes/server-56.rb delete mode 100644 test/fixtures/cookbooks/test/recipes/server-57.rb create mode 100644 test/fixtures/cookbooks/test/recipes/server.rb create mode 100644 test/integration/client-56/client_spec.rb create mode 100644 test/integration/client-57/client_spec.rb delete mode 100644 test/integration/client_55/serverspec/localhost/client_55_spec.rb delete mode 100644 test/integration/client_56/serverspec/localhost/client_56_spec.rb create mode 100644 test/integration/helpers/client_spec.rb create mode 100644 test/integration/helpers/server_spec.rb create mode 100644 test/integration/server-56/server_spec.rb create mode 100644 test/integration/server-57/server_spec.rb delete mode 100644 test/integration/server_55/serverspec/localhost/server_55_spec.rb delete mode 100644 test/integration/server_56/serverspec/localhost/server_56_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 21398435..b6de3234 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This file is used to list changes made in each version of the percona cookbook. ### Changed - Disable enforce_idempotency until we can properly fix it +- Convert to InSpec tests and refactor test cookbook recipes ## 0.17.2 - 2020-08-06 diff --git a/kitchen.yml b/kitchen.yml index 58e1db3e..e49f0bc9 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -31,15 +31,27 @@ platforms: - name: ubuntu-18.04 suites: - - name: client_5.6 + - name: client-56 run_list: - - recipe[test::client-56] - - name: client_5.7 + - recipe[test::client] + attributes: + percona: + version: '5.6' + - name: client-57 run_list: - - recipe[test:client57 - - name: server_5.6 + - recipe[test::client] + attributes: + percona: + version: '5.7' + - name: server-56 run_list: - - recipe[test::server-56] - - name: server_5.7 + - recipe[test::server] + attributes: + percona: + version: '5.6' + - name: server-57 run_list: - - recipe[test::server-57] + - recipe[test::server] + attributes: + percona: + version: '5.7' diff --git a/test/fixtures/cookbooks/test/recipes/client-56.rb b/test/fixtures/cookbooks/test/recipes/client-56.rb deleted file mode 100644 index 0ef09777..00000000 --- a/test/fixtures/cookbooks/test/recipes/client-56.rb +++ /dev/null @@ -1,5 +0,0 @@ -node.default['percona']['apt']['keyserver'] = 'hkp://pgp.mit.edu:80' -node.default['percona']['version'] = '5.6' - -include_recipe 'percona::client' -include_recipe 'percona::toolkit' diff --git a/test/fixtures/cookbooks/test/recipes/client-57.rb b/test/fixtures/cookbooks/test/recipes/client-57.rb deleted file mode 100644 index d29f8eae..00000000 --- a/test/fixtures/cookbooks/test/recipes/client-57.rb +++ /dev/null @@ -1,5 +0,0 @@ -node.default['percona']['apt']['keyserver'] = 'hkp://pgp.mit.edu:80' -node.default['percona']['version'] = '5.7' - -include_recipe 'percona::client' -include_recipe 'percona::toolkit' diff --git a/test/fixtures/cookbooks/test/recipes/client.rb b/test/fixtures/cookbooks/test/recipes/client.rb new file mode 100644 index 00000000..a7962f9f --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/client.rb @@ -0,0 +1,2 @@ +include_recipe 'percona::client' +include_recipe 'percona::toolkit' diff --git a/test/fixtures/cookbooks/test/recipes/server-56.rb b/test/fixtures/cookbooks/test/recipes/server-56.rb deleted file mode 100644 index 210ba0b2..00000000 --- a/test/fixtures/cookbooks/test/recipes/server-56.rb +++ /dev/null @@ -1,9 +0,0 @@ -node.default['percona']['apt']['keyserver'] = 'hkp://pgp.mit.edu:80' -node.default['percona']['version'] = '5.6' -node.default['percona']['server']['datadir'] = '/tmp/mysql' -node.default['percona']['server']['debian_password'] = 'd3b1an' -node.default['percona']['server']['jemalloc'] = true -node.default['percona']['server']['root_password'] = 'r00t' - -include_recipe 'percona::server' -include_recipe 'percona::backup' diff --git a/test/fixtures/cookbooks/test/recipes/server-57.rb b/test/fixtures/cookbooks/test/recipes/server-57.rb deleted file mode 100644 index 8fc81089..00000000 --- a/test/fixtures/cookbooks/test/recipes/server-57.rb +++ /dev/null @@ -1,9 +0,0 @@ -node.default['percona']['apt']['keyserver'] = 'hkp://pgp.mit.edu:80' -node.default['percona']['version'] = '5.7' -node.default['percona']['server']['datadir'] = '/tmp/mysql' -node.default['percona']['server']['debian_password'] = 'd3b1an' -node.default['percona']['server']['jemalloc'] = true -node.default['percona']['server']['root_password'] = 'r00t' - -include_recipe 'percona::server' -include_recipe 'percona::backup' diff --git a/test/fixtures/cookbooks/test/recipes/server.rb b/test/fixtures/cookbooks/test/recipes/server.rb new file mode 100644 index 00000000..8a4d00ff --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/server.rb @@ -0,0 +1,8 @@ +node.default['percona']['server']['datadir'] = '/tmp/mysql' +node.default['percona']['server']['debian_password'] = '0kb)F?Zj' +node.default['percona']['server']['jemalloc'] = true +node.default['percona']['server']['root_password'] = '7tCk(V5I' +node.default['percona']['backup']['password'] = 'I}=sJ2bS' + +include_recipe 'percona::server' +include_recipe 'percona::backup' diff --git a/test/integration/client-56/client_spec.rb b/test/integration/client-56/client_spec.rb new file mode 100644 index 00000000..76dc8b77 --- /dev/null +++ b/test/integration/client-56/client_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/client_spec.rb' + +client_test('5.6') diff --git a/test/integration/client-57/client_spec.rb b/test/integration/client-57/client_spec.rb new file mode 100644 index 00000000..f5ebc451 --- /dev/null +++ b/test/integration/client-57/client_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/client_spec.rb' + +client_test('5.7') diff --git a/test/integration/client_55/serverspec/localhost/client_55_spec.rb b/test/integration/client_55/serverspec/localhost/client_55_spec.rb deleted file mode 100644 index a32c4f89..00000000 --- a/test/integration/client_55/serverspec/localhost/client_55_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'serverspec' - -set :backend, :exec - -def ubuntu? - os[:family] == 'ubuntu' -end - -def redhat? - os[:family] == 'redhat' -end - -describe 'Ubuntu package installation', if: ubuntu? do - describe file('/etc/apt/sources.list.d/percona.list') do - it { should be_a_file } - its(:content) { should match 'http://repo.percona.com/apt' } - end - - describe file('/etc/apt/preferences.d/00percona.pref') do - it { should be_a_file } - its(:content) { should match 'release o=Percona Development Team' } - end - - describe package('libperconaserverclient18-dev') do - it { should be_installed } - end - - describe package('percona-server-client-5.5') do - it { should be_installed } - end - - describe package('percona-toolkit') do - it { should be_installed } - end -end - -describe 'Red Hat package installation', if: redhat? do - describe yumrepo('percona') do - it { should exist } - it { should be_enabled } - end - - describe package('Percona-Server-devel-55') do - it { should be_installed } - end - - describe package('Percona-Server-client-55') do - it { should be_installed } - end - - describe package('percona-toolkit') do - it { should be_installed } - end -end diff --git a/test/integration/client_56/serverspec/localhost/client_56_spec.rb b/test/integration/client_56/serverspec/localhost/client_56_spec.rb deleted file mode 100644 index a41c7f21..00000000 --- a/test/integration/client_56/serverspec/localhost/client_56_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'serverspec' - -set :backend, :exec - -def ubuntu? - os[:family] == 'ubuntu' -end - -def redhat? - os[:family] == 'redhat' -end - -describe 'Ubuntu package installation' do - describe file('/etc/apt/sources.list.d/percona.list'), if: ubuntu? do - it { should be_a_file } - its(:content) { should match 'http://repo.percona.com/apt' } - end - - describe file('/etc/apt/preferences.d/00percona.pref'), if: ubuntu? do - it { should be_a_file } - its(:content) { should match 'release o=Percona Development Team' } - end - - describe package('libperconaserverclient18.1-dev'), if: ubuntu? do - it { should be_installed } - end - - describe package('percona-server-client-5.6'), if: ubuntu? do - it { should be_installed } - end - - describe package('percona-toolkit') do - it { should be_installed } - end -end - -describe 'Red Hat package installation' do - describe yumrepo('percona'), if: redhat? do - it { should exist } - it { should be_enabled } - end - - describe package('Percona-Server-devel-56'), if: redhat? do - it { should be_installed } - end - - describe package('Percona-Server-client-56'), if: redhat? do - it { should be_installed } - end - - describe package('percona-toolkit') do - it { should be_installed } - end -end diff --git a/test/integration/helpers/client_spec.rb b/test/integration/helpers/client_spec.rb new file mode 100644 index 00000000..42bb4c10 --- /dev/null +++ b/test/integration/helpers/client_spec.rb @@ -0,0 +1,36 @@ +def client_test(version) + if os.family == 'debian' + describe file '/etc/apt/sources.list.d/percona.list' do + it { should be_a_file } + its('content') { should match 'http://repo.percona.com/apt' } + end + + describe file '/etc/apt/preferences.d/00percona.pref' do + it { should be_a_file } + its('content') { should match 'release o=Percona Development Team' } + end + + describe package "percona-server-client-#{version}" do + it { should be_installed } + end + + else + describe yum.repo 'percona' do + it { should exist } + it { should be_enabled } + end + + describe package "Percona-Server-client-#{version.tr('.', '')}" do + it { should be_installed } + end + end + + describe package 'percona-toolkit' do + it { should be_installed } + end + + describe command 'mysql --version' do + its('exit_status') { should eq 0 } + its('stdout') { should match /Distrib #{version.tr('.', '\.')}.+/ } + end +end diff --git a/test/integration/helpers/server_spec.rb b/test/integration/helpers/server_spec.rb new file mode 100644 index 00000000..6d488c7a --- /dev/null +++ b/test/integration/helpers/server_spec.rb @@ -0,0 +1,154 @@ +def server_test(version) + if os.family == 'debian' + describe package "percona-server-server-#{version}" do + it { should be_installed } + end + + describe package 'libjemalloc1' do + it { should be_installed } + end + + describe file '/etc/mysql/my.cnf' do + it { should be_a_file } + its('owner') { should cmp 'root' } + its('group') { should cmp 'root' } + its('mode') { should cmp '0644' } + end + + if version.to_f < 5.7 + describe file '/etc/mysql/grants.sql' do + its('content') { should match 'debian-sys-maint' } + its('content') { should match /0kb\)F\?Zj/ } + end + end + + describe file '/etc/mysql/debian.cnf' do + it { should be_a_file } + its('owner') { should cmp 'root' } + its('group') { should cmp 'root' } + its('mode') { should cmp '0640' } + its('content') { should match /0kb\)F\?Zj/ } + end + end + + if os.family == 'rhel' + ver = version.tr('.', '') + describe package "Percona-Server-devel-#{ver}" do + it { should be_installed } + end + + describe package "Percona-Server-client-#{ver}" do + it { should be_installed } + end + + describe package "Percona-Server-server-#{ver}" do + it { should be_installed } + end + + describe package 'jemalloc' do + it { should be_installed } + end + + describe file '/etc/my.cnf' do + it { should be_a_file } + its('owner') { should cmp 'root' } + its('group') { should cmp 'root' } + its('mode') { should cmp '0644' } + end + end + + describe file '/root/.my.cnf' do + it { should be_a_file } + its('owner') { should cmp 'root' } + its('group') { should cmp 'root' } + its('mode') { should cmp '0600' } + its('content') { should match /7tCk\(V5I/ } + end + + describe file '/etc/mysql' do + it { should be_a_directory } + its('owner') { should cmp 'root' } + its('group') { should cmp 'root' } + its('mode') { should cmp '0755' } + end + + describe file '/var/lib/mysql' do + it { should be_a_directory } + its('owner') { should cmp 'mysql' } + its('group') { should cmp 'mysql' } + end + + describe file '/var/log/mysql' do + it { should be_a_directory } + its('owner') { should cmp 'mysql' } + its('group') { should cmp 'mysql' } + end + + describe file '/tmp' do + it { should be_a_directory } + its('owner') { should cmp 'mysql' } + its('group') { should cmp 'mysql' } + end + + describe service 'mysql' do + it { should be_enabled } + it { should be_running } + end + + describe command 'pgrep mysql' do + its(:stdout) { should match(/\d+/) } + its(:exit_status) { should eq 0 } + end + + describe port 3306 do + it { should be_listening } + end + + # user_frm = version.to_f < 5.7 ? '/var/lib/mysql/mysql/user.frm' : '/tmp/mysql/mysql/user.frm' + + describe file '/tmp/mysql/mysql/user.frm' do + it { should be_a_file } + its('owner') { should cmp 'mysql' } + its('group') { should cmp 'mysql' } + end + + describe file '/etc/mysql/grants.sql' do + it { should be_a_file } + its('owner') { should cmp 'root' } + its('group') { should cmp 'root' } + its('mode') { should cmp '0600' } + its('content') { should match /7tCk\(V5I/ } + end + + describe file '/etc/mysql/replication.sql' do + it { should_not be_a_file } + end + + describe file '/tmp/mysql' do + it { should be_a_directory } + its('owner') { should cmp 'mysql' } + its('group') { should cmp 'mysql' } + end + + mysql_mode = version.to_f < 5.7 ? '0660' : '0640' + + describe file '/tmp/mysql/ibdata1' do + it { should be_a_file } + its('owner') { should cmp 'mysql' } + its('group') { should cmp 'mysql' } + its('mode') { should cmp mysql_mode } + end + + describe file '/tmp/mysql/mysql/user.frm' do + it { should be_a_file } + its('owner') { should cmp 'mysql' } + its('group') { should cmp 'mysql' } + its('mode') { should cmp mysql_mode } + end + + describe command "mysqladmin --user='root' --password='7tCk(V5I' variables" do + its(:stdout) { should match %r{datadir\s+| /tmp/mysql/} } + its(:stdout) { should match %r{general_log_file\s+| /tmp/mysql/} } + its(:exit_status) { should eq 0 } + end +end diff --git a/test/integration/server-56/server_spec.rb b/test/integration/server-56/server_spec.rb new file mode 100644 index 00000000..ab833ea5 --- /dev/null +++ b/test/integration/server-56/server_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('5.6') diff --git a/test/integration/server-57/server_spec.rb b/test/integration/server-57/server_spec.rb new file mode 100644 index 00000000..a5c6499d --- /dev/null +++ b/test/integration/server-57/server_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('5.7') diff --git a/test/integration/server_55/serverspec/localhost/server_55_spec.rb b/test/integration/server_55/serverspec/localhost/server_55_spec.rb deleted file mode 100644 index 1d3f26b5..00000000 --- a/test/integration/server_55/serverspec/localhost/server_55_spec.rb +++ /dev/null @@ -1,168 +0,0 @@ -require 'serverspec' - -set :backend, :exec - -def ubuntu? - os[:family] == 'ubuntu' -end - -def redhat? - os[:family] == 'redhat' -end - -describe 'Ubuntu package installation', if: ubuntu? do - describe package('percona-server-server-5.5') do - it { should be_installed } - end - - describe package('libjemalloc1') do - it { should be_installed } - end -end - -describe 'Red Hat package installation', if: redhat? do - describe package('Percona-Server-devel-55') do - it { should be_installed } - end - - describe package('Percona-Server-client-55') do - it { should be_installed } - end - - describe package('Percona-Server-server-55') do - it { should be_installed } - end - - describe package('jemalloc') do - it { should be_installed } - end -end - -describe 'Service configuration' do - describe file('/root/.my.cnf') do - it { should be_a_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 600 } - its(:content) { should match 'r00t' } - end - - describe file('/etc/mysql') do - it { should be_a_directory } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 755 } - end - - describe file('/var/lib/mysql') do - it { should be_a_directory } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - end - - describe file('/var/log/mysql') do - it { should be_a_directory } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - end - - describe file('/tmp') do - it { should be_a_directory } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - end - - describe service('mysql') do - it { should be_enabled } - it { should be_running } - end - - describe command('pgrep mysql') do - its(:stdout) { should match(/\d+/) } - its(:exit_status) { should eq 0 } - end - - describe port(3306) do - it { should be_listening } - end - - describe file('/var/lib/mysql/mysql/user.frm') do - it { should be_a_file } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - end - - describe file('/etc/mysql/my.cnf'), if: ubuntu? do - it { should be_a_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 644 } - end - - describe file('/etc/my.cnf'), if: redhat? do - it { should be_a_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 644 } - end - - describe file('/etc/mysql/grants.sql') do - it { should be_a_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 600 } - its(:content) { should match 'r00t' } - end - - describe file('/etc/mysql/grants.sql'), if: ubuntu? do - its(:content) { should match 'debian-sys-maint' } - its(:content) { should match 'd3b1an' } - end - - describe file('/etc/mysql/debian.cnf'), if: ubuntu? do - it { should be_a_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 640 } - its(:content) { should match 'd3b1an' } - end - - describe file('/etc/mysql/replication.sql') do - it { should_not be_a_file } - end - - describe 'Custom data directory' do - describe file('/tmp/mysql') do - it { should be_a_directory } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - end - - describe file('/tmp/mysql/ibdata1') do - it { should be_a_file } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - it { should be_mode 660 } - end - - describe file('/tmp/mysql/ibdata1') do - it { should be_a_file } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - it { should be_mode 660 } - end - - describe file('/tmp/mysql/mysql/user.frm') do - it { should be_a_file } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - it { should be_mode 660 } - end - - describe command("mysqladmin --user='root' --password='r00t' variables") do - its(:stdout) { should match %r{datadir\s+| /tmp/mysql/} } - its(:stdout) { should match %r{general_log_file\s+| /tmp/mysql/} } - its(:exit_status) { should eq 0 } - end - end -end diff --git a/test/integration/server_56/serverspec/localhost/server_56_spec.rb b/test/integration/server_56/serverspec/localhost/server_56_spec.rb deleted file mode 100644 index 68108e96..00000000 --- a/test/integration/server_56/serverspec/localhost/server_56_spec.rb +++ /dev/null @@ -1,168 +0,0 @@ -require 'serverspec' - -set :backend, :exec - -def ubuntu? - os[:family] == 'ubuntu' -end - -def redhat? - os[:family] == 'redhat' -end - -describe 'Ubuntu package installation', if: ubuntu? do - describe package('percona-server-server-5.6') do - it { should be_installed } - end - - describe package('libjemalloc1') do - it { should be_installed } - end -end - -describe 'Red Hat package installation', if: redhat? do - describe package('Percona-Server-devel-56') do - it { should be_installed } - end - - describe package('Percona-Server-client-56') do - it { should be_installed } - end - - describe package('Percona-Server-server-56') do - it { should be_installed } - end - - describe package('jemalloc') do - it { should be_installed } - end -end - -describe 'Service configuration' do - describe file('/root/.my.cnf') do - it { should be_a_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 600 } - its(:content) { should match 'r00t' } - end - - describe file('/etc/mysql') do - it { should be_a_directory } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 755 } - end - - describe file('/var/lib/mysql') do - it { should be_a_directory } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - end - - describe file('/var/log/mysql') do - it { should be_a_directory } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - end - - describe file('/tmp') do - it { should be_a_directory } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - end - - describe service('mysql') do - it { should be_enabled } - it { should be_running } - end - - describe command('pgrep mysql') do - its(:stdout) { should match(/\d+/) } - its(:exit_status) { should eq 0 } - end - - describe port(3306) do - it { should be_listening } - end - - describe file('/var/lib/mysql/mysql/user.frm') do - it { should be_a_file } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - end - - describe file('/etc/mysql/my.cnf'), if: ubuntu? do - it { should be_a_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 644 } - end - - describe file('/etc/my.cnf'), if: redhat? do - it { should be_a_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 644 } - end - - describe file('/etc/mysql/grants.sql') do - it { should be_a_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 600 } - its(:content) { should match 'r00t' } - end - - describe file('/etc/mysql/grants.sql'), if: ubuntu? do - its(:content) { should match 'debian-sys-maint' } - its(:content) { should match 'd3b1an' } - end - - describe file('/etc/mysql/debian.cnf'), if: ubuntu? do - it { should be_a_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'root' } - it { should be_mode 640 } - its(:content) { should match 'd3b1an' } - end - - describe file('/etc/mysql/replication.sql') do - it { should_not be_a_file } - end - - describe 'Custom data directory' do - describe file('/tmp/mysql') do - it { should be_a_directory } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - end - - describe file('/tmp/mysql/ibdata1') do - it { should be_a_file } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - it { should be_mode 660 } - end - - describe file('/tmp/mysql/ibdata1') do - it { should be_a_file } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - it { should be_mode 660 } - end - - describe file('/tmp/mysql/mysql/user.frm') do - it { should be_a_file } - it { should be_owned_by 'mysql' } - it { should be_grouped_into 'mysql' } - it { should be_mode 660 } - end - - describe command("mysqladmin --user='root' --password='r00t' variables") do - its(:stdout) { should match %r{datadir\s+| /tmp/mysql/} } - its(:stdout) { should match %r{general_log_file\s+| /tmp/mysql/} } - its(:exit_status) { should eq 0 } - end - end -end From 92b66a84325038e33e902e10beedc601ec592d2a Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Fri, 31 Jul 2020 18:21:42 -0700 Subject: [PATCH 119/300] Don't install abi_version packages on Debian/Ubuntu This is no longer needed as the upstream packages properly deal with this. This was causing issues during the installation. Also clean up the formatting a little so it's easier to read. Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + attributes/client.rb | 46 +++++++++++++++++++------------------------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6de3234..643dca23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This file is used to list changes made in each version of the percona cookbook. - Disable enforce_idempotency until we can properly fix it - Convert to InSpec tests and refactor test cookbook recipes +- Don't install abi_version packages on Debian/Ubuntu ## 0.17.2 - 2020-08-06 diff --git a/attributes/client.rb b/attributes/client.rb index bc7cd6b1..baa4d710 100644 --- a/attributes/client.rb +++ b/attributes/client.rb @@ -13,31 +13,25 @@ case node['platform_family'] when 'debian' - abi_version = case version - when '5.5' then '18' - when '5.6' then '18.1' - else '' - end - - default['percona']['client']['packages'] = if Array(node['percona']['server']['role']).include?('cluster') - %W( - libperconaserverclient#{abi_version}-dev percona-xtradb-cluster-client-#{version} - ) - else - %W( - libperconaserverclient#{abi_version}-dev percona-server-client-#{version} - ) - end + default['percona']['client']['packages'] = + if Array(node['percona']['server']['role']).include?('cluster') + %W( + percona-xtradb-cluster-client-#{version} + ) + else + %W( + percona-server-client-#{version} + ) + end when 'rhel' - default['percona']['client']['packages'] = if Array(node['percona']['server']['role']).include?('cluster') - %W( - Percona-XtraDB-Cluster-client-#{version} - ) - # Percona-XtraDB-Cluster-devel-#{version} - else - %W( - Percona-Server-client-#{version} - ) - # Percona-Server-devel-#{version} - end + default['percona']['client']['packages'] = + if Array(node['percona']['server']['role']).include?('cluster') + %W( + Percona-XtraDB-Cluster-client-#{version} + ) + else + %W( + Percona-Server-client-#{version} + ) + end end From 0eca94f959f0c68ec666ae276dcf9fbcecf0373e Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 14:59:40 -0700 Subject: [PATCH 120/300] Update apt gpg key Signed-off-by: Lance Albertson --- CHANGELOG.md | 4 ++++ attributes/package_repo.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 643dca23..7687bd44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +### Fixed + +- Update apt gpg key + ### Changed - Disable enforce_idempotency until we can properly fix it diff --git a/attributes/package_repo.rb b/attributes/package_repo.rb index 6a6ad1c6..de1c6788 100644 --- a/attributes/package_repo.rb +++ b/attributes/package_repo.rb @@ -11,7 +11,7 @@ 'default' => node['platform_version'].to_i ) -default['percona']['apt']['key'] = '0x9334A25F8507EFA5' +default['percona']['apt']['key'] = '8507EFA5' default['percona']['apt']['keyserver'] = 'hkp://keys.gnupg.net:80' default['percona']['apt']['uri'] = 'http://repo.percona.com/apt' From f5037903700d73dddb2ae4ee3177757c74e5f97e Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 15:00:19 -0700 Subject: [PATCH 121/300] Fixes for supporting 5.7 Starting with 5.7, the systemd unit will automatically initialize the database properly, so we can skip using execute[setup mysql datadir] resource. In addition, the systemd unit included on RHEL has a few issues that needed to be fixed including: - Removing PIDfile as it was causing issues with the newer version of systemd on RHEL 7 - Use --initialize-insecure so that we can do an easier way of initializing the database with Chef Other changes include: - Skip debian-sys-maint grants setup when using >= 5.7 - Fix excluding innodb_additional_mem_pool_size option for 5.7 Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + metadata.rb | 1 + recipes/configure_server.rb | 1 + recipes/server.rb | 17 +++++++++++++++++ templates/grants.sql.erb | 2 +- templates/my.cnf.main.erb | 2 +- 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7687bd44..30e45b03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This file is used to list changes made in each version of the percona cookbook. ### Fixed - Update apt gpg key +- Fixes for supporting 5.7 ### Changed diff --git a/metadata.rb b/metadata.rb index 6e51239b..3f12aefc 100644 --- a/metadata.rb +++ b/metadata.rb @@ -11,6 +11,7 @@ depends 'openssl' depends 'yum-epel' depends 'chef-vault' +depends 'line' supports 'debian' supports 'ubuntu' diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index e5dd0617..861b0cdf 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -126,6 +126,7 @@ execute 'setup mysql datadir' do command "mysql_install_db --defaults-file=#{percona['main_config_file']} --user=#{user}" not_if "test -f #{datadir}/mysql/user.frm" + not_if { node['percona']['version'] == '5.7' } action :nothing end diff --git a/recipes/server.rb b/recipes/server.rb index ec4902ab..73b09fd4 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -32,6 +32,23 @@ package node['percona']['server']['package'] do action node['percona']['server']['package_action'].to_sym end + + # Work around issue with 5.7 on RHEL + if node['percona']['version'].to_f >= 5.7 + execute 'systemctl daemon-reload' do + action :nothing + end + + delete_lines 'remove PIDFile from systemd.service' do + path '/usr/lib/systemd/system/mysqld.service' + pattern /^PIDFile=.*/ + notifies :run, 'execute[systemctl daemon-reload]', :immediately + end + + filter_lines '/usr/bin/mysqld_pre_systemd' do + filters(substitute: [/--initialize /, /--initialize /, '--initialize-insecure ']) + end + end end unless node['percona']['skip_configure'] diff --git a/templates/grants.sql.erb b/templates/grants.sql.erb index 2152565d..e49b1b3d 100644 --- a/templates/grants.sql.erb +++ b/templates/grants.sql.erb @@ -1,7 +1,7 @@ # Generated by Chef for <%= node["fqdn"] %>. # Local modifications will be overwritten. -<% if node["platform_family"] == "debian" -%> +<% if node["platform_family"] == "debian" && node["percona"]["version"].to_f < 5.7 -%> # debian-sys-maint user for administration <% [['SELECT', 'mysql.user'], ['SHUTDOWN', '*.*']].each do |priv, loc| %> <%= "GRANT #{priv} ON #{loc} TO '#{@debian_user}'@'localhost';" %> diff --git a/templates/my.cnf.main.erb b/templates/my.cnf.main.erb index 511b6672..59a1ed93 100644 --- a/templates/my.cnf.main.erb +++ b/templates/my.cnf.main.erb @@ -516,7 +516,7 @@ myisam_recover skip-innodb <% end %> -<%- if node["percona"]["version"] < "5.7.4" %> +<%- if node["percona"]["version"].to_f < 5.7 %> # Additional memory pool that is used by InnoDB to store metadata # information. If InnoDB requires more memory for this purpose it will # start to allocate it from the OS. As this is fast enough on most From 0a397f8ba3311636d73a752f2aef02f1dd9175e6 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 16:41:43 -0700 Subject: [PATCH 122/300] Update changelog to include standardized file fixes Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30e45b03..27ea70d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This file is used to list changes made in each version of the percona cookbook. - Disable enforce_idempotency until we can properly fix it - Convert to InSpec tests and refactor test cookbook recipes - Don't install abi_version packages on Debian/Ubuntu +- Standardise files with files in sous-chefs/repo-management ## 0.17.2 - 2020-08-06 From ee1b8f0a9bca128fa8585ad231d63e0f2c28690f Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 16:44:31 -0700 Subject: [PATCH 123/300] Remove support for Amazon Linux Upstream doesn't officially provide packages for this so we shouldn't include it here. Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 1 - CHANGELOG.md | 4 ++++ README.md | 2 -- attributes/package_repo.rb | 6 +----- kitchen.dokken.yml | 5 ----- kitchen.yml | 6 ------ metadata.rb | 1 - 7 files changed, 5 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8296c086..d72d04c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,6 @@ jobs: - 'ubuntu-1604' - 'ubuntu-1804' - 'opensuse-leap-15' - - 'amazonlinux-2' suite: - 'server-56' - 'server-57' diff --git a/CHANGELOG.md b/CHANGELOG.md index 27ea70d1..bde3766b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ This file is used to list changes made in each version of the percona cookbook. - Don't install abi_version packages on Debian/Ubuntu - Standardise files with files in sous-chefs/repo-management +### Removed + +- Remove support for Amazon Linux + ## 0.17.2 - 2020-08-06 ### Fixed diff --git a/README.md b/README.md index b17db102..1b4fa385 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,6 @@ This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of We provide an expanding set of tests against the following 64-bit platforms: -- Amazon 2014.03 - CentOS 6.5 - CentOS 7.0 - Debian 7.8 @@ -42,7 +41,6 @@ cause, and we'll make reasonable efforts to improve support: - Ubuntu - Debian -- Amazon Linux AMI - CentOS - Red Hat - Scientific diff --git a/attributes/package_repo.rb b/attributes/package_repo.rb index de1c6788..f632d0a5 100644 --- a/attributes/package_repo.rb +++ b/attributes/package_repo.rb @@ -6,17 +6,13 @@ default['percona']['use_percona_repos'] = true arch = node['kernel']['machine'] == 'x86_64' ? 'x86_64' : 'i386' -pversion = value_for_platform( - 'amazon' => { 'default' => 'latest' }, - 'default' => node['platform_version'].to_i -) default['percona']['apt']['key'] = '8507EFA5' default['percona']['apt']['keyserver'] = 'hkp://keys.gnupg.net:80' default['percona']['apt']['uri'] = 'http://repo.percona.com/apt' default['percona']['yum']['description'] = 'Percona Packages' -default['percona']['yum']['baseurl'] = "http://repo.percona.com/centos/#{pversion}/os/#{arch}/" +default['percona']['yum']['baseurl'] = "http://repo.percona.com/centos/#{node['platform_version'].to_i}/os/#{arch}/" default['percona']['yum']['gpgkey'] = [ 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index d8bb812a..2b09f0ca 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -13,11 +13,6 @@ provisioner: name: dokken platforms: - - name: amazonlinux-2 - driver: - image: dokken/amazonlinux-2 - pid_one_command: /usr/lib/systemd/systemd - - name: debian-8 driver: image: dokken/debian-8 diff --git a/kitchen.yml b/kitchen.yml index e49f0bc9..5bae2a93 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -16,12 +16,6 @@ verifier: name: inspec platforms: - - name: amazonlinux-2 - driver_config: - box: ywatase/amzn2 - - name: amazon-linux - driver_config: - box: mvbcoding/awslinux - name: centos-6 - name: centos-7 - name: debian-8 diff --git a/metadata.rb b/metadata.rb index 3f12aefc..a9dfc61f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -16,7 +16,6 @@ supports 'debian' supports 'ubuntu' supports 'centos' -supports 'amazon' supports 'scientific' supports 'fedora' supports 'redhat' From 14d0732d0a5a71dfe37359be84063ab81c6e57cc Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 16:46:16 -0700 Subject: [PATCH 124/300] Remove support for OpenSUSE Upstream doesn't officially provide packages for this so we shouldn't include it here. Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 1 - CHANGELOG.md | 1 + kitchen.dokken.yml | 5 ----- kitchen.yml | 1 - 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d72d04c3..5bdb444d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,6 @@ jobs: - 'centos-7' - 'ubuntu-1604' - 'ubuntu-1804' - - 'opensuse-leap-15' suite: - 'server-56' - 'server-57' diff --git a/CHANGELOG.md b/CHANGELOG.md index bde3766b..3083a348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ This file is used to list changes made in each version of the percona cookbook. ### Removed - Remove support for Amazon Linux +- Remove support for OpenSUSE ## 0.17.2 - 2020-08-06 diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 2b09f0ca..a9e20065 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -45,8 +45,3 @@ platforms: pid_one_command: /bin/systemd intermediate_instructions: - RUN /usr/bin/apt-get update - - - name: opensuse-leap-15 - driver: - image: dokken/opensuse-leap-15 - pid_one_command: /bin/systemd diff --git a/kitchen.yml b/kitchen.yml index 5bae2a93..9e67c1a1 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -20,7 +20,6 @@ platforms: - name: centos-7 - name: debian-8 - name: debian-9 - - name: opensuse-leap-15 - name: ubuntu-16.04 - name: ubuntu-18.04 From ae43a9fbad3bf664a53c2d64ddd0c4f7f0b0739d Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 17:10:17 -0700 Subject: [PATCH 125/300] Add Debian 10 / Remove Debian 8 support Debian 10 support is only for 5.7 and Debian 8 has been EOL'd upstream. Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 5 +++++ README.md | 3 +-- attributes/default.rb | 11 +++++++++++ kitchen.dokken.yml | 8 ++++---- kitchen.yml | 6 +++++- recipes/backup.rb | 9 ++------- test/integration/helpers/server_spec.rb | 14 ++++++++++++++ 8 files changed, 43 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5bdb444d..3d6b89df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,8 +40,8 @@ jobs: strategy: matrix: os: - - 'debian-8' - 'debian-9' + - 'debian-10' - 'centos-7' - 'ubuntu-1604' - 'ubuntu-1804' diff --git a/CHANGELOG.md b/CHANGELOG.md index 3083a348..c704b07e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +### Added + +- Add support for Debian 10 for 5.7 only + ### Fixed - Update apt gpg key @@ -20,6 +24,7 @@ This file is used to list changes made in each version of the percona cookbook. - Remove support for Amazon Linux - Remove support for OpenSUSE +- Remove support for Debian 8 (EOL) ## 0.17.2 - 2020-08-06 diff --git a/README.md b/README.md index 1b4fa385..02250011 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ We provide an expanding set of tests against the following 64-bit platforms: - CentOS 6.5 - CentOS 7.0 -- Debian 7.8 +- Debian 9+ - Ubuntu 12.04 LTS - Ubuntu 14.04 LTS @@ -40,7 +40,6 @@ the following to be supported. Please submit an issue if this is not the cause, and we'll make reasonable efforts to improve support: - Ubuntu -- Debian - CentOS - Red Hat - Scientific diff --git a/attributes/default.rb b/attributes/default.rb index 50d4dd26..70515c02 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -208,6 +208,17 @@ # XtraBackup Settings default['percona']['backup']['configure'] = false default['percona']['backup']['username'] = 'backup' +default['percona']['backup']['package_name'] = + case node['platform_family'] + when 'debian' + if node['platform_version'].to_i >= 10 + 'percona-xtrabackup-80' + else + 'xtrabackup' + end + when 'rhel' + 'percona-xtrabackup' + end unless attribute?(node['percona']['backup']['password']) default['percona']['backup']['password'] = random_password end diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index a9e20065..b0ad6daa 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -13,16 +13,16 @@ provisioner: name: dokken platforms: - - name: debian-8 + - name: debian-9 driver: - image: dokken/debian-8 + image: dokken/debian-9 pid_one_command: /bin/systemd intermediate_instructions: - RUN /usr/bin/apt-get update - - name: debian-9 + - name: debian-10 driver: - image: dokken/debian-9 + image: dokken/debian-10 pid_one_command: /bin/systemd intermediate_instructions: - RUN /usr/bin/apt-get update diff --git a/kitchen.yml b/kitchen.yml index 9e67c1a1..4a0fe44a 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -18,8 +18,8 @@ verifier: platforms: - name: centos-6 - name: centos-7 - - name: debian-8 - name: debian-9 + - name: debian-10 - name: ubuntu-16.04 - name: ubuntu-18.04 @@ -30,6 +30,8 @@ suites: attributes: percona: version: '5.6' + excludes: + - debian-10 - name: client-57 run_list: - recipe[test::client] @@ -42,6 +44,8 @@ suites: attributes: percona: version: '5.6' + excludes: + - debian-10 - name: server-57 run_list: - recipe[test::server] diff --git a/recipes/backup.rb b/recipes/backup.rb index e9293455..991f8cc6 100644 --- a/recipes/backup.rb +++ b/recipes/backup.rb @@ -7,13 +7,8 @@ include_recipe 'percona::package_repo' -case node['platform_family'] -when 'debian' - package 'xtrabackup' do - options '--force-yes' - end -when 'rhel' - package 'percona-xtrabackup' +package 'xtrabackup' do + package_name node['percona']['backup']['package_name'] end # access grants diff --git a/test/integration/helpers/server_spec.rb b/test/integration/helpers/server_spec.rb index 6d488c7a..013a53cf 100644 --- a/test/integration/helpers/server_spec.rb +++ b/test/integration/helpers/server_spec.rb @@ -4,6 +4,16 @@ def server_test(version) it { should be_installed } end + if os.release.to_i >= 10 + describe package 'percona-xtrabackup-80' do + it { should be_installed } + end + else + describe package 'xtrabackup' do + it { should be_installed } + end + end + describe package 'libjemalloc1' do it { should be_installed } end @@ -37,6 +47,10 @@ def server_test(version) it { should be_installed } end + describe package 'xtrabackup' do + it { should be_installed } + end + describe package "Percona-Server-client-#{ver}" do it { should be_installed } end From 9c06e5a8ed3c6de6e8060b6362fd5d0ffec990c4 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 17:11:49 -0700 Subject: [PATCH 126/300] Remove support for Fedora / Scientific Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + README.md | 2 -- metadata.rb | 6 ++---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c704b07e..9cabcabe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ This file is used to list changes made in each version of the percona cookbook. - Remove support for Amazon Linux - Remove support for OpenSUSE - Remove support for Debian 8 (EOL) +- Remove support for Fedora / Scientific ## 0.17.2 - 2020-08-06 diff --git a/README.md b/README.md index 02250011..11031f5f 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,6 @@ cause, and we'll make reasonable efforts to improve support: - Ubuntu - CentOS - Red Hat -- Scientific -- Fedora ### Cookbooks diff --git a/metadata.rb b/metadata.rb index a9dfc61f..af956b65 100644 --- a/metadata.rb +++ b/metadata.rb @@ -13,9 +13,7 @@ depends 'chef-vault' depends 'line' -supports 'debian' -supports 'ubuntu' supports 'centos' -supports 'scientific' -supports 'fedora' +supports 'debian' supports 'redhat' +supports 'ubuntu' From a74f949a7d04abd54643d2c8aaaef0170a13ce6c Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 17:23:13 -0700 Subject: [PATCH 127/300] Add support for Ubuntu 20.04 for 5.7 only Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 1 + CHANGELOG.md | 1 + README.md | 4 +--- kitchen.dokken.yml | 7 +++++++ kitchen.yml | 3 +++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d6b89df..cc7c0ed0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,7 @@ jobs: - 'centos-7' - 'ubuntu-1604' - 'ubuntu-1804' + - 'ubuntu-2004' suite: - 'server-56' - 'server-57' diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cabcabe..396ada2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This file is used to list changes made in each version of the percona cookbook. ### Added - Add support for Debian 10 for 5.7 only +- Add support for Ubuntu 20.04 for 5.7 only ### Fixed diff --git a/README.md b/README.md index 11031f5f..1cb13805 100644 --- a/README.md +++ b/README.md @@ -32,14 +32,12 @@ We provide an expanding set of tests against the following 64-bit platforms: - CentOS 6.5 - CentOS 7.0 - Debian 9+ -- Ubuntu 12.04 LTS -- Ubuntu 14.04 LTS +- Ubuntu 16.04+ LTS Although we don't test against all possible platform versions, we expect the following to be supported. Please submit an issue if this is not the cause, and we'll make reasonable efforts to improve support: -- Ubuntu - CentOS - Red Hat diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index b0ad6daa..1945e804 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -45,3 +45,10 @@ platforms: pid_one_command: /bin/systemd intermediate_instructions: - RUN /usr/bin/apt-get update + + - name: ubuntu-20.04 + driver: + image: dokken/ubuntu-20.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update diff --git a/kitchen.yml b/kitchen.yml index 4a0fe44a..9918b1d2 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -22,6 +22,7 @@ platforms: - name: debian-10 - name: ubuntu-16.04 - name: ubuntu-18.04 + - name: ubuntu-20.04 suites: - name: client-56 @@ -32,6 +33,7 @@ suites: version: '5.6' excludes: - debian-10 + - ubuntu-20.04 - name: client-57 run_list: - recipe[test::client] @@ -46,6 +48,7 @@ suites: version: '5.6' excludes: - debian-10 + - ubuntu-20.04 - name: server-57 run_list: - recipe[test::server] From 259661c880eba89ab273aabcba9c04194ecc4dcc Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 20:47:14 -0700 Subject: [PATCH 128/300] Add support for CentOS 8 / Remove CentOS 6 This updates the baseurl for the yum repo to match what upstream uses. In addition, it includes the noarch repository which was missing. Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 1 + CHANGELOG.md | 2 ++ README.md | 12 ++---------- attributes/default.rb | 6 +++++- attributes/package_repo.rb | 6 +----- kitchen.dokken.yml | 5 +++++ kitchen.yml | 4 +++- recipes/package_repo.rb | 17 +++++++++++++++-- test/integration/helpers/client_spec.rb | 7 ++++++- test/integration/helpers/server_spec.rb | 10 ++++++++-- 10 files changed, 48 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc7c0ed0..9dd27631 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,7 @@ jobs: - 'debian-9' - 'debian-10' - 'centos-7' + - 'centos-8' - 'ubuntu-1604' - 'ubuntu-1804' - 'ubuntu-2004' diff --git a/CHANGELOG.md b/CHANGELOG.md index 396ada2c..a61c932d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This file is used to list changes made in each version of the percona cookbook. - Add support for Debian 10 for 5.7 only - Add support for Ubuntu 20.04 for 5.7 only +- Add support for CentOS 8 ### Fixed @@ -27,6 +28,7 @@ This file is used to list changes made in each version of the percona cookbook. - Remove support for OpenSUSE - Remove support for Debian 8 (EOL) - Remove support for Fedora / Scientific +- Remove support for CentOS 6 ## 0.17.2 - 2020-08-06 diff --git a/README.md b/README.md index 1cb13805..afc1b0d2 100644 --- a/README.md +++ b/README.md @@ -27,20 +27,12 @@ This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of ### Supported Platforms -We provide an expanding set of tests against the following 64-bit platforms: +We provide an expanding set of tests against the following 64-bit platforms which match what upstream supports: -- CentOS 6.5 -- CentOS 7.0 +- CentOS 7+ - Debian 9+ - Ubuntu 16.04+ LTS -Although we don't test against all possible platform versions, we expect -the following to be supported. Please submit an issue if this is not the -cause, and we'll make reasonable efforts to improve support: - -- CentOS -- Red Hat - ### Cookbooks - [apt](https://supermarket.getchef.com/cookbooks/apt) Chef LWRP Cookbook diff --git a/attributes/default.rb b/attributes/default.rb index 70515c02..28e73a7e 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -217,7 +217,11 @@ 'xtrabackup' end when 'rhel' - 'percona-xtrabackup' + if node['platform_version'].to_i >= 8 + 'percona-xtrabackup-80' + else + 'percona-xtrabackup' + end end unless attribute?(node['percona']['backup']['password']) default['percona']['backup']['password'] = random_password diff --git a/attributes/package_repo.rb b/attributes/package_repo.rb index f632d0a5..c9df2196 100644 --- a/attributes/package_repo.rb +++ b/attributes/package_repo.rb @@ -4,15 +4,11 @@ # default['percona']['use_percona_repos'] = true - -arch = node['kernel']['machine'] == 'x86_64' ? 'x86_64' : 'i386' - default['percona']['apt']['key'] = '8507EFA5' default['percona']['apt']['keyserver'] = 'hkp://keys.gnupg.net:80' default['percona']['apt']['uri'] = 'http://repo.percona.com/apt' - default['percona']['yum']['description'] = 'Percona Packages' -default['percona']['yum']['baseurl'] = "http://repo.percona.com/centos/#{node['platform_version'].to_i}/os/#{arch}/" +default['percona']['yum']['baseurl'] = 'http://repo.percona.com/yum/release/$releasever/RPMS' default['percona']['yum']['gpgkey'] = [ 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 1945e804..46541e33 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -32,6 +32,11 @@ platforms: image: dokken/centos-7 pid_one_command: /usr/lib/systemd/systemd + - name: centos-8 + driver: + image: dokken/centos-8 + pid_one_command: /usr/lib/systemd/systemd + - name: ubuntu-16.04 driver: image: dokken/ubuntu-16.04 diff --git a/kitchen.yml b/kitchen.yml index 9918b1d2..66deeb53 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -16,8 +16,8 @@ verifier: name: inspec platforms: - - name: centos-6 - name: centos-7 + - name: centos-8 - name: debian-9 - name: debian-10 - name: ubuntu-16.04 @@ -32,6 +32,7 @@ suites: percona: version: '5.6' excludes: + - centos-8 - debian-10 - ubuntu-20.04 - name: client-57 @@ -47,6 +48,7 @@ suites: percona: version: '5.6' excludes: + - centos-8 - debian-10 - ubuntu-20.04 - name: server-57 diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index 400dffb2..e0d4531f 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -23,11 +23,24 @@ end when 'rhel' - yum_repository 'percona' do + yum_repository "percona-#{node['kernel']['machine']}" do description node['percona']['yum']['description'] - baseurl node['percona']['yum']['baseurl'] + baseurl "#{node['percona']['yum']['baseurl']}/$basearch" gpgkey node['percona']['yum']['gpgkey'] gpgcheck node['percona']['yum']['gpgcheck'] sslverify node['percona']['yum']['sslverify'] end + + yum_repository 'percona-noarch' do + description node['percona']['yum']['description'] + baseurl "#{node['percona']['yum']['baseurl']}/noarch" + gpgkey node['percona']['yum']['gpgkey'] + gpgcheck node['percona']['yum']['gpgcheck'] + sslverify node['percona']['yum']['sslverify'] + end + + execute 'dnf -y module disable mysql' do + only_if { node['platform_version'].to_i >= 8 } + not_if 'dnf module list mysql | grep -q "^mysql.*\[x\]"' + end end diff --git a/test/integration/helpers/client_spec.rb b/test/integration/helpers/client_spec.rb index 42bb4c10..b28b5367 100644 --- a/test/integration/helpers/client_spec.rb +++ b/test/integration/helpers/client_spec.rb @@ -15,7 +15,12 @@ def client_test(version) end else - describe yum.repo 'percona' do + describe yum.repo 'percona-x86_64' do + it { should exist } + it { should be_enabled } + end + + describe yum.repo 'percona-noarch' do it { should exist } it { should be_enabled } end diff --git a/test/integration/helpers/server_spec.rb b/test/integration/helpers/server_spec.rb index 013a53cf..3fc2632c 100644 --- a/test/integration/helpers/server_spec.rb +++ b/test/integration/helpers/server_spec.rb @@ -47,8 +47,14 @@ def server_test(version) it { should be_installed } end - describe package 'xtrabackup' do - it { should be_installed } + if os.release.to_i >= 8 + describe package 'percona-xtrabackup-80' do + it { should be_installed } + end + else + describe package 'xtrabackup' do + it { should be_installed } + end end describe package "Percona-Server-client-#{ver}" do From 07d9fa7c4b89242758f03c5d8b4c10a43f953ef1 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 21:00:32 -0700 Subject: [PATCH 129/300] Fix manage_symlink_source warning with template[/etc/mysql/my.cnf] Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + recipes/configure_server.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a61c932d..5e886b09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This file is used to list changes made in each version of the percona cookbook. - Update apt gpg key - Fixes for supporting 5.7 +- Fix manage_symlink_source warning with template[/etc/mysql/my.cnf] ### Changed diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 861b0cdf..5e2f4c53 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -155,6 +155,7 @@ group 'root' mode '0644' sensitive true + manage_symlink_source true if Array(server['role']).include?('cluster') variables(wsrep_sst_auth: wsrep_sst_auth) end From db0522e5394b0a5f771c9ce17935159c4330aca2 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 21:14:18 -0700 Subject: [PATCH 130/300] Don't remove mysql-libs on RHEL We no longer need to forcibly remove mysql-libs on RHEL as the upstream package now properly replaces it. This causes issues on RHEL for packages such as postfix if they're already installed on the system by removing it. This installs postfix to ensure it still exists after using percona. Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + recipes/cluster.rb | 5 ----- recipes/server.rb | 6 ------ test/fixtures/cookbooks/test/recipes/server.rb | 3 +++ test/integration/helpers/server_spec.rb | 6 ++++++ 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e886b09..17514b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ This file is used to list changes made in each version of the percona cookbook. - Update apt gpg key - Fixes for supporting 5.7 - Fix manage_symlink_source warning with template[/etc/mysql/my.cnf] +- Don't remove mysql-libs on RHEL ### Changed diff --git a/recipes/cluster.rb b/recipes/cluster.rb index ca91b19f..035bbff2 100644 --- a/recipes/cluster.rb +++ b/recipes/cluster.rb @@ -31,11 +31,6 @@ notifies :stop, 'service[mysql]', :immediately end when 'rhel' - package 'mysql-libs' do - action :remove - not_if "rpm -qa | grep -q '#{node['percona']['cluster']['package']}'" - end - # This is required for `socat` per: # www.percona.com/doc/percona-xtradb-cluster/5.6/installation/yum_repo.html include_recipe 'yum-epel' diff --git a/recipes/server.rb b/recipes/server.rb index 73b09fd4..b8682375 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -20,12 +20,6 @@ node.default['percona']['server']['package'] = "Percona-Server-server-#{version.tr('.', '')}" node.default['percona']['server']['shared_pkg'] = "Percona-Server-shared-#{version.tr('.', '')}" - # Need to remove this to avoid conflicts - package 'mysql-libs' do - action :remove - not_if "rpm -qa | grep #{node['percona']['server']['shared_pkg']}" - end - # we need mysqladmin include_recipe 'percona::client' diff --git a/test/fixtures/cookbooks/test/recipes/server.rb b/test/fixtures/cookbooks/test/recipes/server.rb index 8a4d00ff..94a14e8b 100644 --- a/test/fixtures/cookbooks/test/recipes/server.rb +++ b/test/fixtures/cookbooks/test/recipes/server.rb @@ -4,5 +4,8 @@ node.default['percona']['server']['root_password'] = '7tCk(V5I' node.default['percona']['backup']['password'] = 'I}=sJ2bS' +# Install postfix on RHEL to ensure we don't properly break mysql-libs compatibility +package 'postfix' if platform_family?('rhel') + include_recipe 'percona::server' include_recipe 'percona::backup' diff --git a/test/integration/helpers/server_spec.rb b/test/integration/helpers/server_spec.rb index 3fc2632c..f249e4c3 100644 --- a/test/integration/helpers/server_spec.rb +++ b/test/integration/helpers/server_spec.rb @@ -42,6 +42,12 @@ def server_test(version) end if os.family == 'rhel' + + # postfix on RHEL depends on mysql-libs, ensure it still exists when using percona + describe package 'postfix' do + it { should be_installed } + end + ver = version.tr('.', '') describe package "Percona-Server-devel-#{ver}" do it { should be_installed } From ed2c2034a814ca781e58c58c52b7a71b93c76756 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 2 Aug 2020 21:20:15 -0700 Subject: [PATCH 131/300] Disable cookstyle check on node.save (for now) Signed-off-by: Lance Albertson --- recipes/configure_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 5e2f4c53..7aafac07 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -53,7 +53,7 @@ ipaddr = Percona::ConfigHelper.bind_to(node, server['bind_to']) if ipaddr && server['bind_address'] != ipaddr node.override['percona']['server']['bind_address'] = ipaddr - node.save unless Chef::Config[:solo] + node.save unless Chef::Config[:solo] # rubocop:disable ChefCorrectness/CookbookUsesNodeSave end log "Can't find ip address for #{server['bind_to']}" do From 2eba02ffaef011ac9531f346a4148f1ad52cb816 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 3 Aug 2020 22:55:37 -0700 Subject: [PATCH 132/300] Add cluster suite and tests to test cluster recipe This also fixes install various issues with how the cluster recipe worked. This unfortunately doesn't test the full configuration as that requires at least three nodes to complete. Other fixes include: - Properly install the correct version of the jemalloc on Debian/Ubuntu - Properly fix the library path for jemalloc on all platforms - Remove immediate stop for mysql server after installing cluster packages on Debian. This is no longer required. - Switch all platforms to use execute[setup mysql datadir] resource and remove systemd fix for RHEL. This updates the command to run on 5.7. - Don't include backup recipe when testing cluster as it already installs xtrabackup - Update InSpec tests so that it works for both server and cluster variants Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 6 ++- CHANGELOG.md | 2 + attributes/default.rb | 38 +++++++++++----- kitchen.yml | 16 +++++++ recipes/cluster.rb | 20 +++------ recipes/configure_server.rb | 14 +++--- recipes/server.rb | 4 -- .../cookbooks/test/recipes/cluster.rb | 10 +++++ test/integration/cluster-56/cluster_spec.rb | 3 ++ test/integration/cluster-57/cluster_spec.rb | 3 ++ test/integration/helpers/server_spec.rb | 44 ++++++++++++++----- test/integration/server-56/server_spec.rb | 2 +- test/integration/server-57/server_spec.rb | 2 +- 13 files changed, 111 insertions(+), 53 deletions(-) create mode 100644 test/fixtures/cookbooks/test/recipes/cluster.rb create mode 100644 test/integration/cluster-56/cluster_spec.rb create mode 100644 test/integration/cluster-57/cluster_spec.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9dd27631..410772ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,10 +48,12 @@ jobs: - 'ubuntu-1804' - 'ubuntu-2004' suite: - - 'server-56' - - 'server-57' - 'client-56' - 'client-57' + - 'cluster-56' + - 'cluster-57' + - 'server-56' + - 'server-57' fail-fast: false steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 17514b32..0c87bcd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This file is used to list changes made in each version of the percona cookbook. - Add support for Debian 10 for 5.7 only - Add support for Ubuntu 20.04 for 5.7 only - Add support for CentOS 8 +- Add cluster suite and tests to test cluster recipe ### Fixed @@ -16,6 +17,7 @@ This file is used to list changes made in each version of the percona cookbook. - Fixes for supporting 5.7 - Fix manage_symlink_source warning with template[/etc/mysql/my.cnf] - Don't remove mysql-libs on RHEL +- jemalloc package installation and path setup for all platforms ### Changed diff --git a/attributes/default.rb b/attributes/default.rb index 28e73a7e..4c1f9fe4 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -62,15 +62,24 @@ default['percona']['server']['slave_load_tmpdir'] = '/tmp' default['percona']['server']['debian_username'] = 'debian-sys-maint' default['percona']['server']['jemalloc'] = false -default['percona']['server']['jemalloc_lib'] = value_for_platform_family( - 'debian' => value_for_platform( - 'ubuntu' => { - '14.04' => '/usr/lib/x86_64-linux-gnu/libjemalloc.so.1', - '12.04' => '/usr/lib/libjemalloc.so.1', - } - ), - 'rhel' => '/usr/lib64/libjemalloc.so.1' -) +default['percona']['server']['jemalloc_package'] = + case node['platform'] + when 'debian' + node['platform_version'].to_i >= 10 ? 'libjemalloc2' : 'libjemalloc1' + when 'ubuntu' + node['platform_version'].to_f >= 20.04 ? 'libjemalloc2' : 'libjemalloc1' + when 'centos', 'redhat' + 'jemalloc' + end +default['percona']['server']['jemalloc_lib'] = + case node['platform'] + when 'debian' + node['platform_version'].to_i >= 10 ? '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' : '/usr/lib/x86_64-linux-gnu/libjemalloc.so.1' + when 'ubuntu' + node['platform_version'].to_f >= 20.04 ? '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' : '/usr/lib/x86_64-linux-gnu/libjemalloc.so.1' + when 'centos', 'redhat' + node['platform_version'].to_i >= 8 ? '/usr/lib64/libjemalloc.so.2' : '/usr/lib64/libjemalloc.so.1' + end default['percona']['server']['nice'] = 0 default['percona']['server']['open_files_limit'] = 16_384 default['percona']['server']['hostname'] = 'localhost' @@ -211,9 +220,14 @@ default['percona']['backup']['package_name'] = case node['platform_family'] when 'debian' - if node['platform_version'].to_i >= 10 - 'percona-xtrabackup-80' - else + case node['platform'] + when 'debian' + if node['platform_version'].to_i >= 10 + 'percona-xtrabackup-80' + else + 'xtrabackup' + end + when 'ubuntu' 'xtrabackup' end when 'rhel' diff --git a/kitchen.yml b/kitchen.yml index 66deeb53..089a8ca5 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -57,3 +57,19 @@ suites: attributes: percona: version: '5.7' + - name: cluster-56 + run_list: + - recipe[test::cluster] + attributes: + percona: + version: '5.6' + excludes: + - centos-8 + - debian-10 + - ubuntu-20.04 + - name: cluster-57 + run_list: + - recipe[test::cluster] + attributes: + percona: + version: '5.7' diff --git a/recipes/cluster.rb b/recipes/cluster.rb index 035bbff2..c8103764 100644 --- a/recipes/cluster.rb +++ b/recipes/cluster.rb @@ -21,22 +21,12 @@ 'debian' => "percona-xtradb-cluster-#{version.tr('.', '')}" ) -# install packages -case node['platform_family'] -when 'debian' - package node['percona']['cluster']['package'] do - # The package starts up immediately, then additional config is added and the - # restart command fails to work. Instead, stop the database before changing - # the configuration. - notifies :stop, 'service[mysql]', :immediately - end -when 'rhel' - # This is required for `socat` per: - # www.percona.com/doc/percona-xtradb-cluster/5.6/installation/yum_repo.html - include_recipe 'yum-epel' +# This is required for `socat` per: +# www.percona.com/doc/percona-xtradb-cluster/5.6/installation/yum_repo.html +include_recipe 'yum-epel' if platform_family?('rhel') - package node['percona']['cluster']['package'] -end +# install packages +package node['percona']['cluster']['package'] unless node['percona']['skip_configure'] include_recipe 'percona::configure_server' diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 7aafac07..b8a03a4c 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -31,12 +31,7 @@ passwords = EncryptedPasswords.new(node, percona['encrypted_data_bag']) if node['percona']['server']['jemalloc'] - package_name = value_for_platform_family( - 'debian' => 'libjemalloc1', - 'rhel' => 'jemalloc' - ) - - package package_name + package node['percona']['server']['jemalloc_package'] end template '/root/.my.cnf' do @@ -124,9 +119,12 @@ # install db to the data directory execute 'setup mysql datadir' do - command "mysql_install_db --defaults-file=#{percona['main_config_file']} --user=#{user}" + if node['percona']['version'].to_f >= 5.7 + command "mysqld --defaults-file=#{percona['main_config_file']} --user=#{user} --initialize-insecure" + else + command "mysql_install_db --defaults-file=#{percona['main_config_file']} --user=#{user}" + end not_if "test -f #{datadir}/mysql/user.frm" - not_if { node['percona']['version'] == '5.7' } action :nothing end diff --git a/recipes/server.rb b/recipes/server.rb index b8682375..f7b4990c 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -38,10 +38,6 @@ pattern /^PIDFile=.*/ notifies :run, 'execute[systemctl daemon-reload]', :immediately end - - filter_lines '/usr/bin/mysqld_pre_systemd' do - filters(substitute: [/--initialize /, /--initialize /, '--initialize-insecure ']) - end end end diff --git a/test/fixtures/cookbooks/test/recipes/cluster.rb b/test/fixtures/cookbooks/test/recipes/cluster.rb new file mode 100644 index 00000000..fd2d2d16 --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/cluster.rb @@ -0,0 +1,10 @@ +node.default['percona']['server']['datadir'] = '/tmp/mysql' +node.default['percona']['server']['debian_password'] = '0kb)F?Zj' +node.default['percona']['server']['jemalloc'] = true +node.default['percona']['server']['root_password'] = '7tCk(V5I' +node.default['percona']['backup']['password'] = 'I}=sJ2bS' + +# Install postfix on RHEL to ensure we don't properly break mysql-libs compatibility +package 'postfix' if platform_family?('rhel') + +include_recipe 'percona::cluster' diff --git a/test/integration/cluster-56/cluster_spec.rb b/test/integration/cluster-56/cluster_spec.rb new file mode 100644 index 00000000..d15177a7 --- /dev/null +++ b/test/integration/cluster-56/cluster_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('5.6', 'cluster') diff --git a/test/integration/cluster-57/cluster_spec.rb b/test/integration/cluster-57/cluster_spec.rb new file mode 100644 index 00000000..2229e862 --- /dev/null +++ b/test/integration/cluster-57/cluster_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('5.7', 'cluster') diff --git a/test/integration/helpers/server_spec.rb b/test/integration/helpers/server_spec.rb index f249e4c3..740b81ee 100644 --- a/test/integration/helpers/server_spec.rb +++ b/test/integration/helpers/server_spec.rb @@ -1,20 +1,44 @@ -def server_test(version) +def server_test(version, type) if os.family == 'debian' - describe package "percona-server-server-#{version}" do - it { should be_installed } - end - - if os.release.to_i >= 10 - describe package 'percona-xtrabackup-80' do + case type + when 'server' + describe package "percona-server-server-#{version}" do it { should be_installed } end - else - describe package 'xtrabackup' do + when 'cluster' + describe package "percona-xtradb-cluster-#{version.tr('.', '')}" do it { should be_installed } end end - describe package 'libjemalloc1' do + xtrabackup_pkg = + if type == 'cluster' + if version.to_f < 5.7 + 'percona-xtrabackup' + else + 'percona-xtrabackup-24' + end + elsif os.name == 'debian' && os.release.to_i >= 10 + 'percona-xtrabackup-80' + else + 'xtrabackup' + end + + describe package xtrabackup_pkg do + it { should be_installed } + end + + jemalloc_pkg = + case os.name + when 'debian' + os.release.to_i >= 10 ? 'libjemalloc2' : 'libjemalloc1' + when 'ubuntu' + os.release.to_f >= 20.04 ? 'libjemalloc2' : 'libjemalloc1' + when 'centos' + os.release.to_i >= 8 ? 'libjemalloc2' : 'libjemalloc1' + end + + describe package jemalloc_pkg do it { should be_installed } end diff --git a/test/integration/server-56/server_spec.rb b/test/integration/server-56/server_spec.rb index ab833ea5..a9b1529f 100644 --- a/test/integration/server-56/server_spec.rb +++ b/test/integration/server-56/server_spec.rb @@ -1,3 +1,3 @@ require_relative '../helpers/server_spec.rb' -server_test('5.6') +server_test('5.6', 'server') diff --git a/test/integration/server-57/server_spec.rb b/test/integration/server-57/server_spec.rb index a5c6499d..dc8bc783 100644 --- a/test/integration/server-57/server_spec.rb +++ b/test/integration/server-57/server_spec.rb @@ -1,3 +1,3 @@ require_relative '../helpers/server_spec.rb' -server_test('5.7') +server_test('5.7', 'server') From 52d831638c5b005388232cc3090e751c7f87356e Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Tue, 4 Aug 2020 08:55:02 -0700 Subject: [PATCH 133/300] Fixed enabled ChefSpec tests Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + spec/default_spec.rb | 10 +++++----- spec/package_repo_spec.rb | 39 +++++++++++++++++++-------------------- spec/spec_helper.rb | 14 ++------------ 4 files changed, 27 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c87bcd0..f29dccf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This file is used to list changes made in each version of the percona cookbook. - Fix manage_symlink_source warning with template[/etc/mysql/my.cnf] - Don't remove mysql-libs on RHEL - jemalloc package installation and path setup for all platforms +- Fixed enabled ChefSpec tests ### Changed diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 12ce94f7..a0f2bd53 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' describe 'percona::default' do - let(:chef_run) do - ChefSpec::SoloRunner.new.converge(described_recipe) - end + platform 'ubuntu' - it 'can converge the client recipe' do - stub_command('apt-key list | grep 8507EFA5').and_return 'foo' + before do + stub_command('apt-key list | grep 8507EFA5') + end + it do expect(chef_run).to include_recipe('percona::client') end end diff --git a/spec/package_repo_spec.rb b/spec/package_repo_spec.rb index e5fd0bee..e4554f34 100644 --- a/spec/package_repo_spec.rb +++ b/spec/package_repo_spec.rb @@ -1,36 +1,35 @@ require 'spec_helper' describe 'percona::package_repo' do - describe 'Ubuntu' do - let(:chef_run) do - ChefSpec::SoloRunner.new.converge(described_recipe) - end - - before do - stub_command('apt-key list | grep 8507EFA5').and_return('foo') - end + before do + stub_command('apt-key list | grep 8507EFA5') + stub_command('dnf module list mysql | grep -q "^mysql.*\\[x\\]"') + end + context 'ubuntu' do + platform 'ubuntu' - it 'sets up an apt repository for `percona`' do + it do expect(chef_run).to add_apt_repository('percona') end - it 'sets up an apt preference' do + it do expect(chef_run).to add_apt_preference('00percona') end end - describe 'CentOS' do - let(:chef_run) do - env_options = { platform: 'centos', version: '6' } - ChefSpec::SoloRunner.new(env_options).converge(described_recipe) - end + context 'centos' do + platform 'centos' - it 'sets up a yum repository for `percona`' do - expect(chef_run).to create_yum_repository('percona') + it do + expect(chef_run).to create_yum_repository('percona-x86_64').with( + gpgkey: [ + 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', + 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', + ] + ) end - - it 'sets up a yum repository for `percona` with the 2019 GPG key' do - expect(chef_run).to create_yum_repository('percona').with( + it do + expect(chef_run).to create_yum_repository('percona-noarch').with( gpgkey: [ 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9260ced7..5d94fb35 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,16 +2,6 @@ require 'chefspec/berkshelf' RSpec.configure do |config| - config.platform = 'ubuntu' - config.version = '16.04' - config.log_level = :error - config.raise_errors_for_deprecations! -end - -def add_apt_repository(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:apt_repository, :add, resource_name) -end - -def add_apt_preference(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:apt_preference, :add, resource_name) + config.formatter = :documentation + config.color = true end From 91d3b8381ba452a9cf041e143ba14f144254a58d Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Tue, 4 Aug 2020 09:24:19 -0700 Subject: [PATCH 134/300] Exclude centos-8, debian-10, and ubuntu-2004 from 5.6 suites Upstream does not support those platforms. Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 410772ec..b5c4b920 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,25 @@ jobs: - 'cluster-57' - 'server-56' - 'server-57' + exclude: + - os: centos-8 + suite: client-56 + - os: centos-8 + suite: server-56 + - os: centos-8 + suite: cluster-56 + - os: debian-10 + suite: client-56 + - os: debian-10 + suite: server-56 + - os: debian-10 + suite: cluster-56 + - os: ubuntu-2004 + suite: client-56 + - os: ubuntu-2004 + suite: server-56 + - os: ubuntu-2004 + suite: cluster-56 fail-fast: false steps: From 93896272f092a5d45700cabbc91737a7ea639334 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Tue, 4 Aug 2020 09:58:41 -0700 Subject: [PATCH 135/300] Disable apparmor for mysqld on GH Action node This fixes an issue with testing. Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5c4b920..641a9a48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,6 +80,13 @@ jobs: uses: actions/checkout@master - name: Install Chef uses: actionshub/chef-install@master + # https://github.com/actions/virtual-environments/issues/181#issuecomment-610874237 + - name: Disable apparmor for mysqld + run: | + set -x + sudo apt-get -y remove mysql-server --purge + sudo apt-get -y install apparmor-profiles + sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld - name: Dokken uses: actionshub/kitchen-dokken@master env: From 17f4439a1db903dedb80eb08047fbe959e2fdd2b Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Tue, 4 Aug 2020 12:24:48 -0700 Subject: [PATCH 136/300] Fix xtrabackup installation for Ubuntu 20.04 Signed-off-by: Lance Albertson --- attributes/default.rb | 14 +++----------- test/integration/helpers/server_spec.rb | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 4c1f9fe4..84dc8879 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -222,20 +222,12 @@ when 'debian' case node['platform'] when 'debian' - if node['platform_version'].to_i >= 10 - 'percona-xtrabackup-80' - else - 'xtrabackup' - end + node['platform_version'].to_i >= 10 ? 'percona-xtrabackup-80' : 'xtrabackup' when 'ubuntu' - 'xtrabackup' + node['platform_version'].to_f >= 20.04 ? 'percona-xtrabackup-80' : 'xtrabackup' end when 'rhel' - if node['platform_version'].to_i >= 8 - 'percona-xtrabackup-80' - else - 'percona-xtrabackup' - end + node['platform_version'].to_i >= 8 ? 'percona-xtrabackup-80' : 'percona-xtrabackup' end unless attribute?(node['percona']['backup']['password']) default['percona']['backup']['password'] = random_password diff --git a/test/integration/helpers/server_spec.rb b/test/integration/helpers/server_spec.rb index 740b81ee..3984574c 100644 --- a/test/integration/helpers/server_spec.rb +++ b/test/integration/helpers/server_spec.rb @@ -18,7 +18,7 @@ def server_test(version, type) else 'percona-xtrabackup-24' end - elsif os.name == 'debian' && os.release.to_i >= 10 + elsif (os.name == 'debian' && os.release.to_i >= 10) || (os.name == 'ubuntu' && os.release.to_f >= 20.04) 'percona-xtrabackup-80' else 'xtrabackup' From 5dbd4eb98daaed9b5b4e597907142d717faee15c Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Tue, 4 Aug 2020 14:54:51 -0700 Subject: [PATCH 137/300] Deprecate monitoring recipe Upstream hasn't updated these packages for the recent OS platforms so we'll just go ahead and remove this. Users can install them directly if they want to. Signed-off-by: Lance Albertson --- CHANGELOG.md | 4 ++++ README.md | 9 --------- attributes/monitoring.rb | 7 ------- recipes/monitoring.rb | 10 ---------- 4 files changed, 4 insertions(+), 26 deletions(-) delete mode 100644 attributes/monitoring.rb delete mode 100644 recipes/monitoring.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index f29dccf4..585bc061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,10 @@ This file is used to list changes made in each version of the percona cookbook. - Remove support for Fedora / Scientific - Remove support for CentOS 6 +### Deprecated + +- Deprecate monitoring recipe + ## 0.17.2 - 2020-08-06 ### Fixed diff --git a/README.md b/README.md index afc1b0d2..2d2387c6 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ Optionally installs: - [XtraBackup](http://www.percona.com/software/percona-xtrabackup/) hot backup software - [Percona Toolkit](http://www.percona.com/software/percona-toolkit/) advanced command-line tools - [XtraDB Cluster](http://www.percona.com/software/percona-xtradb-cluster/) high availability and high scalability solution for MySQL. -- [Percona Monitoring Plugins](http://www.percona.com/software/percona-monitoring-plugins) various Nagios plugins for monitoring MySQL ## Maintainers @@ -60,7 +59,6 @@ the [currently tested versions](https://github.com/phlipper/chef-percona/blob/ma - `percona::configure_server` - Used internally to manage the server configuration. - `percona::replication` - Used internally to grant permissions for replication. - `percona::access_grants` - Used internally to grant permissions for recipes. -- `percona::monitoring` - Installs Percona monitoring plugins for Nagios ## Usage @@ -450,13 +448,6 @@ when "rhel" end ``` -### monitoring.rb - -```ruby -default["percona"]["plugins_version"] = "1.1.3" -default["percona"]["plugins_packages"] = %w[percona-nagios-plugins percona-zabbix-templates percona-cacti-templates] -``` - ### package_repo.rb ```ruby diff --git a/attributes/monitoring.rb b/attributes/monitoring.rb deleted file mode 100644 index bc1ab2d7..00000000 --- a/attributes/monitoring.rb +++ /dev/null @@ -1,7 +0,0 @@ -# -# Cookbook:: percona -# Attributes:: monitoring -# - -default['percona']['plugins_version'] = '1.1.3' -default['percona']['plugins_packages'] = %w(percona-nagios-plugins percona-zabbix-templates percona-cacti-templates) diff --git a/recipes/monitoring.rb b/recipes/monitoring.rb deleted file mode 100644 index 86698a95..00000000 --- a/recipes/monitoring.rb +++ /dev/null @@ -1,10 +0,0 @@ -# -# Cookbook:: percona -# Recipe:: monitoring -# - -node['percona']['plugins_packages'].each do |pkg| - package pkg do - version node['percona']['plugins_version'] - end -end From cb2e21de7a18213ff5952f0c04cf6c92bc2581b1 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Wed, 5 Aug 2020 14:44:26 -0700 Subject: [PATCH 138/300] Add support for Percona 8.0 and default to that version Starting with 8.0, Percona has changed how they manage the packages and repositories. This provides some fixes to workaround those issues. One notable change is that they have individual repositories for their products such as Percona Server vs. Percona XtraDB Cluster. This also includes the following changes: - Updates grants.sql to work with 8.0 properly - Exclude various configuration options that have been deprecated in 8.0 Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 3 ++ CHANGELOG.md | 1 + README.md | 2 +- attributes/client.rb | 4 ++ attributes/default.rb | 20 ++++++++- attributes/package_repo.rb | 3 ++ kitchen.yml | 18 ++++++++ recipes/cluster.rb | 8 +--- recipes/package_repo.rb | 28 +++++++++++-- recipes/server.rb | 7 ---- recipes/toolkit.rb | 5 ++- spec/package_repo_spec.rb | 2 +- templates/grants.sql.erb | 15 +++++-- templates/my.cnf.cluster.erb | 4 ++ templates/my.cnf.main.erb | 5 +++ test/integration/client-80/client_spec.rb | 3 ++ test/integration/cluster-80/cluster_spec.rb | 3 ++ test/integration/helpers/client_spec.rb | 46 +++++++++++++++++---- test/integration/helpers/server_spec.rb | 39 ++++++++++------- test/integration/server-80/server_spec.rb | 3 ++ 20 files changed, 170 insertions(+), 49 deletions(-) create mode 100644 test/integration/client-80/client_spec.rb create mode 100644 test/integration/cluster-80/cluster_spec.rb create mode 100644 test/integration/server-80/server_spec.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 641a9a48..60aeebde 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,10 +50,13 @@ jobs: suite: - 'client-56' - 'client-57' + - 'client-80' - 'cluster-56' - 'cluster-57' + - 'cluster-80' - 'server-56' - 'server-57' + - 'server-80' exclude: - os: centos-8 suite: client-56 diff --git a/CHANGELOG.md b/CHANGELOG.md index 585bc061..71b952c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This file is used to list changes made in each version of the percona cookbook. - Add support for Ubuntu 20.04 for 5.7 only - Add support for CentOS 8 - Add cluster suite and tests to test cluster recipe +- Add support for Percona 8.0 and default to that version ### Fixed diff --git a/README.md b/README.md index 2d2387c6..2fa7bf62 100644 --- a/README.md +++ b/README.md @@ -207,7 +207,7 @@ Now you need to bring three servers up one at a time with the percona role appli ## Attributes ```ruby -default["percona"]["version"] = "5.6" +default["percona"]["version"] = "8.0" version = node["percona"]["version"] # Always restart percona on configuration changes diff --git a/attributes/client.rb b/attributes/client.rb index baa4d710..f526f070 100644 --- a/attributes/client.rb +++ b/attributes/client.rb @@ -18,6 +18,8 @@ %W( percona-xtradb-cluster-client-#{version} ) + elsif node['percona']['version'].to_f >= 8.0 + %w(percona-server-client) else %W( percona-server-client-#{version} @@ -29,6 +31,8 @@ %W( Percona-XtraDB-Cluster-client-#{version} ) + elsif node['percona']['version'].to_f >= 8.0 + %w(percona-server-client) else %W( Percona-Server-client-#{version} diff --git a/attributes/default.rb b/attributes/default.rb index 84dc8879..992415ff 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -8,7 +8,7 @@ ::Chef::Node.include ::OpenSSLCookbook::RandomPassword end -default['percona']['version'] = '5.6' +default['percona']['version'] = '8.0' # Always restart percona on configuration changes default['percona']['auto_restart'] = true @@ -55,6 +55,14 @@ # Basic Settings default['percona']['server']['role'] = ['standalone'] +default['percona']['server']['package'] = + if node['percona']['version'].to_f >= 8.0 + 'percona-server-server' + elsif platform_family?('debian') + "percona-server-server-#{node['percona']['version']}" + else + "Percona-Server-server-#{node['percona']['version'].tr('.', '')}" + end default['percona']['server']['username'] = 'mysql' default['percona']['server']['datadir'] = '/var/lib/mysql' default['percona']['server']['logdir'] = '/var/log/mysql' @@ -153,7 +161,7 @@ default['percona']['server']['log_bin_basename'] = 'master-bin' # 5.6~> default: datadir + '/' + hostname + '-bin' default['percona']['server']['relay_log'] = 'slave-relay-bin' default['percona']['server']['log_slave_updates'] = false -default['percona']['server']['log_warnings'] = true +default['percona']['server']['log_warnings'] = !(node['percona']['version'].to_f >= 8.0) default['percona']['server']['log_long_format'] = false default['percona']['server']['bulk_insert_buffer_size'] = '64M' default['percona']['server']['sync_master_info'] = false @@ -234,6 +242,14 @@ end # XtraDB Cluster Settings +default['percona']['cluster']['package'] = + if node['percona']['version'].to_f >= 8.0 + 'percona-xtradb-cluster-server' + elsif platform_family?('rhel') + "Percona-XtraDB-Cluster-#{node['percona']['version'].tr('.', '')}" + else + "percona-xtradb-cluster-#{node['percona']['version'].tr('.', '')}" + end default['percona']['cluster']['binlog_format'] = 'ROW' default['percona']['cluster']['wsrep_provider'] = value_for_platform_family( 'debian' => '/usr/lib/libgalera_smm.so', diff --git a/attributes/package_repo.rb b/attributes/package_repo.rb index c9df2196..c2245223 100644 --- a/attributes/package_repo.rb +++ b/attributes/package_repo.rb @@ -4,6 +4,9 @@ # default['percona']['use_percona_repos'] = true +# From 8.0 onward, Percona has split up each product into individual repositories +# See https://www.percona.com/doc/percona-repo-config/index.html for more information +default['percona']['repositories'] = %w(ps-80) default['percona']['apt']['key'] = '8507EFA5' default['percona']['apt']['keyserver'] = 'hkp://keys.gnupg.net:80' default['percona']['apt']['uri'] = 'http://repo.percona.com/apt' diff --git a/kitchen.yml b/kitchen.yml index 089a8ca5..3759177f 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -41,6 +41,12 @@ suites: attributes: percona: version: '5.7' + - name: client-80 + run_list: + - recipe[test::client] + attributes: + percona: + version: '8.0' - name: server-56 run_list: - recipe[test::server] @@ -57,6 +63,12 @@ suites: attributes: percona: version: '5.7' + - name: server-80 + run_list: + - recipe[test::server] + attributes: + percona: + version: '8.0' - name: cluster-56 run_list: - recipe[test::cluster] @@ -73,3 +85,9 @@ suites: attributes: percona: version: '5.7' + - name: cluster-80 + run_list: + - recipe[test::cluster] + attributes: + percona: + version: '8.0' diff --git a/recipes/cluster.rb b/recipes/cluster.rb index c8103764..b1a91084 100644 --- a/recipes/cluster.rb +++ b/recipes/cluster.rb @@ -3,6 +3,7 @@ # Recipe:: cluster # +node.default['percona']['repositories'] = %w(pxc-80) include_recipe 'percona::package_repo' # Determine and set wsrep_sst_receive_address @@ -14,13 +15,6 @@ node.default['percona']['cluster']['wsrep_sst_receive_address'] = address end -# set default package attributes -version = node['percona']['version'] -node.default['percona']['cluster']['package'] = value_for_platform_family( - 'rhel' => "Percona-XtraDB-Cluster-#{version.tr('.', '')}", - 'debian' => "percona-xtradb-cluster-#{version.tr('.', '')}" -) - # This is required for `socat` per: # www.percona.com/doc/percona-xtradb-cluster/5.6/installation/yum_repo.html include_recipe 'yum-epel' if platform_family?('rhel') diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index e0d4531f..b384df75 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -19,11 +19,21 @@ components ['main'] keyserver node['percona']['apt']['keyserver'] key node['percona']['apt']['key'] - not_if "apt-key list | grep #{node['percona']['apt']['key'][-8, 8]}" + end + + if node['percona']['version'].to_f >= 8.0 + node['percona']['repositories'].each do |repo| + apt_repository "percona-#{repo}" do + uri "http://repo.percona.com/#{repo}/apt" + components ['main'] + keyserver node['percona']['apt']['keyserver'] + key node['percona']['apt']['key'] + end + end end when 'rhel' - yum_repository "percona-#{node['kernel']['machine']}" do + yum_repository 'percona' do description node['percona']['yum']['description'] baseurl "#{node['percona']['yum']['baseurl']}/$basearch" gpgkey node['percona']['yum']['gpgkey'] @@ -31,8 +41,20 @@ sslverify node['percona']['yum']['sslverify'] end + if node['percona']['version'].to_f >= 8.0 + node['percona']['repositories'].each do |repo| + yum_repository "percona-#{repo}" do + description node['percona']['yum']['description'] + ' - ' + repo + baseurl "http://repo.percona.com/#{repo}/yum/release/$releasever/RPMS/$basearch" + gpgkey node['percona']['yum']['gpgkey'] + gpgcheck node['percona']['yum']['gpgcheck'] + sslverify node['percona']['yum']['sslverify'] + end + end + end + yum_repository 'percona-noarch' do - description node['percona']['yum']['description'] + description node['percona']['yum']['description'] + ' - noarch' baseurl "#{node['percona']['yum']['baseurl']}/noarch" gpgkey node['percona']['yum']['gpgkey'] gpgcheck node['percona']['yum']['gpgcheck'] diff --git a/recipes/server.rb b/recipes/server.rb index f7b4990c..a29c5db0 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -5,21 +5,14 @@ include_recipe 'percona::package_repo' -version = node['percona']['version'] - # install packages case node['platform_family'] when 'debian' - node.default['percona']['server']['package'] = "percona-server-server-#{version}" - package node['percona']['server']['package'] do options '--force-yes' action node['percona']['server']['package_action'].to_sym end when 'rhel' - node.default['percona']['server']['package'] = "Percona-Server-server-#{version.tr('.', '')}" - node.default['percona']['server']['shared_pkg'] = "Percona-Server-shared-#{version.tr('.', '')}" - # we need mysqladmin include_recipe 'percona::client' diff --git a/recipes/toolkit.rb b/recipes/toolkit.rb index 7237925e..328b69d3 100644 --- a/recipes/toolkit.rb +++ b/recipes/toolkit.rb @@ -5,6 +5,7 @@ include_recipe 'percona::package_repo' -package 'percona-toolkit' do - options '--force-yes' if platform_family?('debian') +unless node['percona']['version'].to_f >= 8.0 && platform_family?('rhel') && + node['platform_version'].to_i >= 8 + package 'percona-toolkit' end diff --git a/spec/package_repo_spec.rb b/spec/package_repo_spec.rb index e4554f34..a9ad4168 100644 --- a/spec/package_repo_spec.rb +++ b/spec/package_repo_spec.rb @@ -21,7 +21,7 @@ platform 'centos' it do - expect(chef_run).to create_yum_repository('percona-x86_64').with( + expect(chef_run).to create_yum_repository('percona').with( gpgkey: [ 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', diff --git a/templates/grants.sql.erb b/templates/grants.sql.erb index e49b1b3d..5b896223 100644 --- a/templates/grants.sql.erb +++ b/templates/grants.sql.erb @@ -7,19 +7,28 @@ <%= "GRANT #{priv} ON #{loc} TO '#{@debian_user}'@'localhost';" %> <% end -%> SET PASSWORD FOR '<%= @debian_user %>'@'localhost' = PASSWORD('<%= @debian_password %>'); -<% end -%> - +<% end -%> <% if node["percona"]["backup"]["configure"] %> # Grant permissions for the XtraBackup user # Ensure the user exists, then revoke all grants, then re-grant specific permissions +<% if node["percona"]["version"].to_f >= 8.0 %> +CREATE USER IF NOT EXISTS '<%= node["percona"]["backup"]["username"] %>'@'localhost' IDENTIFIED BY '<%= @backup_password %>'; +GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '<%= node["percona"]["backup"]["username"] %>'@'localhost'; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM '<%= node["percona"]["backup"]["username"] %>'@'localhost'; +GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '<%= node["percona"]["backup"]["username"] %>'@'localhost'; +<% else -%> GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '<%= node["percona"]["backup"]["username"] %>'@'localhost' IDENTIFIED BY '<%= @backup_password %>'; REVOKE ALL PRIVILEGES, GRANT OPTION FROM '<%= node["percona"]["backup"]["username"] %>'@'localhost'; GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '<%= node["percona"]["backup"]["username"] %>'@'localhost' IDENTIFIED BY '<%= @backup_password %>'; <% end -%> +<% end -%> # Set the server root password. This should be preseeded by the package installation. +<% if node["percona"]["version"].to_f >= 8.0 %> +ALTER USER 'root'@'localhost' IDENTIFIED BY '<%= @root_password %>'; +<% else -%> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<%= @root_password %>'); - +<% end -%> FLUSH PRIVILEGES; diff --git a/templates/my.cnf.cluster.erb b/templates/my.cnf.cluster.erb index 9ea5db7e..0a10eca9 100644 --- a/templates/my.cnf.cluster.erb +++ b/templates/my.cnf.cluster.erb @@ -252,6 +252,7 @@ table_definition_cache = <%= node["percona"]["server"]["table_definition_cache" table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> #thread_concurrency = 10 +<%- if node["percona"]["version"].to_f < 8.0 %> # # # * Query Cache Configuration @@ -260,6 +261,7 @@ query_cache_limit = <%= node["percona"]["server"]["query_cache_limit"] %> query_cache_size = <%= node["percona"]["server"]["query_cache_size"] %> query_cache_type = <%= node["percona"]["server"]["query_cache_type"] %> +<%- end %> # # * Logging and Replication # @@ -531,12 +533,14 @@ innodb_autoextend_increment = <%= node["percona"]["server"]["innodb_autoextend_i <% if node["percona"]["server"]["innodb_file_per_table"] %> innodb_file_per_table <% end %> +<%- if node["percona"]["version"].to_f < 8.0 %> # The file format to use for new InnoDB tables. # Currently Antelope and Barracuda are supported. # This applies only for tables that have their own tablespace, # so for it to have an effect innodb_file_per_table must be enabled. innodb_file_format = <%= node["percona"]["server"]["innodb_file_format"] %> +<% end %> # Set this option if you would like the InnoDB tablespace files to be # stored in another location. By default this is the MySQL datadir. diff --git a/templates/my.cnf.main.erb b/templates/my.cnf.main.erb index 59a1ed93..2e260875 100644 --- a/templates/my.cnf.main.erb +++ b/templates/my.cnf.main.erb @@ -238,6 +238,8 @@ table_definition_cache = <%= node["percona"]["server"]["table_definition_cache" table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> #thread_concurrency = 10 +<%- if node["percona"]["version"].to_f < 8.0 %> +# # # * Query Cache Configuration # @@ -261,6 +263,7 @@ query_cache_limit = <%= node["percona"]["server"]["query_cache_limit"] %> query_cache_type = <%= node["percona"]["server"]["query_cache_type"] %> +<%- end %> # # * Logging and Replication # @@ -549,12 +552,14 @@ innodb_autoextend_increment = <%= node["percona"]["server"]["innodb_autoextend_i <% if node["percona"]["server"]["innodb_file_per_table"] %> innodb_file_per_table <% end %> +<%- if node["percona"]["version"].to_f < 8.0 %> # The file format to use for new InnoDB tables. # Currently Antelope and Barracuda are supported. # This applies only for tables that have their own tablespace, # so for it to have an effect innodb_file_per_table must be enabled. innodb_file_format = <%= node["percona"]["server"]["innodb_file_format"] %> +<% end %> # Set this option if you would like the InnoDB tablespace files to be # stored in another location. By default this is the MySQL datadir. diff --git a/test/integration/client-80/client_spec.rb b/test/integration/client-80/client_spec.rb new file mode 100644 index 00000000..c35af487 --- /dev/null +++ b/test/integration/client-80/client_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/client_spec.rb' + +client_test('8.0') diff --git a/test/integration/cluster-80/cluster_spec.rb b/test/integration/cluster-80/cluster_spec.rb new file mode 100644 index 00000000..0f799ff1 --- /dev/null +++ b/test/integration/cluster-80/cluster_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('8.0', 'cluster') diff --git a/test/integration/helpers/client_spec.rb b/test/integration/helpers/client_spec.rb index b28b5367..4fa40e40 100644 --- a/test/integration/helpers/client_spec.rb +++ b/test/integration/helpers/client_spec.rb @@ -2,7 +2,11 @@ def client_test(version) if os.family == 'debian' describe file '/etc/apt/sources.list.d/percona.list' do it { should be_a_file } - its('content') { should match 'http://repo.percona.com/apt' } + if version.to_f >= 8.0 + its('content') { should match 'http://repo.percona.com/ps-80/apt' } + else + its('content') { should match 'http://repo.percona.com/apt' } + end end describe file '/etc/apt/preferences.d/00percona.pref' do @@ -10,12 +14,19 @@ def client_test(version) its('content') { should match 'release o=Percona Development Team' } end - describe package "percona-server-client-#{version}" do - it { should be_installed } + if version.to_f >= 8.0 + describe package 'percona-server-client' do + it { should be_installed } + its('version') { should >= '8' } + end + else + describe package "percona-server-client-#{version}" do + it { should be_installed } + end end else - describe yum.repo 'percona-x86_64' do + describe yum.repo 'percona' do it { should exist } it { should be_enabled } end @@ -25,17 +36,34 @@ def client_test(version) it { should be_enabled } end - describe package "Percona-Server-client-#{version.tr('.', '')}" do - it { should be_installed } + if version.to_f >= 8.0 + describe package 'percona-server-client' do + it { should be_installed } + its('version') { should >= '8' } + end + else + describe package "Percona-Server-client-#{version.tr('.', '')}" do + it { should be_installed } + end end end - describe package 'percona-toolkit' do - it { should be_installed } + if version.to_f >= 8.0 && os.family == 'redhat' && os.release.to_i >= 8 + describe package 'percona-toolkit' do + it { should_not be_installed } + end + else + describe package 'percona-toolkit' do + it { should be_installed } + end end describe command 'mysql --version' do its('exit_status') { should eq 0 } - its('stdout') { should match /Distrib #{version.tr('.', '\.')}.+/ } + if version.to_f >= 8.0 + its('stdout') { should match /Ver #{version.tr('.', '\.')}.+/ } + else + its('stdout') { should match /Distrib #{version.tr('.', '\.')}.+/ } + end end end diff --git a/test/integration/helpers/server_spec.rb b/test/integration/helpers/server_spec.rb index 3984574c..560434a9 100644 --- a/test/integration/helpers/server_spec.rb +++ b/test/integration/helpers/server_spec.rb @@ -2,12 +2,26 @@ def server_test(version, type) if os.family == 'debian' case type when 'server' - describe package "percona-server-server-#{version}" do - it { should be_installed } + if version.to_f >= 8.0 + describe package 'percona-server-server' do + it { should be_installed } + its('version') { should >= '8.0' } + end + else + describe package "percona-server-server-#{version}" do + it { should be_installed } + end end when 'cluster' - describe package "percona-xtradb-cluster-#{version.tr('.', '')}" do - it { should be_installed } + if version.to_f >= 8.0 + describe package 'percona-xtradb-cluster-server' do + it { should be_installed } + its('version') { should >= '1:8.0' } + end + else + describe package "percona-xtradb-cluster-#{version.tr('.', '')}" do + it { should be_installed } + end end end @@ -25,7 +39,11 @@ def server_test(version, type) end describe package xtrabackup_pkg do - it { should be_installed } + if version.to_f >= 8.0 && type == 'cluster' + it { should_not be_installed } + else + it { should be_installed } + end end jemalloc_pkg = @@ -154,14 +172,6 @@ def server_test(version, type) it { should be_listening } end - # user_frm = version.to_f < 5.7 ? '/var/lib/mysql/mysql/user.frm' : '/tmp/mysql/mysql/user.frm' - - describe file '/tmp/mysql/mysql/user.frm' do - it { should be_a_file } - its('owner') { should cmp 'mysql' } - its('group') { should cmp 'mysql' } - end - describe file '/etc/mysql/grants.sql' do it { should be_a_file } its('owner') { should cmp 'root' } @@ -180,6 +190,7 @@ def server_test(version, type) its('group') { should cmp 'mysql' } end + mysql_file = version.to_f >= 8.0 ? '/tmp/mysql/mysql.ibd' : '/tmp/mysql/mysql/user.frm' mysql_mode = version.to_f < 5.7 ? '0660' : '0640' describe file '/tmp/mysql/ibdata1' do @@ -189,7 +200,7 @@ def server_test(version, type) its('mode') { should cmp mysql_mode } end - describe file '/tmp/mysql/mysql/user.frm' do + describe file mysql_file do it { should be_a_file } its('owner') { should cmp 'mysql' } its('group') { should cmp 'mysql' } diff --git a/test/integration/server-80/server_spec.rb b/test/integration/server-80/server_spec.rb new file mode 100644 index 00000000..7ef9eecc --- /dev/null +++ b/test/integration/server-80/server_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('8.0', 'server') From 0e1afcff126f53129e005906b884bf60df427b50 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Wed, 5 Aug 2020 15:07:35 -0700 Subject: [PATCH 139/300] Remove references to EOL 5.5 release Percona 5.5 has been deprecated since December 1st, 2018 [1] [1] https://www.percona.com/blog/2018/11/21/percona-server-for-mysql-5-5-62-38-14-is-now-available/ Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + templates/my.cnf.cluster.erb | 36 +++++++-------------------------- templates/my.cnf.main.erb | 39 ++++++------------------------------ 3 files changed, 14 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71b952c6..fa652be4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ This file is used to list changes made in each version of the percona cookbook. - Remove support for Debian 8 (EOL) - Remove support for Fedora / Scientific - Remove support for CentOS 6 +- Remove references to EOL 5.5 release ### Deprecated diff --git a/templates/my.cnf.cluster.erb b/templates/my.cnf.cluster.erb index 0a10eca9..aec40f26 100644 --- a/templates/my.cnf.cluster.erb +++ b/templates/my.cnf.cluster.erb @@ -112,11 +112,9 @@ old_passwords = <%= @old_passwords %> bind-address = <%= node["percona"]["server"]["bind_address"] %> <% end %> -<%- if node["percona"]["version"] >= "5.5" %> # As of 5.6.6 performance_schema is enabled by default. This allows it to be # explicitly turned on or off as needed across all mysql versions performance_schema=<%= node["percona"]["server"]["performance_schema"] ? "ON" : "OFF" %> -<% end %> # # * Fine Tuning @@ -208,11 +206,7 @@ thread_cache_size = <%= node["percona"]["server"]["thread_cache_size"] %> # This replaces the startup script and checks MyISAM tables if needed # the first time they are touched -<%- if node["percona"]["version"] < "5.5" %> -myisam-recover = <%= node["percona"]["server"]["myisam_recover_options"] %> -<% else %> myisam-recover-options = <%= node["percona"]["server"]["myisam_recover_options"] %> -<% end %> # back_log is the number of connections the operating system can keep in @@ -238,7 +232,7 @@ sql-mode = <%= node["percona"]["server"]["sql_modes"].join(",") %> # The number of open tables for all threads. # make sure that the open file limit is at least twice this in the # mysqld_safe section -<%- if node["percona"]["version"] >= "5.6" %> +<%- if node["percona"]["version"].to_f >= 5.6 %> table_open_cache = <%= node["percona"]["server"]["table_cache"] %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- else %> @@ -326,12 +320,8 @@ replicate-ignore-table = <%= ignore_table %> <% if node["percona"]["server"]["replication"]["suppress_1592"] %> #turns off this statement is unsafe in statement-based replication -<% if node["percona"]["version"] < "5.5" -%> -suppress_log_warning_1592 -<% else %> log_warnings_suppress=1592 <% end %> -<% end %> # Make the slave read-only. Only users with the SUPER privilege and the # replication slave thread will be able to modify data on it. You can @@ -361,20 +351,8 @@ slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_ # https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin_basename # it is recommened to specify a filename for the binary log, hopefully # something that is not host specific. I've chosen master-bin. -<%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> +<%- if node["percona"]["version"].to_f >= 5.6 and node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> log_bin = <%= node["percona"]["server"]["log_bin_basename"] %> -<%- else %> - <%- unless [1,'1',0,'0','OFF','off',''].include?(node["percona"]["server"]["log_bin"]) %> - <%# from toady point log_bin attr. was missused in the cookbook in the past %> - <%# and contained more or less the base-name %> -log_bin = <%= node["percona"]["server"]["log_bin"] %> - <%- else %> - # to allow on <= 5.5 useage of log_bin_basename - # introduced by this PR - <%- if node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> -log_bin = <%= node["percona"]["server"]["log_bin_basename"] %> - <%- end %> - <%- end %> <%- end %> <% unless node["percona"]["server"]["relay_log"].empty? %> @@ -385,7 +363,7 @@ expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> slave_net_timeout = <%= node["percona"]["server"]["slave_net_timeout"] %> -<%- if node["percona"]["version"] >= "5.6" %> +<%- if node["percona"]["version"].to_f >= 5.6 %> binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> <% if node["percona"]["server"]["master_verify_checksum"] %> master_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> @@ -407,7 +385,7 @@ binlog-do-db = <%= db_name %> binlog-ignore-db = <%= db_name %> <% end -%> -<%- if node["percona"]["version"] >= "5.6" %> +<%- if node["percona"]["version"].to_f >= 5.6 %> gtid_mode = <%= node["percona"]["server"]["gtid_mode"] %> <% if node["percona"]["server"]["enforce_gtid_consistency"] %> enforce_gtid_consistency = <%= node["percona"]["server"]["enforce_gtid_consistency"] %> @@ -478,7 +456,7 @@ myisam_max_sort_file_size = <%= node["percona"]["server"]["myisam_max_sort_file_ # have multiple CPUs and plenty of memory. myisam_repair_threads = <%= node["percona"]["server"]["myisam_repair_threads"] %> -<%- if node["percona"]["version"] < "5.7" %> +<%- if node["percona"]["version"].to_f < 5.7 %> # Automatically check and repair not properly closed MyISAM tables. <% if node["percona"]["server"]["myisam_recover_options"] %> myisam_recover @@ -498,7 +476,7 @@ myisam_recover skip-innodb <% end %> -<%- if node["percona"]["version"] < "5.7.4" %> +<%- if node["percona"]["version"].to_f < 5.7 %> # Additional memory pool that is used by InnoDB to store metadata # information. If InnoDB requires more memory for this purpose it will # start to allocate it from the OS. As this is fast enough on most @@ -633,7 +611,7 @@ innodb_commit_concurrency=0 innodb_open_files=<%= node["percona"]["server"]["innodb_open_files"] %> -<%- if node["percona"]["version"] >= "5.6" %> +<%- if node["percona"]["version"].to_f >= 5.6 %> innodb_numa_interleave=<%= node["percona"]["server"]["innodb_numa_interleave"] %> <%- end %> diff --git a/templates/my.cnf.main.erb b/templates/my.cnf.main.erb index 2e260875..75b1c69b 100644 --- a/templates/my.cnf.main.erb +++ b/templates/my.cnf.main.erb @@ -96,11 +96,9 @@ bind-address = <%= node["percona"]["server"]["bind_address"] %> <% end %> # -<%- if node["percona"]["version"] >= "5.5" %> # As of 5.6.6 performance_schema is enabled by default. This allows it to be # explicitly turned on or off as needed across all mysql versions performance_schema=<%= node["percona"]["server"]["performance_schema"] ? "ON" : "OFF" %> -<% end %> # * Fine Tuning # @@ -194,11 +192,7 @@ thread_cache_size = <%= node["percona"]["server"]["thread_cache_size"] %> # This replaces the startup script and checks MyISAM tables if needed # the first time they are touched -<%- if node["percona"]["version"] < "5.5" %> -myisam-recover = <%= node["percona"]["server"]["myisam_recover_options"] %> -<% else %> myisam-recover-options = <%= node["percona"]["server"]["myisam_recover_options"] %> -<% end %> # back_log is the number of connections the operating system can keep in # the listen queue, before the MySQL connection manager thread has @@ -224,7 +218,7 @@ sql-mode = <%= node["percona"]["server"]["sql_modes"].join(",") %> # The number of open tables for all threads. # make sure that the open file limit is at least twice this in the # mysqld_safe section -<%- if node["percona"]["version"] >= "5.6" %> +<%- if node["percona"]["version"].to_f >= 5.6 %> table_open_cache = <%= node["percona"]["server"]["table_cache"] %> table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> <%- else %> @@ -328,12 +322,8 @@ replicate-ignore-table = <%= ignore_table %> <% if node["percona"]["server"]["replication"]["suppress_1592"] %> #turns off this statement is unsafe in statement-based replication -<% if node["percona"]["version"] < "5.5" -%> -suppress_log_warning_1592 -<% else %> log_warnings_suppress=1592 <% end %> -<% end %> # Make the slave read-only. Only users with the SUPER privilege and the # replication slave thread will be able to modify data on it. You can @@ -364,20 +354,8 @@ slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_ # https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#sysvar_log_bin_basename # it is recommened to specify a filename for the binary log, hopefully # something that is not host specific. I've chosen master-bin. -<%- if node["percona"]["version"] >= "5.6" and node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> -log_bin = <%= node["percona"]["server"]["log_bin_basename"] %> -<%- else %> - <%- unless [1,'1',0,'0','OFF','off',''].include?(node["percona"]["server"]["log_bin"]) %> - <%# from toady point log_bin attr. was missused in the cookbook in the past %> - <%# and contained more or less the base-name %> -log_bin = <%= node["percona"]["server"]["log_bin"] %> - <%- else %> - # to allow on <= 5.5 useage of log_bin_basename - # introduced by this PR - <%- if node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> +<%- if node["percona"]["version"].to_f >= 5.6 and node["percona"]["server"].key?('log_bin_basename') and !node["percona"]["server"]["log_bin_basename"].empty? %> log_bin = <%= node["percona"]["server"]["log_bin_basename"] %> - <%- end %> - <%- end %> <%- end %> <% unless node["percona"]["server"]["relay_log"].empty? %> @@ -388,7 +366,7 @@ expire_logs_days = <%= node["percona"]["server"]["expire_logs_days"] %> max_binlog_size = <%= node["percona"]["server"]["max_binlog_size"] %> binlog_format = <%= node["percona"]["server"]["binlog_format"] %> slave_net_timeout = <%= node["percona"]["server"]["slave_net_timeout"] %> -<%- if node["percona"]["version"] >= "5.6" %> +<%- if node["percona"]["version"].to_f >= 5.6 %> binlog_checksum = <%= node["percona"]["server"]["binlog_checksum"] %> <% if node["percona"]["server"]["master_verify_checksum"] %> master_verify_checksum = <%= node["percona"]["server"]["master_verify_checksum"] %> @@ -410,7 +388,7 @@ binlog-do-db = <%= db_name %> binlog-ignore-db = <%= db_name %> <% end -%> -<%- if node["percona"]["version"] >= "5.6" %> +<%- if node["percona"]["version"].to_f >= 5.6 %> gtid_mode = <%= node["percona"]["server"]["gtid_mode"] %> <% if node["percona"]["server"]["enforce_gtid_consistency"] %> enforce_gtid_consistency = <%= node["percona"]["server"]["enforce_gtid_consistency"] %> @@ -499,7 +477,7 @@ myisam_max_sort_file_size = <%= node["percona"]["server"]["myisam_max_sort_file_ # have multiple CPUs and plenty of memory. myisam_repair_threads = <%= node["percona"]["server"]["myisam_repair_threads"] %> -<%- if node["percona"]["version"] < "5.7" %> +<%- if node["percona"]["version"].to_f < 5.7 %> # Automatically check and repair not properly closed MyISAM tables. <% if node["percona"]["server"]["myisam_recover_options"] %> myisam_recover @@ -652,15 +630,10 @@ innodb_commit_concurrency=0 innodb_open_files=<%= node["percona"]["server"]["innodb_open_files"] %> -<%- if node["percona"]["version"] >= "5.6" %> +<%- if node["percona"]["version"].to_f >= 5.6 %> innodb_numa_interleave=<%= node["percona"]["server"]["innodb_numa_interleave"] %> <%- end %> -<% if node["percona"]["version"] == "5.5" %> -# set this to 1 if you like to import single tables from xtrabackup snapshot -innodb_import_table_from_xtrabackup = <%= node["percona"]["server"]["innodb_import_table_from_xtrabackup"] %> -<% end %> - # # * Security Features # From 05fcaab5e8a909ea7ede3f82fc90aaf1d4e35a17 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Wed, 5 Aug 2020 16:06:03 -0700 Subject: [PATCH 140/300] Fix apt tests for client suite Signed-off-by: Lance Albertson --- test/integration/helpers/client_spec.rb | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/integration/helpers/client_spec.rb b/test/integration/helpers/client_spec.rb index 4fa40e40..bd599771 100644 --- a/test/integration/helpers/client_spec.rb +++ b/test/integration/helpers/client_spec.rb @@ -1,11 +1,19 @@ def client_test(version) if os.family == 'debian' - describe file '/etc/apt/sources.list.d/percona.list' do - it { should be_a_file } - if version.to_f >= 8.0 - its('content') { should match 'http://repo.percona.com/ps-80/apt' } - else - its('content') { should match 'http://repo.percona.com/apt' } + describe apt 'http://repo.percona.com/apt' do + it { should exist } + it { should be_enabled } + end + + if version.to_f >= 8.0 + describe apt 'http://repo.percona.com/ps-80/apt' do + it { should exist } + it { should be_enabled } + end + else + describe apt 'http://repo.percona.com/ps-80/apt' do + it { should_not exist } + it { should_not be_enabled } end end From db4c423cc7f65129cb64d370fd2fc117dd256b71 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Wed, 5 Aug 2020 16:17:14 -0700 Subject: [PATCH 141/300] Provide useful debug information if kitchen fails Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60aeebde..8ee37272 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,6 +98,18 @@ jobs: with: suite: ${{ matrix.suite }} os: ${{ matrix.os }} + - name: Print debug output on failure + if: failure() + run: | + set -x + sudo journalctl -l --since today + sudo docker version + sudo docker info + KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "journalctl -l" + KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "cat /var/log/mysql/error.log" + KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "mount" + KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "cat /etc/mtab" + KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "ls -l /var/lib/mysql/ /tmp/mysql/" final: needs: [dokken] From 23d464b2805d7469ef776bc19b3f5dd475d620cc Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 6 Aug 2020 15:51:52 -0700 Subject: [PATCH 142/300] Update mdlrc Signed-off-by: Lance Albertson --- .mdlrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mdlrc b/.mdlrc index b7e08259..ebeef65e 100644 --- a/.mdlrc +++ b/.mdlrc @@ -1 +1 @@ -rules "~MD013" +rules "~MD013", "~MD024" From 1275d4e7dfe6889369c20801e472b69c19e2e8da Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Fri, 7 Aug 2020 17:03:19 -0700 Subject: [PATCH 143/300] Re-add ChefSpec tests This re-adds all of the ChefSpec tests and also updates them to match the changes that have been made. Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + spec/access_grants_spec.rb | 101 +++--- spec/backup_spec.rb | 62 ++-- spec/client_spec.rb | 130 +++---- spec/cluster_spec.rb | 202 +++++------ spec/configure_server_spec.rb | 624 +++++++++++++++++++--------------- spec/default_spec.rb | 4 - spec/package_repo_spec.rb | 66 +++- spec/replication_spec.rb | 104 +++--- spec/server_spec.rb | 200 ++++++----- spec/ssl_spec.rb | 131 ++++--- spec/toolkit_spec.rb | 65 ++-- 12 files changed, 906 insertions(+), 784 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa652be4..d8bc6db4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This file is used to list changes made in each version of the percona cookbook. - Add support for CentOS 8 - Add cluster suite and tests to test cluster recipe - Add support for Percona 8.0 and default to that version +- Re-add ChefSpec tests ### Fixed diff --git a/spec/access_grants_spec.rb b/spec/access_grants_spec.rb index 0c35c094..babf97ae 100644 --- a/spec/access_grants_spec.rb +++ b/spec/access_grants_spec.rb @@ -1,42 +1,59 @@ -# require 'spec_helper' - -# describe 'percona::access_grants' do -# let(:grant_file) do -# '/etc/mysql/grants.sql' -# end - -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['server']['root_password'] = 's3kr1t' -# end.converge(described_recipe) -# end - -# it 'writes the `grants.sql` file' do -# expect(chef_run).to create_template(grant_file).with( -# owner: 'root', -# group: 'root', -# mode: '0600', -# sensitive: true -# ) -# end - -# it 'adds the root password to `grants.sql`' do -# expect(chef_run).to render_file(grant_file).with_content( -# "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('s3kr1t')" -# ) -# end - -# it 'executes the `install privileges` command' do -# expect(chef_run).to_not run_execute('mysql-install-privileges') - -# exec_resource = chef_run.execute('mysql-install-privileges') -# expect(exec_resource).to( -# subscribe_to("template[#{grant_file}]").on(:run).immediately -# ) - -# tmpl_resource = chef_run.template(grant_file) -# expect(tmpl_resource).to( -# notify('execute[mysql-install-privileges]').to(:run).immediately -# ) -# end -# end +require 'spec_helper' + +describe 'percona::access_grants' do + platform 'ubuntu' + + let(:grant_file) do + '/etc/mysql/grants.sql' + end + + override_attributes['percona']['server']['root_password'] = 's3kr1t' + override_attributes['percona']['server']['debian_password'] = 's3kr1t' + override_attributes['percona']['backup']['password'] = 's3kr1t' + + it 'writes the `grants.sql` file' do + expect(chef_run).to create_template(grant_file).with( + owner: 'root', + group: 'root', + mode: '0600', + sensitive: true, + variables: { + root_password: 's3kr1t', + debian_password: 's3kr1t', + backup_password: 's3kr1t', + debian_user: 'debian-sys-maint', + } + ) + end + + it 'adds the root password to `grants.sql`' do + expect(chef_run).to render_file(grant_file).with_content( + "ALTER USER 'root'@'localhost' IDENTIFIED BY 's3kr1t';" + ) + end + + context 'Percona < 8.0' do + override_attributes['percona']['version'] = '5.7' + override_attributes['percona']['server']['root_password'] = 's3kr1t' + it 'adds the root password to `grants.sql`' do + expect(chef_run).to render_file(grant_file).with_content( + "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('s3kr1t');" + ) + end + end + + it 'executes the `install privileges` command' do + expect(chef_run).to nothing_execute('mysql-install-privileges') + .with(command: "/usr/bin/mysql -p's3kr1t' -e '' &> /dev/null > /dev/null &> /dev/null ; if [ $? -eq 0 ] ; then /usr/bin/mysql -p's3kr1t' < /etc/mysql/grants.sql ; else /usr/bin/mysql < /etc/mysql/grants.sql ; fi ;") + + exec_resource = chef_run.execute('mysql-install-privileges') + expect(exec_resource).to( + subscribe_to("template[#{grant_file}]").on(:run).immediately + ) + + tmpl_resource = chef_run.template(grant_file) + expect(tmpl_resource).to( + notify('execute[mysql-install-privileges]').to(:run).immediately + ) + end +end diff --git a/spec/backup_spec.rb b/spec/backup_spec.rb index 86eb930f..84e2f396 100644 --- a/spec/backup_spec.rb +++ b/spec/backup_spec.rb @@ -1,24 +1,38 @@ -# require 'spec_helper' - -# describe 'percona::backup' do -# describe 'Ubuntu' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new.converge(described_recipe) -# end - -# it { expect(chef_run).to include_recipe('percona::package_repo') } -# it { expect(chef_run).to install_package('xtrabackup') } -# it { expect(chef_run).to include_recipe('percona::access_grants') } -# end - -# describe 'CentOS' do -# let(:chef_run) do -# env_options = { platform: 'centos', version: '6' } -# ChefSpec::SoloRunner.new(env_options).converge(described_recipe) -# end - -# it { expect(chef_run).to include_recipe('percona::package_repo') } -# it { expect(chef_run).to install_package('percona-xtrabackup') } -# it { expect(chef_run).to include_recipe('percona::access_grants') } -# end -# end +require 'spec_helper' + +describe 'percona::backup' do + context 'Ubuntu' do + platform 'ubuntu' + + it { expect(chef_run).to include_recipe('percona::package_repo') } + it { expect(chef_run).to install_package('xtrabackup') } + it { expect(chef_run).to include_recipe('percona::access_grants') } + + context 'Ubuntu 20.04' do + platform 'ubuntu', '20.04' + it { expect(chef_run).to install_package('percona-xtrabackup-80') } + end + + context 'Debian 10' do + platform 'debian', '10' + it { expect(chef_run).to install_package('percona-xtrabackup-80') } + end + end + + context 'CentOS' do + platform 'centos' + + before do + stub_command('dnf module list mysql | grep -q "^mysql.*\\[x\\]"') + end + + it { expect(chef_run).to include_recipe('percona::package_repo') } + it { expect(chef_run).to install_package('xtrabackup') } + it { expect(chef_run).to include_recipe('percona::access_grants') } + + context 'CentOS 8' do + platform 'centos', '8' + it { expect(chef_run).to install_package('percona-xtrabackup-80') } + end + end +end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 5a92caf9..730ae866 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -1,57 +1,73 @@ -# require 'spec_helper' - -# describe 'percona::client' do -# describe 'when `package_action` is `install`' do -# describe 'Ubuntu' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new.converge(described_recipe) -# end - -# specify do -# expect(chef_run).to install_package 'libperconaserverclient18.1-dev' -# expect(chef_run).to install_package 'percona-server-client-5.6' -# end -# end - -# describe 'CentOS' do -# let(:chef_run) do -# env_options = { platform: 'centos', version: '6' } -# ChefSpec::SoloRunner.new(env_options).converge(described_recipe) -# end - -# specify do -# expect(chef_run).to install_package 'Percona-Server-devel-56' -# expect(chef_run).to install_package 'Percona-Server-client-56' -# end -# end -# end - -# describe 'when `package_action` is `upgrade`' do -# describe 'Ubuntu' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['client']['package_action'] = 'upgrade' -# end.converge(described_recipe) -# end - -# specify do -# expect(chef_run).to upgrade_package 'libperconaserverclient18.1-dev' -# expect(chef_run).to upgrade_package 'percona-server-client-5.6' -# end -# end - -# describe 'CentOS' do -# let(:chef_run) do -# env_options = { platform: 'centos', version: '6' } -# ChefSpec::SoloRunner.new(env_options) do |node| -# node.default['percona']['client']['package_action'] = 'upgrade' -# end.converge(described_recipe) -# end - -# specify do -# expect(chef_run).to upgrade_package 'Percona-Server-devel-56' -# expect(chef_run).to upgrade_package 'Percona-Server-client-56' -# end -# end -# end -# end +require 'spec_helper' + +describe 'percona::client' do + before do + stub_command('dnf module list mysql | grep -q "^mysql.*\\[x\\]"') + end + + describe 'when `package_action` is `install`' do + context 'Ubuntu' do + platform 'ubuntu' + + it do + expect(chef_run).to install_package 'percona-server-client' + end + + context 'version 5.7' do + override_attributes['percona']['version'] = '5.7' + it do + expect(chef_run).to install_package 'percona-server-client-5.7' + end + end + + context 'version 5.6' do + override_attributes['percona']['version'] = '5.6' + it do + expect(chef_run).to install_package 'percona-server-client-5.6' + end + end + end + + context 'CentOS' do + platform 'centos' + + it do + expect(chef_run).to install_package 'percona-server-client' + end + + context 'version 5.7' do + override_attributes['percona']['version'] = '5.7' + it do + expect(chef_run).to install_package 'Percona-Server-client-57' + end + end + + context 'version 5.6' do + override_attributes['percona']['version'] = '5.6' + it do + expect(chef_run).to install_package 'Percona-Server-client-56' + end + end + end + end + + describe 'when `package_action` is `upgrade`' do + context 'Ubuntu' do + platform 'ubuntu' + override_attributes['percona']['client']['package_action'] = 'upgrade' + + it do + expect(chef_run).to upgrade_package 'percona-server-client' + end + end + + context 'CentOS' do + platform 'centos' + override_attributes['percona']['client']['package_action'] = 'upgrade' + + it do + expect(chef_run).to upgrade_package 'percona-server-client' + end + end + end +end diff --git a/spec/cluster_spec.rb b/spec/cluster_spec.rb index 47146dbc..3767a2be 100644 --- a/spec/cluster_spec.rb +++ b/spec/cluster_spec.rb @@ -1,113 +1,89 @@ -# require 'spec_helper' - -# describe 'percona::cluster' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new.converge(described_recipe) -# end - -# before do -# stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(true) -# stub_command("mysqladmin --user=root --password='' version") -# .and_return(true) -# end - -# specify do -# expect(chef_run).to include_recipe 'percona::package_repo' -# expect(chef_run).to include_recipe 'percona::configure_server' -# expect(chef_run).to include_recipe 'percona::access_grants' - -# expect(chef_run).to_not include_recipe 'yum-epel' -# end - -# describe 'version 5.5' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['version'] = '5.5' -# end.converge(described_recipe) -# end - -# let(:centos_cluster_package) do -# 'Percona-XtraDB-Cluster-55' -# end - -# let(:ubuntu_cluster_package) do -# 'percona-xtradb-cluster-55' -# end - -# describe 'Ubuntu' do -# specify do -# expect(chef_run).to install_package(ubuntu_cluster_package) - -# expect(chef_run.package(ubuntu_cluster_package)).to( -# notify('service[mysql]').to(:stop).immediately -# ) -# end -# end - -# describe 'CentOS' do -# let(:chef_run) do -# env_options = { platform: 'centos', version: '6' } -# ChefSpec::SoloRunner.new(env_options) do |node| -# node.default['percona']['version'] = '5.5' -# end.converge(described_recipe) -# end - -# before do -# stub_command("rpm -qa | grep -q 'Percona-XtraDB-Cluster-55'") -# .and_return(false) -# end - -# specify do -# expect(chef_run).to remove_package 'mysql-libs' -# expect(chef_run).to include_recipe 'yum-epel' -# expect(chef_run).to install_package centos_cluster_package -# end -# end -# end - -# describe 'version 5.6' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['version'] = '5.6' -# end.converge(described_recipe) -# end - -# let(:centos_cluster_package) do -# 'Percona-XtraDB-Cluster-56' -# end - -# let(:ubuntu_cluster_package) do -# 'percona-xtradb-cluster-56' -# end - -# describe 'Ubuntu' do -# specify do -# expect(chef_run).to install_package(ubuntu_cluster_package) - -# expect(chef_run.package(ubuntu_cluster_package)).to( -# notify('service[mysql]').to(:stop).immediately -# ) -# end -# end - -# describe 'CentOS' do -# let(:chef_run) do -# env_options = { platform: 'centos', version: '6' } -# ChefSpec::SoloRunner.new(env_options) do |node| -# node.default['percona']['version'] = '5.6' -# end.converge(described_recipe) -# end - -# before do -# stub_command("rpm -qa | grep -q 'Percona-XtraDB-Cluster-56'") -# .and_return(false) -# end - -# specify do -# expect(chef_run).to remove_package 'mysql-libs' -# expect(chef_run).to include_recipe 'yum-epel' -# expect(chef_run).to install_package centos_cluster_package -# end -# end -# end -# end +require 'spec_helper' + +describe 'percona::cluster' do + platform 'ubuntu' + + before do + stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(true) + stub_command("mysqladmin --user=root --password='' version").and_return(true) + stub_command('dnf module list mysql | grep -q "^mysql.*\\[x\\]"') + end + + %w( + percona::package_repo + percona::configure_server + percona::access_grants + ).each do |r| + it do + expect(chef_run).to include_recipe r + end + end + + it do + expect(chef_run).to_not include_recipe 'yum-epel' + end + + describe 'version 5.6' do + override_attributes['percona']['version'] = '5.6' + + describe 'Ubuntu' do + it do + expect(chef_run).to install_package 'percona-xtradb-cluster-56' + end + end + + describe 'CentOS' do + platform 'centos' + + it do + expect(chef_run).to include_recipe 'yum-epel' + end + + it do + expect(chef_run).to install_package 'Percona-XtraDB-Cluster-56' + end + end + end + describe 'version 5.7' do + override_attributes['percona']['version'] = '5.7' + + describe 'Ubuntu' do + it do + expect(chef_run).to install_package 'percona-xtradb-cluster-57' + end + end + + describe 'CentOS' do + platform 'centos' + + it do + expect(chef_run).to include_recipe 'yum-epel' + end + + it do + expect(chef_run).to install_package 'Percona-XtraDB-Cluster-57' + end + end + end + describe 'version 8.0' do + override_attributes['percona']['version'] = '8.0' + + describe 'Ubuntu' do + it do + expect(chef_run).to install_package 'percona-xtradb-cluster-server' + end + end + + describe 'CentOS' do + platform 'centos' + + it do + expect(chef_run).to include_recipe 'yum-epel' + end + + it do + expect(chef_run).to install_package 'percona-xtradb-cluster-server' + end + end + end +end diff --git a/spec/configure_server_spec.rb b/spec/configure_server_spec.rb index 40f663d1..333cc717 100644 --- a/spec/configure_server_spec.rb +++ b/spec/configure_server_spec.rb @@ -1,277 +1,347 @@ -# require 'spec_helper' - -# describe 'percona::configure_server' do -# describe 'first run' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new.converge(described_recipe) -# end - -# before do -# stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(false) -# stub_command("mysqladmin --user=root --password='' version") -# .and_return(true) -# end - -# it 'does not include the `chef-vault` recipe' do -# expect(chef_run).to_not include_recipe 'chef-vault' -# end - -# it 'creates the main server config file' do -# expect(chef_run).to create_template('/etc/mysql/my.cnf').with( -# owner: 'root', -# group: 'root', -# mode: '0644', -# cookbook: 'percona', -# source: 'my.cnf.main.erb' -# ) - -# expect(chef_run).to render_file('/etc/mysql/my.cnf').with_content( -# 'performance_schema=OFF' -# ) - -# resource = chef_run.template('/etc/mysql/my.cnf') -# expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately -# expect(resource).to notify('service[mysql]').to(:restart).immediately -# end - -# it 'creates the data directory' do -# expect(chef_run).to create_directory('/var/lib/mysql').with( -# owner: 'mysql', -# group: 'mysql', -# recursive: true -# ) -# end - -# it 'defines the setup for the data directory' do -# resource = chef_run.execute('setup mysql datadir') -# expect(resource).to do_nothing -# end - -# it 'creates the log directory' do -# expect(chef_run).to create_directory('log directory').with( -# path: '/var/log/mysql', -# owner: 'mysql', -# group: 'mysql', -# recursive: true -# ) -# end - -# it 'do not create duplicated slow query log directory' do -# expect(chef_run).to_not create_directory('slow query log directory').with( -# path: '/var/log/mysql', -# owner: 'mysql', -# group: 'mysql', -# recursive: true -# ) -# end - -# it 'creates the temporary directory' do -# expect(chef_run).to create_directory('/tmp').with( -# owner: 'mysql', -# group: 'mysql', -# recursive: true -# ) -# end - -# it 'creates the configuration include directory' do -# expect(chef_run).to create_directory('/etc/mysql/conf.d/').with( -# owner: 'mysql', -# group: 'mysql', -# recursive: true -# ) -# end - -# it 'updates the root user password' do -# expect(chef_run).to run_execute('Update MySQL root password') -# end -# end - -# describe 'subsequent runs' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['main_config_file'] = '/mysql/my.cnf' -# node.default['percona']['server']['root_password'] = 's3kr1t' -# node.default['percona']['server']['debian_password'] = 'd3b1an' -# node.default['percona']['server']['performance_schema'] = true -# node.default['percona']['conf']['mysqld']['datadir'] = '/mysql/data' -# node.default['percona']['conf']['mysqld']['tmpdir'] = '/mysql/tmp' -# node.default['percona']['conf']['mysqld']['includedir'] = '/mysql/conf.d' -# end.converge(described_recipe) -# end - -# before do -# stub_command('test -f /mysql/data/mysql/user.frm').and_return(true) -# stub_command("mysqladmin --user=root --password='' version") -# .and_return(false) -# end - -# it 'creates a `.my.cnf` file for root' do -# expect(chef_run).to create_template('/root/.my.cnf').with( -# owner: 'root', -# group: 'root', -# mode: '0600', -# sensitive: true -# ) - -# expect(chef_run).to render_file('/root/.my.cnf').with_content('s3kr1t') -# end - -# it 'creates the configuration directory' do -# expect(chef_run).to create_directory('/etc/mysql').with( -# owner: 'root', -# group: 'root', -# mode: '0755' -# ) -# end - -# it 'creates the data directory' do -# expect(chef_run).to create_directory('/mysql/data').with( -# owner: 'mysql', -# group: 'mysql', -# recursive: true -# ) -# end - -# it 'creates the temporary directory' do -# expect(chef_run).to create_directory('/mysql/tmp').with( -# owner: 'mysql', -# group: 'mysql', -# recursive: true -# ) -# end - -# it 'creates the configuration include directory' do -# expect(chef_run).to create_directory('/mysql/conf.d').with( -# owner: 'mysql', -# group: 'mysql', -# recursive: true -# ) -# end - -# it 'creates the slow query log directory' do -# expect(chef_run).to create_directory('/var/log/mysql').with( -# owner: 'mysql', -# group: 'mysql', -# recursive: true -# ) -# end - -# it 'manages the `mysql` service' do -# expect(chef_run).to enable_service('mysql') -# end - -# it 'defines the setup for the data directory' do -# resource = chef_run.execute('setup mysql datadir') -# expect(resource).to do_nothing -# end - -# it 'creates the main server config file' do -# expect(chef_run).to create_template('/mysql/my.cnf').with( -# owner: 'root', -# group: 'root', -# mode: '0644', -# sensitive: true, -# cookbook: 'percona', -# source: 'my.cnf.main.erb' -# ) - -# expect(chef_run).to render_file('/mysql/my.cnf').with_content( -# 'performance_schema=ON' -# ) - -# resource = chef_run.template('/mysql/my.cnf') -# expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately -# expect(resource).to notify('service[mysql]').to(:restart).immediately -# end - -# it 'does not update the root user password' do -# expect(chef_run).to_not run_execute('Update MySQL root password') -# end - -# it 'creates the debian system user config file' do -# debian_cnf = '/etc/mysql/debian.cnf' - -# expect(chef_run).to create_template(debian_cnf).with( -# owner: 'root', -# group: 'root', -# mode: '0640', -# sensitive: true -# ) - -# expect(chef_run).to render_file(debian_cnf).with_content('d3b1an') - -# resource = chef_run.template(debian_cnf) -# expect(resource).to notify('service[mysql]').to(:restart).immediately -# end -# end - -# describe 'custom slow query log directory' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['server']['slow_query_logdir'] = '/var/log/slowq' -# end.converge(described_recipe) -# end - -# before do -# stub_command("mysqladmin --user=root --password='' version") -# .and_return(true) -# end - -# it 'creates the slow query log directory' do -# expect(chef_run).to create_directory('/var/log/slowq').with( -# owner: 'mysql', -# group: 'mysql', -# recursive: true -# ) -# end -# end - -# describe '`rhel` platform family' do -# let(:chef_run) do -# env_options = { platform: 'centos', version: '6' } -# ChefSpec::SoloRunner.new(env_options).converge(described_recipe) -# end - -# before do -# stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(false) -# stub_command("mysqladmin --user=root --password='' version") -# .and_return(true) -# end - -# it 'creates the main server config file' do -# expect(chef_run).to create_template('/etc/my.cnf').with( -# owner: 'root', -# group: 'root', -# mode: '0644', -# sensitive: true, -# cookbook: 'percona', -# source: 'my.cnf.main.erb' -# ) - -# resource = chef_run.template('/etc/my.cnf') -# expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately -# expect(resource).to notify('service[mysql]').to(:restart).immediately -# end - -# it 'does not create the configuration include directory' do -# expect(chef_run).to_not create_directory('/mysql/conf.d') -# end -# end - -# describe '`chef-vault` support' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['use_chef_vault'] = true -# end.converge(described_recipe) -# end - -# before do -# stub_command("mysqladmin --user=root --password='' version") -# .and_return(false) -# end - -# it 'includes the `chef-vault` recipe' do -# expect(chef_run).to include_recipe 'chef-vault' -# end -# end -# end +require 'spec_helper' + +describe 'percona::configure_server' do + platform 'ubuntu' + describe 'first run' do + before do + stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(false) + stub_command("mysqladmin --user=root --password='' version").and_return(true) + end + + it 'does not include the `chef-vault` recipe' do + expect(chef_run).to_not include_recipe 'chef-vault' + end + + it 'creates the main server config file' do + expect(chef_run).to create_template('/etc/mysql/my.cnf').with( + owner: 'root', + group: 'root', + mode: '0644', + cookbook: 'percona', + source: 'my.cnf.main.erb', + manage_symlink_source: true + ) + + expect(chef_run).to render_file('/etc/mysql/my.cnf').with_content( + 'performance_schema=OFF' + ) + + resource = chef_run.template('/etc/mysql/my.cnf') + expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately + expect(resource).to notify('service[mysql]').to(:restart).immediately + end + + it 'creates the data directory' do + expect(chef_run).to create_directory('/var/lib/mysql').with( + owner: 'mysql', + group: 'mysql', + recursive: true + ) + end + + it 'defines the setup for the data directory' do + expect(chef_run).to nothing_execute('setup mysql datadir').with(command: 'mysqld --defaults-file=/etc/mysql/my.cnf --user=mysql --initialize-insecure') + end + + context 'version < 5.7' do + override_attributes['percona']['version'] = '5.6' + it 'defines the setup for the data directory' do + expect(chef_run).to nothing_execute('setup mysql datadir').with(command: 'mysql_install_db --defaults-file=/etc/mysql/my.cnf --user=mysql') + end + end + + it 'creates the log directory' do + expect(chef_run).to create_directory('log directory').with( + path: '/var/log/mysql', + owner: 'mysql', + group: 'mysql', + recursive: true + ) + end + + it 'do not create duplicated slow query log directory' do + expect(chef_run).to_not create_directory('slow query log directory').with( + path: '/var/log/mysql', + owner: 'mysql', + group: 'mysql', + recursive: true + ) + end + + it 'creates the temporary directory' do + expect(chef_run).to create_directory('/tmp').with( + owner: 'mysql', + group: 'mysql', + recursive: true + ) + end + + it 'creates the configuration include directory' do + expect(chef_run).to create_directory('/etc/mysql/conf.d/').with( + owner: 'mysql', + group: 'mysql', + recursive: true + ) + end + + it 'updates the root user password' do + expect(chef_run).to run_execute('Update MySQL root password') + end + end + + describe 'subsequent runs' do + override_attributes['percona']['main_config_file'] = '/mysql/my.cnf' + override_attributes['percona']['server']['root_password'] = 's3kr1t' + override_attributes['percona']['server']['debian_password'] = 'd3b1an' + override_attributes['percona']['server']['performance_schema'] = true + override_attributes['percona']['conf']['mysqld']['datadir'] = '/mysql/data' + override_attributes['percona']['conf']['mysqld']['tmpdir'] = '/mysql/tmp' + override_attributes['percona']['conf']['mysqld']['includedir'] = '/mysql/conf.d' + + before do + stub_command('test -f /mysql/data/mysql/user.frm').and_return(true) + stub_command("mysqladmin --user=root --password='' version").and_return(false) + end + + it 'creates a `.my.cnf` file for root' do + expect(chef_run).to create_template('/root/.my.cnf').with( + owner: 'root', + group: 'root', + mode: '0600', + sensitive: true + ) + + expect(chef_run).to render_file('/root/.my.cnf').with_content('s3kr1t') + end + + it 'creates the configuration directory' do + expect(chef_run).to create_directory('/etc/mysql').with( + owner: 'root', + group: 'root', + mode: '0755' + ) + end + + it 'creates the data directory' do + expect(chef_run).to create_directory('/mysql/data').with( + owner: 'mysql', + group: 'mysql', + recursive: true + ) + end + + it 'creates the temporary directory' do + expect(chef_run).to create_directory('/mysql/tmp').with( + owner: 'mysql', + group: 'mysql', + recursive: true + ) + end + + it 'creates the configuration include directory' do + expect(chef_run).to create_directory('/mysql/conf.d').with( + owner: 'mysql', + group: 'mysql', + recursive: true + ) + end + + it 'creates the slow query log directory' do + expect(chef_run).to create_directory('/var/log/mysql').with( + owner: 'mysql', + group: 'mysql', + recursive: true + ) + end + + it 'manages the `mysql` service' do + expect(chef_run).to enable_service('mysql') + end + + it 'defines the setup for the data directory' do + expect(chef_run).to nothing_execute('setup mysql datadir') + end + + it 'creates the main server config file' do + expect(chef_run).to create_template('/mysql/my.cnf').with( + owner: 'root', + group: 'root', + mode: '0644', + sensitive: true, + cookbook: 'percona', + source: 'my.cnf.main.erb' + ) + + expect(chef_run).to render_file('/mysql/my.cnf').with_content( + 'performance_schema=ON' + ) + + resource = chef_run.template('/mysql/my.cnf') + expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately + expect(resource).to notify('service[mysql]').to(:restart).immediately + end + + it 'does not update the root user password' do + expect(chef_run).to_not run_execute('Update MySQL root password') + end + + it 'creates the debian system user config file' do + debian_cnf = '/etc/mysql/debian.cnf' + + expect(chef_run).to create_template(debian_cnf).with( + owner: 'root', + group: 'root', + mode: '0640', + sensitive: true + ) + + expect(chef_run).to render_file(debian_cnf).with_content('d3b1an') + + resource = chef_run.template(debian_cnf) + expect(resource).to notify('service[mysql]').to(:restart).immediately + end + end + + describe 'custom slow query log directory' do + override_attributes['percona']['server']['slow_query_logdir'] = '/var/log/slowq' + + before do + stub_command("mysqladmin --user=root --password='' version").and_return(true) + end + + it 'creates the slow query log directory' do + expect(chef_run).to create_directory('/var/log/slowq').with( + owner: 'mysql', + group: 'mysql', + recursive: true + ) + end + end + + describe 'jemalloc enabled' do + before do + stub_command("mysqladmin --user=root --password='' version").and_return(true) + end + + override_attributes['percona']['server']['jemalloc'] = true + + context 'Debian 10' do + platform 'debian', '10' + + it do + expect(chef_run).to install_package 'libjemalloc2' + end + + it 'sets the correct malloc-lib path' do + expect(chef_run).to render_file('/etc/mysql/my.cnf').with_content( + %r{^malloc-lib.*= /usr/lib/x86_64-linux-gnu/libjemalloc.so.2} + ) + end + end + context 'Debian 9' do + platform 'debian', '9' + + it do + expect(chef_run).to install_package 'libjemalloc1' + end + + it 'sets the correct malloc-lib path' do + expect(chef_run).to render_file('/etc/mysql/my.cnf').with_content( + %r{^malloc-lib.*= /usr/lib/x86_64-linux-gnu/libjemalloc.so.1} + ) + end + end + context 'Ubuntu 20.04' do + platform 'ubuntu', '20.04' + + it do + expect(chef_run).to install_package 'libjemalloc2' + end + + it 'sets the correct malloc-lib path' do + expect(chef_run).to render_file('/etc/mysql/my.cnf').with_content( + %r{^malloc-lib.*= /usr/lib/x86_64-linux-gnu/libjemalloc.so.2} + ) + end + end + context 'Ubuntu 18.04' do + platform 'ubuntu', '18.04' + + it do + expect(chef_run).to install_package 'libjemalloc1' + end + + it 'sets the correct malloc-lib path' do + expect(chef_run).to render_file('/etc/mysql/my.cnf').with_content( + %r{^malloc-lib.*= /usr/lib/x86_64-linux-gnu/libjemalloc.so.1} + ) + end + end + context 'CentOS 8' do + platform 'centos', '8' + + it do + expect(chef_run).to install_package 'jemalloc' + end + + it 'sets the correct malloc-lib path' do + expect(chef_run).to render_file('/etc/my.cnf').with_content( + %r{^malloc-lib.*= /usr/lib64/libjemalloc.so.2} + ) + end + end + context 'CentOS 7' do + platform 'centos', '7' + + it do + expect(chef_run).to install_package 'jemalloc' + end + + it 'sets the correct malloc-lib path' do + expect(chef_run).to render_file('/etc/my.cnf').with_content( + %r{^malloc-lib.*= /usr/lib64/libjemalloc.so.1} + ) + end + end + end + + context '`rhel` platform family' do + platform 'centos' + + before do + stub_command("mysqladmin --user=root --password='' version").and_return(true) + stub_command('dnf module list mysql | grep -q "^mysql.*\\[x\\]"') + end + + it 'creates the main server config file' do + expect(chef_run).to create_template('/etc/my.cnf').with( + owner: 'root', + group: 'root', + mode: '0644', + sensitive: true, + cookbook: 'percona', + source: 'my.cnf.main.erb' + ) + + resource = chef_run.template('/etc/my.cnf') + expect(resource).to notify('execute[setup mysql datadir]').to(:run).immediately + expect(resource).to notify('service[mysql]').to(:restart).immediately + end + + it 'does not create the configuration include directory' do + expect(chef_run).to_not create_directory('/mysql/conf.d') + end + end + + describe '`chef-vault` support' do + override_attributes['percona']['use_chef_vault'] = true + + before do + stub_command("mysqladmin --user=root --password='' version").and_return(false) + end + + it 'includes the `chef-vault` recipe' do + expect(chef_run).to include_recipe 'chef-vault' + end + end +end diff --git a/spec/default_spec.rb b/spec/default_spec.rb index a0f2bd53..ed9447ec 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -3,10 +3,6 @@ describe 'percona::default' do platform 'ubuntu' - before do - stub_command('apt-key list | grep 8507EFA5') - end - it do expect(chef_run).to include_recipe('percona::client') end diff --git a/spec/package_repo_spec.rb b/spec/package_repo_spec.rb index a9ad4168..26b76427 100644 --- a/spec/package_repo_spec.rb +++ b/spec/package_repo_spec.rb @@ -2,18 +2,44 @@ describe 'percona::package_repo' do before do - stub_command('apt-key list | grep 8507EFA5') stub_command('dnf module list mysql | grep -q "^mysql.*\\[x\\]"') end + context 'ubuntu' do platform 'ubuntu' it do - expect(chef_run).to add_apt_repository('percona') + expect(chef_run).to add_apt_repository('percona').with( + uri: 'http://repo.percona.com/apt', + components: %w(main), + keyserver: 'hkp://keys.gnupg.net:80', + key: %w(8507EFA5) + ) end it do - expect(chef_run).to add_apt_preference('00percona') + expect(chef_run).to add_apt_preference('00percona').with( + glob: '*', + pin: 'release o=Percona Development Team', + pin_priority: '1001' + ) + end + + it do + expect(chef_run).to add_apt_repository('percona-ps-80').with( + uri: 'http://repo.percona.com/ps-80/apt', + components: %w(main), + keyserver: 'hkp://keys.gnupg.net:80', + key: %w(8507EFA5) + ) + end + + context 'version < 8.0' do + override_attributes['percona']['version'] = '5.7' + + it do + expect(chef_run).to_not add_apt_repository('percona-ps-80') + end end end @@ -22,19 +48,49 @@ it do expect(chef_run).to create_yum_repository('percona').with( + description: 'Percona Packages', + baseurl: 'http://repo.percona.com/yum/release/$releasever/RPMS/$basearch', gpgkey: [ 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', - ] + ], + gpgcheck: true, + sslverify: true ) end + it do expect(chef_run).to create_yum_repository('percona-noarch').with( + description: 'Percona Packages - noarch', + baseurl: 'http://repo.percona.com/yum/release/$releasever/RPMS/noarch', gpgkey: [ 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', - ] + ], + gpgcheck: true, + sslverify: true ) end + + it do + expect(chef_run).to create_yum_repository('percona-ps-80').with( + description: 'Percona Packages - ps-80', + baseurl: 'http://repo.percona.com/ps-80/yum/release/$releasever/RPMS/$basearch', + gpgkey: [ + 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', + 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', + ], + gpgcheck: true, + sslverify: true + ) + end + + context 'version < 8.0' do + override_attributes['percona']['version'] = '5.7' + + it do + expect(chef_run).to_not create_yum_repository('percona-ps-80') + end + end end end diff --git a/spec/replication_spec.rb b/spec/replication_spec.rb index 1d8c4316..d1bccfe7 100644 --- a/spec/replication_spec.rb +++ b/spec/replication_spec.rb @@ -1,53 +1,51 @@ -# require 'spec_helper' - -# describe 'percona::replication' do -# let(:replication_sql) do -# '/etc/mysql/replication.sql' -# end - -# describe 'without replication configured' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['server']['role'] = [] -# node.default['percona']['server']['replication']['host'] = '' -# end.converge(described_recipe) -# end - -# it 'does not create a replication template' do -# expect(chef_run).to_not create_template(replication_sql) -# end - -# it 'does not execute the replication sql' do -# expect(chef_run).to_not run_execute('mysql-set-replication') - -# resource = chef_run.execute('mysql-set-replication') -# expect(resource).to do_nothing -# end -# end - -# describe 'with replication configured' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['server']['role'] = ['master'] -# node.default['percona']['server']['replication']['password'] = 's3kr1t' -# end.converge(described_recipe) -# end - -# it 'creates a replication template' do -# expect(chef_run).to create_template(replication_sql).with( -# owner: 'root', -# group: 'root', -# mode: '0600', -# sensitive: true -# ) -# expect(chef_run).to render_file(replication_sql).with_content('s3kr1t') -# end - -# it 'executes the replication sql' do -# resource = chef_run.execute('mysql-set-replication') -# expect(resource).to( -# subscribe_to("template[#{replication_sql}]").on(:run).immediately -# ) -# end -# end -# end +require 'spec_helper' + +describe 'percona::replication' do + platform 'ubuntu' + let(:replication_sql) do + '/etc/mysql/replication.sql' + end + + describe 'without replication configured' do + override_attributes['percona']['server']['role'] = [] + override_attributes['percona']['server']['replication']['host'] = '' + + it 'does not create a replication template' do + expect(chef_run).to_not create_template(replication_sql) + end + + it 'does not execute the replication sql' do + expect(chef_run).to_not run_execute('mysql-set-replication') + + resource = chef_run.execute('mysql-set-replication') + expect(resource).to do_nothing + end + end + + describe 'with replication configured' do + override_attributes['percona']['server']['role'] = ['master'] + override_attributes['percona']['server']['replication']['password'] = 's3kr1t' + override_attributes['percona']['server']['root_password'] = 's3kr1t' + + it 'creates a replication template' do + expect(chef_run).to create_template(replication_sql).with( + owner: 'root', + group: 'root', + mode: '0600', + sensitive: true + ) + expect(chef_run).to render_file(replication_sql).with_content('s3kr1t') + end + + it 'executes the replication sql' do + resource = chef_run.execute('mysql-set-replication') + expect(chef_run).to nothing_execute('mysql-set-replication').with( + command: '/usr/bin/mysql -ps3kr1t < /etc/mysql/replication.sql', + sensitive: true + ) + expect(resource).to( + subscribe_to("template[#{replication_sql}]").on(:run).immediately + ) + end + end +end diff --git a/spec/server_spec.rb b/spec/server_spec.rb index 5e51351d..34507246 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -1,101 +1,99 @@ -# require 'spec_helper' - -# describe 'percona::server' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new.converge(described_recipe) -# end - -# before do -# stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(true) -# stub_command("mysqladmin --user=root --password='' version") -# .and_return(true) -# end - -# it { expect(chef_run).to include_recipe('percona::package_repo') } -# it { expect(chef_run).to include_recipe('percona::configure_server') } -# it { expect(chef_run).to include_recipe('percona::access_grants') } -# it { expect(chef_run).to include_recipe('percona::replication') } - -# describe 'Ubuntu' do -# it { expect(chef_run).to install_package('percona-server-server-5.6') } -# end - -# describe 'CentOS' do -# let(:shared_pkg) do -# 'Percona-Server-shared-56' -# end - -# let(:chef_run) do -# env_options = { platform: 'centos', version: '6' } -# ChefSpec::SoloRunner.new(env_options).converge(described_recipe) -# end - -# before do -# stub_command("rpm -qa | grep #{shared_pkg}").and_return(false) -# end - -# describe 'without percona server shared package' do -# it { expect(chef_run).to remove_package('mysql-libs') } -# end - -# describe 'with percona server shared package' do -# before do -# stub_command("rpm -qa | grep #{shared_pkg}").and_return(true) -# end - -# it { expect(chef_run).to_not remove_package('mysql-libs') } -# end - -# it { expect(chef_run).to include_recipe('percona::client') } -# it { expect(chef_run).to install_package('Percona-Server-server-56') } -# end - -# describe 'when `skip_configure` is true' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['skip_configure'] = true -# end.converge(described_recipe) -# end - -# it { expect(chef_run).to_not include_recipe('percona::configure_server') } -# end - -# describe 'when `skip_passwords` is true' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['skip_passwords'] = true -# end.converge(described_recipe) -# end - -# it { expect(chef_run).to_not include_recipe('percona::access_grants') } -# it { expect(chef_run).to_not include_recipe('percona::replication') } -# end - -# describe 'when `package_action` is `upgrade`' do -# describe 'Ubuntu' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['server']['package_action'] = 'upgrade' -# end.converge(described_recipe) -# end - -# it { expect(chef_run).to upgrade_package('percona-server-server-5.6') } -# end - -# describe 'CentOS' do -# let(:chef_run) do -# env_options = { platform: 'centos', version: '6' } -# ChefSpec::SoloRunner.new(env_options) do |node| -# node.default['percona']['server']['package_action'] = 'upgrade' -# end.converge(described_recipe) -# end - -# before do -# stub_command('rpm -qa | grep Percona-Server-shared-56') -# .and_return(false) -# end - -# it { expect(chef_run).to upgrade_package('Percona-Server-server-56') } -# end -# end -# end +require 'spec_helper' + +describe 'percona::server' do + platform 'ubuntu' + + before do + stub_command("mysqladmin --user=root --password='' version").and_return(true) + stub_command('dnf module list mysql | grep -q "^mysql.*\\[x\\]"') + end + + describe 'Ubuntu' do + platform 'ubuntu' + + it { expect(chef_run).to include_recipe('percona::package_repo') } + it { expect(chef_run).to include_recipe('percona::configure_server') } + it { expect(chef_run).to include_recipe('percona::access_grants') } + it { expect(chef_run).to include_recipe('percona::replication') } + it { expect(chef_run).to install_package('percona-server-server') } + + context 'version 5.7' do + override_attributes['percona']['version'] = '5.7' + it do + expect(chef_run).to install_package 'percona-server-server-5.7' + end + end + + context 'version 5.6' do + override_attributes['percona']['version'] = '5.6' + it do + expect(chef_run).to install_package 'percona-server-server-5.6' + end + end + end + + context 'CentOS' do + platform 'centos' + + it { expect(chef_run).to include_recipe('percona::client') } + it { expect(chef_run).to install_package('percona-server-server') } + + it do + expect(chef_run).to nothing_execute('systemctl daemon-reload') + end + + it do + expect(chef_run).to edit_delete_lines('remove PIDFile from systemd.service').with( + path: '/usr/lib/systemd/system/mysqld.service' + # pattern: /^PIDFile=.*/ TODO: this errors out with + ) + end + + it do + expect(chef_run.delete_lines('remove PIDFile from systemd.service')).to \ + notify('execute[systemctl daemon-reload]').to(:run).immediately + end + + context 'version 5.7' do + override_attributes['percona']['version'] = '5.7' + it do + expect(chef_run).to install_package 'Percona-Server-server-57' + end + end + + context 'version 5.6' do + override_attributes['percona']['version'] = '5.6' + it do + expect(chef_run).to install_package 'Percona-Server-server-56' + end + end + end + + describe 'when `skip_configure` is true' do + override_attributes['percona']['skip_configure'] = true + + it { expect(chef_run).to_not include_recipe('percona::configure_server') } + end + + describe 'when `skip_passwords` is true' do + override_attributes['percona']['skip_passwords'] = true + + it { expect(chef_run).to_not include_recipe('percona::access_grants') } + it { expect(chef_run).to_not include_recipe('percona::replication') } + end + + describe 'when `package_action` is `upgrade`' do + describe 'Ubuntu' do + override_attributes['percona']['server']['package_action'] = 'upgrade' + + it { expect(chef_run).to upgrade_package('percona-server-server') } + end + + context 'CentOS' do + platform 'centos' + override_attributes['percona']['server']['package_action'] = 'upgrade' + + it { expect(chef_run).to upgrade_package('percona-server-server') } + end + end +end diff --git a/spec/ssl_spec.rb b/spec/ssl_spec.rb index 31b3fbca..b223dd73 100644 --- a/spec/ssl_spec.rb +++ b/spec/ssl_spec.rb @@ -1,68 +1,63 @@ -# require 'spec_helper' - -# describe 'percona::ssl' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new do |node| -# node.default['percona']['encrypted_data_bag'] = 'test-bag' -# node.default['percona']['server']['role'] = %w(master slave) -# end.converge(described_recipe) -# end - -# before do -# expect(Chef::EncryptedDataBagItem).to( -# receive(:load).with('test-bag', 'ssl_replication').and_return( -# 'ca-cert' => 'test-ca-cert', -# 'client' => { -# 'client-cert' => 'test-client-cert', -# 'client-key' => 'test-client-key', -# }, -# 'server' => { -# 'server-cert' => 'test-server-cert', -# 'server-key' => 'test-server-key', -# } -# ) -# ) -# end - -# it 'creates the certificate directory' do -# expect(chef_run).to create_directory('/etc/mysql/ssl').with( -# user: 'mysql', -# mode: '0700' -# ) -# end - -# it 'creates the CA certificate' do -# expect(chef_run).to create_file('/etc/mysql/ssl/cacert.pem').with( -# content: 'test-ca-cert', -# sensitive: true -# ) -# end - -# it 'creates the server key' do -# expect(chef_run).to create_file('/etc/mysql/ssl/server-key.pem').with( -# content: 'test-server-key', -# sensitive: true -# ) -# end - -# it 'creates the server certificate' do -# expect(chef_run).to create_file('/etc/mysql/ssl/server-cert.pem').with( -# content: 'test-server-cert', -# sensitive: true -# ) -# end - -# it 'creates the client key' do -# expect(chef_run).to create_file('/etc/mysql/ssl/client-key.pem').with( -# content: 'test-client-key', -# sensitive: true -# ) -# end - -# it 'creates the client certificate' do -# expect(chef_run).to create_file('/etc/mysql/ssl/client-cert.pem').with( -# content: 'test-client-cert', -# sensitive: true -# ) -# end -# end +require 'spec_helper' + +describe 'percona::ssl' do + platform 'ubuntu' + override_attributes['percona']['encrypted_data_bag'] = 'test-bag' + override_attributes['percona']['server']['role'] = %w(master slave) + + before do + stub_data_bag_item('test-bag', 'ssl_replication').and_return( + 'ca-cert' => 'test-ca-cert', + 'client' => { + 'client-cert' => 'test-client-cert', + 'client-key' => 'test-client-key', + }, + 'server' => { + 'server-cert' => 'test-server-cert', + 'server-key' => 'test-server-key', + } + ) + end + + it 'creates the certificate directory' do + expect(chef_run).to create_directory('/etc/mysql/ssl').with( + user: 'mysql', + mode: '0700' + ) + end + + it 'creates the CA certificate' do + expect(chef_run).to create_file('/etc/mysql/ssl/cacert.pem').with( + content: 'test-ca-cert', + sensitive: true + ) + end + + it 'creates the server key' do + expect(chef_run).to create_file('/etc/mysql/ssl/server-key.pem').with( + content: 'test-server-key', + sensitive: true + ) + end + + it 'creates the server certificate' do + expect(chef_run).to create_file('/etc/mysql/ssl/server-cert.pem').with( + content: 'test-server-cert', + sensitive: true + ) + end + + it 'creates the client key' do + expect(chef_run).to create_file('/etc/mysql/ssl/client-key.pem').with( + content: 'test-client-key', + sensitive: true + ) + end + + it 'creates the client certificate' do + expect(chef_run).to create_file('/etc/mysql/ssl/client-cert.pem').with( + content: 'test-client-cert', + sensitive: true + ) + end +end diff --git a/spec/toolkit_spec.rb b/spec/toolkit_spec.rb index 6749915d..55469dfd 100644 --- a/spec/toolkit_spec.rb +++ b/spec/toolkit_spec.rb @@ -1,45 +1,30 @@ -# require 'spec_helper' +require 'spec_helper' -# describe 'percona::toolkit' do -# let(:toolkit_package) do -# 'percona-toolkit' -# end +describe 'percona::toolkit' do + describe 'Ubuntu' do + platform 'ubuntu' -# describe 'Ubuntu' do -# let(:chef_run) do -# ChefSpec::SoloRunner.new.converge(described_recipe) -# end + it do + expect(chef_run).to install_package('percona-toolkit') + end + end -# specify do -# expect(chef_run).to install_package(toolkit_package) -# end -# end + describe 'CentOS' do + platform 'centos', '7' -# describe 'CentOS' do -# describe 'when `version` is 5.5' do -# let(:chef_run) do -# env_options = { platform: 'centos', version: '6' } -# ChefSpec::SoloRunner.new(env_options) do |node| -# node.default['percona']['version'] = '5.5' -# end.converge(described_recipe) -# end + before do + stub_command('dnf module list mysql | grep -q "^mysql.*\\[x\\]"') + end -# specify do -# expect(chef_run).to install_package(toolkit_package) -# end -# end - -# describe 'when `version` is 5.6' do -# let(:chef_run) do -# env_options = { platform: 'centos', version: '6' } -# ChefSpec::SoloRunner.new(env_options) do |node| -# node.default['percona']['version'] = '5.6' -# end.converge(described_recipe) -# end - -# specify do -# expect(chef_run).to install_package(toolkit_package) -# end -# end -# end -# end + it do + expect(chef_run).to install_package('percona-toolkit') + end + context 'CentOS 8 & Percona 8.0' do + platform 'centos', '8' + override_attributes['percona']['version'] = '8.0' + it do + expect(chef_run).to_not install_package('percona-toolkit') + end + end + end +end From 07c5752976d9e53668b9ae27cba8b01cc9cfc8bc Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Fri, 7 Aug 2020 17:23:09 -0700 Subject: [PATCH 144/300] Add ssl suite and tests for ssl recipe Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + kitchen.yml | 10 ++++++++++ recipes/ssl.rb | 5 +---- .../data_bags/passwords/ssl_replication.json | 12 ++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 test/integration/data_bags/passwords/ssl_replication.json diff --git a/CHANGELOG.md b/CHANGELOG.md index d8bc6db4..50048801 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This file is used to list changes made in each version of the percona cookbook. - Add cluster suite and tests to test cluster recipe - Add support for Percona 8.0 and default to that version - Re-add ChefSpec tests +- Add ssl suite and tests for ssl recipe ### Fixed diff --git a/kitchen.yml b/kitchen.yml index 3759177f..533ad818 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -11,6 +11,7 @@ provisioner: # enforce_idempotency: true # multiple_converge: 2 deprecations_as_errors: true + data_bags_path: test/integration/data_bags verifier: name: inspec @@ -91,3 +92,12 @@ suites: attributes: percona: version: '8.0' + - name: ssl + run_list: + - recipe[test::server] + - recipe[percona::ssl] + attributes: + percona: + server: + role: + - master diff --git a/recipes/ssl.rb b/recipes/ssl.rb index 58d8ad07..7ce8ce0f 100644 --- a/recipes/ssl.rb +++ b/recipes/ssl.rb @@ -6,18 +6,15 @@ certs_path = '/etc/mysql/ssl' server = node['percona']['server'] data_bag = node['percona']['encrypted_data_bag'] -secret_file = node['percona']['encrypted_data_bag_secret_file'] directory certs_path do owner node['percona']['server']['username'] mode '0700' end -secret = Chef::EncryptedDataBagItem.load_secret(secret_file) certs = data_bag_item( data_bag, - node['percona']['encrypted_data_bag_item_ssl_replication'], - secret + node['percona']['encrypted_data_bag_item_ssl_replication'] ) # place the CA certificate, it should be present on both master and slave diff --git a/test/integration/data_bags/passwords/ssl_replication.json b/test/integration/data_bags/passwords/ssl_replication.json new file mode 100644 index 00000000..ae6801a6 --- /dev/null +++ b/test/integration/data_bags/passwords/ssl_replication.json @@ -0,0 +1,12 @@ +{ + "id": "ssl_replication", + "ca-cert": "CA_CERTIFICATE_STRING", + "server": { + "server-cert": "SERVER_CERTIFICATE_STRING", + "server-key": "SERVER_KEY_STRING" + }, + "client": { + "client-cert": "CLIENT_CERTIFICATE_STRING", + "client-key": "CLIENT_KEY_STRING" + } +} From 899953fa99b344c91202dd717a897dea666eadac Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Fri, 7 Aug 2020 22:32:46 -0700 Subject: [PATCH 145/300] Add master suite and tests for testing the replication recipe Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 21 +++++++++++++----- CHANGELOG.md | 1 + kitchen.yml | 22 +++++++++++++++++++ templates/replication.sql.erb | 11 ++++++---- .../fixtures/cookbooks/test/recipes/master.rb | 6 +++++ test/integration/helpers/server_spec.rb | 18 +++++++++++++-- test/integration/master-56/master_spec.rb | 3 +++ test/integration/master-57/master_spec.rb | 3 +++ test/integration/master-80/master_spec.rb | 3 +++ 9 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 test/fixtures/cookbooks/test/recipes/master.rb create mode 100644 test/integration/master-56/master_spec.rb create mode 100644 test/integration/master-57/master_spec.rb create mode 100644 test/integration/master-80/master_spec.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ee37272..2973c223 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,28 +54,37 @@ jobs: - 'cluster-56' - 'cluster-57' - 'cluster-80' + - 'master-56' + - 'master-57' + - 'master-80' - 'server-56' - 'server-57' - 'server-80' exclude: - os: centos-8 suite: client-56 - - os: centos-8 - suite: server-56 - os: centos-8 suite: cluster-56 + - os: centos-8 + suite: master-56 + - os: centos-8 + suite: server-56 - os: debian-10 suite: client-56 - - os: debian-10 - suite: server-56 - os: debian-10 suite: cluster-56 + - os: debian-10 + suite: master-56 + - os: debian-10 + suite: server-56 - os: ubuntu-2004 suite: client-56 - - os: ubuntu-2004 - suite: server-56 - os: ubuntu-2004 suite: cluster-56 + - os: ubuntu-2004 + suite: master-56 + - os: ubuntu-2004 + suite: server-56 fail-fast: false steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 50048801..828fcc48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This file is used to list changes made in each version of the percona cookbook. - Add support for Percona 8.0 and default to that version - Re-add ChefSpec tests - Add ssl suite and tests for ssl recipe +- Add master suite and tests for testing the replication recipe ### Fixed diff --git a/kitchen.yml b/kitchen.yml index 533ad818..a071b58d 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -70,6 +70,28 @@ suites: attributes: percona: version: '8.0' + - name: master-56 + run_list: + - recipe[test::master] + attributes: + percona: + version: '5.6' + excludes: + - centos-8 + - debian-10 + - ubuntu-20.04 + - name: master-57 + run_list: + - recipe[test::master] + attributes: + percona: + version: '5.7' + - name: master-80 + run_list: + - recipe[test::master] + attributes: + percona: + version: '8.0' - name: cluster-56 run_list: - recipe[test::cluster] diff --git a/templates/replication.sql.erb b/templates/replication.sql.erb index 19283e10..927df8ec 100644 --- a/templates/replication.sql.erb +++ b/templates/replication.sql.erb @@ -1,11 +1,14 @@ -- Generated by Chef for <%= node["hostname"] %>. -- Local modifications will be overwritten. - -GRANT REPLICATION SLAVE ON *.* TO '<%=node["percona"]["server"]["replication"]["username"]%>'@'%' - IDENTIFIED BY '<%= @replication_password %>' <% if node["percona"]["server"]["replication"]["ssl_enabled"] %>REQUIRE SSL<% end %>; +<% if node["percona"]["version"].to_f >= 8.0 %> +CREATE USER IF NOT EXISTS '<%=node["percona"]["server"]["replication"]["username"]%>'@'%' IDENTIFIED BY '<%= @replication_password %>'; +GRANT REPLICATION SLAVE ON *.* TO '<%=node["percona"]["server"]["replication"]["username"]%>'@'%'<% if node["percona"]["server"]["replication"]["ssl_enabled"] %> REQUIRE SSL<% end %>; +<% else -%> +GRANT REPLICATION SLAVE ON *.* TO '<%=node["percona"]["server"]["replication"]["username"]%>'@'%' IDENTIFIED BY '<%= @replication_password %>'<% if node["percona"]["server"]["replication"]["ssl_enabled"] %> REQUIRE SSL<% end %>; +<% end -%> FLUSH PRIVILEGES; - <% unless node["percona"]["server"]["replication"]["host"].empty? %> + CHANGE MASTER TO MASTER_HOST='<%= node["percona"]["server"]["replication"]["host"] %>', MASTER_PORT=<%= node["percona"]["server"]["replication"]["port"] %>, diff --git a/test/fixtures/cookbooks/test/recipes/master.rb b/test/fixtures/cookbooks/test/recipes/master.rb new file mode 100644 index 00000000..e2b0d8ee --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/master.rb @@ -0,0 +1,6 @@ +node.default['percona']['server']['role'] = %w(master) +node.default['percona']['server']['replication']['host'] = 'master-host' +node.default['percona']['server']['replication']['username'] = 'replication' +node.default['percona']['server']['replication']['password'] = ')6$W2M{/' + +include_recipe 'test::server' diff --git a/test/integration/helpers/server_spec.rb b/test/integration/helpers/server_spec.rb index 560434a9..cc8cf43d 100644 --- a/test/integration/helpers/server_spec.rb +++ b/test/integration/helpers/server_spec.rb @@ -180,8 +180,22 @@ def server_test(version, type) its('content') { should match /7tCk\(V5I/ } end - describe file '/etc/mysql/replication.sql' do - it { should_not be_a_file } + if type == 'master' + describe file '/etc/mysql/replication.sql' do + it { should be_a_file } + its('owner') { should cmp 'root' } + its('group') { should cmp 'root' } + its('mode') { should cmp '0600' } + its('content') { should match /\)6\$W2M{\// } + its('content') { should match /TO 'replication'@'%'/ } + its('content') { should match /MASTER_HOST='master-host'/ } + its('content') { should match /MASTER_USER='replication'/ } + its('content') { should match /MASTER_PASSWORD='\)6\$W2M{\/'/ } + end + else + describe file '/etc/mysql/replication.sql' do + it { should_not be_a_file } + end end describe file '/tmp/mysql' do diff --git a/test/integration/master-56/master_spec.rb b/test/integration/master-56/master_spec.rb new file mode 100644 index 00000000..6152392c --- /dev/null +++ b/test/integration/master-56/master_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('5.6', 'master') diff --git a/test/integration/master-57/master_spec.rb b/test/integration/master-57/master_spec.rb new file mode 100644 index 00000000..45f9a077 --- /dev/null +++ b/test/integration/master-57/master_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('5.7', 'master') diff --git a/test/integration/master-80/master_spec.rb b/test/integration/master-80/master_spec.rb new file mode 100644 index 00000000..05bcc861 --- /dev/null +++ b/test/integration/master-80/master_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('8.0', 'master') From 2d784f657e981940480bb0b6c92d623b7fddbdcb Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 9 Aug 2020 10:37:49 -0700 Subject: [PATCH 146/300] Improve and fix ssl suite This provides proper testing on all the various Percona versions with SSL enabled. Other fixes includes: - Use the correct syntax on 8.0 - Use correct cert path for master/slave - Add real self-signed certs to data bags so we can test this properly Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 9 +++++++ CHANGELOG.md | 2 ++ kitchen.yml | 25 ++++++++++++++----- templates/replication.sql.erb | 10 +++++++- test/fixtures/cookbooks/test/recipes/ssl.rb | 7 ++++++ .../data_bags/passwords/ssl_replication.json | 10 ++++---- test/integration/helpers/server_spec.rb | 25 +++++++++++++++++-- test/integration/ssl-56/ssl_spec.rb | 3 +++ test/integration/ssl-57/ssl_spec.rb | 3 +++ test/integration/ssl-80/ssl_spec.rb | 3 +++ 10 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 test/fixtures/cookbooks/test/recipes/ssl.rb create mode 100644 test/integration/ssl-56/ssl_spec.rb create mode 100644 test/integration/ssl-57/ssl_spec.rb create mode 100644 test/integration/ssl-80/ssl_spec.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2973c223..d799ca1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,6 +60,9 @@ jobs: - 'server-56' - 'server-57' - 'server-80' + - 'ssl-56' + - 'ssl-57' + - 'ssl-80' exclude: - os: centos-8 suite: client-56 @@ -69,6 +72,8 @@ jobs: suite: master-56 - os: centos-8 suite: server-56 + - os: centos-8 + suite: ssl-56 - os: debian-10 suite: client-56 - os: debian-10 @@ -77,6 +82,8 @@ jobs: suite: master-56 - os: debian-10 suite: server-56 + - os: debian-10 + suite: ssl-56 - os: ubuntu-2004 suite: client-56 - os: ubuntu-2004 @@ -85,6 +92,8 @@ jobs: suite: master-56 - os: ubuntu-2004 suite: server-56 + - os: ubuntu-2004 + suite: ssl-56 fail-fast: false steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 828fcc48..4bb4d828 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ This file is used to list changes made in each version of the percona cookbook. - Don't remove mysql-libs on RHEL - jemalloc package installation and path setup for all platforms - Fixed enabled ChefSpec tests +- Use the correct syntax on 8.0 for SSL replication +- Use correct cert path for master/slave ### Changed diff --git a/kitchen.yml b/kitchen.yml index a071b58d..8baf8e98 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -114,12 +114,25 @@ suites: attributes: percona: version: '8.0' - - name: ssl + - name: ssl-56 run_list: - - recipe[test::server] - - recipe[percona::ssl] + - recipe[test::ssl] + attributes: + percona: + version: '5.6' + excludes: + - centos-8 + - debian-10 + - ubuntu-20.04 + - name: ssl-57 + run_list: + - recipe[test::ssl] attributes: percona: - server: - role: - - master + version: '5.7' + - name: ssl-80 + run_list: + - recipe[test::ssl] + attributes: + percona: + version: '8.0' diff --git a/templates/replication.sql.erb b/templates/replication.sql.erb index 927df8ec..a06e380b 100644 --- a/templates/replication.sql.erb +++ b/templates/replication.sql.erb @@ -2,7 +2,10 @@ -- Local modifications will be overwritten. <% if node["percona"]["version"].to_f >= 8.0 %> CREATE USER IF NOT EXISTS '<%=node["percona"]["server"]["replication"]["username"]%>'@'%' IDENTIFIED BY '<%= @replication_password %>'; -GRANT REPLICATION SLAVE ON *.* TO '<%=node["percona"]["server"]["replication"]["username"]%>'@'%'<% if node["percona"]["server"]["replication"]["ssl_enabled"] %> REQUIRE SSL<% end %>; +GRANT REPLICATION SLAVE ON *.* TO '<%=node["percona"]["server"]["replication"]["username"]%>'@'%'; +<% if node["percona"]["server"]["replication"]["ssl_enabled"] -%> +ALTER USER '<%=node["percona"]["server"]["replication"]["username"]%>'@'%' REQUIRE SSL; +<% end -%> <% else -%> GRANT REPLICATION SLAVE ON *.* TO '<%=node["percona"]["server"]["replication"]["username"]%>'@'%' IDENTIFIED BY '<%= @replication_password %>'<% if node["percona"]["server"]["replication"]["ssl_enabled"] %> REQUIRE SSL<% end %>; <% end -%> @@ -16,8 +19,13 @@ CHANGE MASTER TO <% if node["percona"]["server"]["replication"]["ssl_enabled"] %> MASTER_SSL=1, MASTER_SSL_CA='/etc/mysql/ssl/cacert.pem', + <% if node['percona']['server']['role'].include?('slave') %> MASTER_SSL_CERT='/etc/mysql/ssl/client-cert.pem', MASTER_SSL_KEY='/etc/mysql/ssl/client-key.pem', + <% elsif node['percona']['server']['role'].include?('master') %> + MASTER_SSL_CERT='/etc/mysql/ssl/server-cert.pem', + MASTER_SSL_KEY='/etc/mysql/ssl/server-key.pem', + <% end %> <% end %> MASTER_PASSWORD='<%= @replication_password %>'; START SLAVE; diff --git a/test/fixtures/cookbooks/test/recipes/ssl.rb b/test/fixtures/cookbooks/test/recipes/ssl.rb new file mode 100644 index 00000000..c81cd9f7 --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/ssl.rb @@ -0,0 +1,7 @@ +node.default['percona']['server']['role'] = %w(master) +node.default['percona']['server']['replication']['host'] = 'master-host' +node.default['percona']['server']['replication']['username'] = 'replication' +node.default['percona']['server']['replication']['password'] = ')6$W2M{/' +node.default['percona']['server']['replication']['ssl_enabled'] = true + +include_recipe 'test::server' diff --git a/test/integration/data_bags/passwords/ssl_replication.json b/test/integration/data_bags/passwords/ssl_replication.json index ae6801a6..2974bacc 100644 --- a/test/integration/data_bags/passwords/ssl_replication.json +++ b/test/integration/data_bags/passwords/ssl_replication.json @@ -1,12 +1,12 @@ { "id": "ssl_replication", - "ca-cert": "CA_CERTIFICATE_STRING", + "ca-cert": "-----BEGIN CERTIFICATE-----\nMIIDXTCCAkWgAwIBAgIJAM9aDRBDRsKlMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMjAwODA4MDYwMTM0WhcNMzAwODA2MDYwMTM0WjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEA2ZQtSKPHkGVD5zy57IYf6E5DA0BKZpQ1DhvzIyaCF54AVWa+N+NaUgy/\n/NRr0cwPBM9uJ/nBCN/dRo1Uj8jAuJ4PS9YwOIfmhR+y/Z3DfBDnZVChmiydwlqR\nTNr8DNnCaU+mveHEdWcdUdXiun5XnSXYmS0mH/YirjM/vDPxVQ3n5Je4dolxte0W\nf9j3UdJ4/56VfQX+OpimlsUyJMuKVhBPtZfpIOAKWNinkhkzwdb+a6aT0qX360QU\n5cRrohQBbSn0imO28hM7d8fNHBLF+1IpTH5yVRdl5MnlDxeAh3Zcs0QQUtb8OUm5\nz/13YgceOCN5WiNghT0J+ah8orpvQwIDAQABo1AwTjAdBgNVHQ4EFgQUw64btZuh\nQLLRX11laapMdeWIPM0wHwYDVR0jBBgwFoAUw64btZuhQLLRX11laapMdeWIPM0w\nDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAZcHA5bt0WyabgVqyvE2Q\nuTjBjYMNuEPtSHqWNm3uW+trck+nMY4jq9hnJULOHR24r5s5Xxd0MI5PZiChmVME\nVbnhu9eA1L3fVLOyDWCd4VewY1CYnPPB8duCSd81Ldzq/WREeVidfa5XYChHAj+J\n+oHxqIea0+qeQvPrS89QVrlSgSTbBBcmuOJUidMiJgrsaGVJJIXpEsqxYm2bdI6l\nIV/QShSVK/KFEdc3oS4Noywvm1iPovU9BzFOW7JduKCH07s64Nbd3i7YpNKpxxNP\nyWvqG+p/t9rP04C/1mxxi/fy4R5U4jeSaX9SmwXwNkIZLoeX4q03sEzl9vRDJrpz\nHw==\n-----END CERTIFICATE-----\n", "server": { - "server-cert": "SERVER_CERTIFICATE_STRING", - "server-key": "SERVER_KEY_STRING" + "server-cert": "-----BEGIN CERTIFICATE-----\nMIIC/jCCAeYCAQEwDQYJKoZIhvcNAQELBQAwRTELMAkGA1UEBhMCQVUxEzARBgNV\nBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0\nZDAeFw0yMDA4MDgwNjA0MjBaFw0zMDA4MDYwNjA0MjBaMEUxCzAJBgNVBAYTAkFV\nMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRz\nIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPq0DpvTBS\nrbHHLFESQDHF2gQbnS6/10fmjq3bMlWrOqrhyG5leH1m/G3hpcpuFTkxItWkc7vn\nPOFZAeOnxpu0OgIgOPbSz51E5CxNNY3JPrTLIHxLtS/U2IkBa23ZBU34wJbl6Vo2\nSc1PlI6ixikvR9XDEPNKBRIeUsq9rQyEX2ipL3HKoZ/lXklVjACB7y8z+DtkEiHj\n2KrZ45ytCyg7xwh/gBPp4NNr3vOE4ZQABiPIWR7FDGyMWz6fbHqbw/nwEY5A14bM\nYhvQDzto8KR0TpRqFOhFiLiXymrOI7ehHg2Y04FLObRcImDQfgc+ApXvNaN2JvaC\nqOjJ8JDyKDW1AgMBAAEwDQYJKoZIhvcNAQELBQADggEBAG4uGCh1xbQSYwOoYEMG\nLEDVm0IlgGMIndAbAIeq3mrCtI2EJ4cscs9lkMNmGgSGaTxDWR35y6Xam3PRnYa3\nYm4K2ZMGRnKYDSRlLZKSiQAh7AS1BeLZ9PQ2G8r/K/Ta6uJuDSXVFokjex7hFe5P\nxqu1ytcxY055nzOXm3LLncznsmMtZt2iW2W4blPPQvu2u6NYgtzqEiRgtaZkLWA+\nmWxUtnpD4PBi8YnJV/wf4bMvQT8gccvtG36sXACtiQBlMHAt6EDRjE84+WS3GEF2\nTVpRluiIO0dBYqLz4faP395e7mefLK1mu0OX0Hb1J8XmWmoK224YWEv3wKeLZWzf\n7YY=\n-----END CERTIFICATE-----\n", + "server-key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDPq0DpvTBSrbHH\nLFESQDHF2gQbnS6/10fmjq3bMlWrOqrhyG5leH1m/G3hpcpuFTkxItWkc7vnPOFZ\nAeOnxpu0OgIgOPbSz51E5CxNNY3JPrTLIHxLtS/U2IkBa23ZBU34wJbl6Vo2Sc1P\nlI6ixikvR9XDEPNKBRIeUsq9rQyEX2ipL3HKoZ/lXklVjACB7y8z+DtkEiHj2KrZ\n45ytCyg7xwh/gBPp4NNr3vOE4ZQABiPIWR7FDGyMWz6fbHqbw/nwEY5A14bMYhvQ\nDzto8KR0TpRqFOhFiLiXymrOI7ehHg2Y04FLObRcImDQfgc+ApXvNaN2JvaCqOjJ\n8JDyKDW1AgMBAAECggEBALAnHPXoA+Bt87n2LoKjr1SbnRZrWydhjlzUtEaVyLNp\nHWBN6s7pyL2d6/sW7cI5AH1chgpsHXyFWMVuY9SCFLto5Tq99yhU8ZtpTOblQXLu\nXN9cm/KAK6WJU5W/sbr/0+boPlehfGNGcQBLDD6ohnDTp1BCxYwJBxhvtAf2jQKO\ngIQw8GlMGG57Gs5WwskQ+Y7nMO1SAHbRT7MyyCTd/4br9khkhwW1G79iuoSlkZ3K\nF3IdvrHe+tqyyuZQqaXNPz3XpwBStvUOzGiRmoNlPq4jYhs8MlrLUWPO92Ua0pcf\nBcOiQPeC8oXNwTS/WEN6RDcX9JMgAFTfDfqyu6gqDgECgYEA6HayzEgm5CYyK0CV\nIMt9UF4qCyDl8aLMTVEoG5rQ4jszWGSVixHWtyJcukYOMv1C+hKHkTlG9t/kGn5I\nxMwIrm568eCFGzG2sJEggUcZ83KeGu3oVS8W/1uPo4YUXZvfYNR81qyH4c0ADv+U\nqA66fqVGsQPOqs5wyPZp4Fsn0oECgYEA5LHknxbR6JCvtd809ELhwukf88I8Xfgp\nEPtYebDfEYFCLWhBIquZnIDsfr0Zx6kblWmXEJzHgW1jCrkLSP3f9KUmK3XTBR6c\nQJeQ6+09oMbPCYdOyZawAGfqiyOYmQNtd6m3csQktG8XPDPC5qz3Eig4DKFzuKtn\nQy4zfQ9HITUCgYBWgIzqDVNDhJ8YjzCvAmnANToJ6BUIxJ6nirKVCxf9hzAFDXDE\nTkAK56N/wT/ZY3q/2ZNOy/SHOysDXMixSodUeVIQnY6KXwZvT6G72XxjpdwFg0/4\nGszA+w5JOERtzOnje051B8CMmp8R9bMYklp9c/0JM7R8xNMdROyDCwiXgQKBgFZ2\n06M6c35kRaqTi2fWaZjRnx0AEObOTmh3PwozTwNFRYn5YrcC/f7n14JLaJXOX/lr\nhIvpWpyaiNmjAJtGMQhD8Fx6HaBP5G+fXlF0ztockGZf2+/nov9kSo70lFs1qouV\nhSBE/EOjxLskLsocFwWsYxSTbjchxtblft4HirMJAoGBALI2RqQX3USRcAuIbImd\nGFyltGN7r83Kb/5VuT8DVuyRZ4S1225m21jgrB8K0F+Px1GctbHdMLUU+MqNrwjT\nmpxvcwFLMGkeCKdchOjkIQEPZHS3oNvKBARarIX8ghBkDXj6ysGGDZOYK/08xuHc\nhcmvInxofp3bonuTL3f0cVWv\n-----END PRIVATE KEY-----\n" }, "client": { - "client-cert": "CLIENT_CERTIFICATE_STRING", - "client-key": "CLIENT_KEY_STRING" + "client-cert": "-----BEGIN CERTIFICATE-----\nMIIC/jCCAeYCAQEwDQYJKoZIhvcNAQELBQAwRTELMAkGA1UEBhMCQVUxEzARBgNV\nBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0\nZDAeFw0yMDA4MDgwNjA0MzJaFw0zMDA4MDYwNjA0MzJaMEUxCzAJBgNVBAYTAkFV\nMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRz\nIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCb87YqyPRG\nEL+gyT0EpfPqVk85MIPPIu9NgEwxvZNBHCeUlRMMPLaj78tCsO6gm2LuvJUDSiwq\nEdcqIg4ggwhGn4C/29EOJkF8bRbzoGUnOezJT/50BscZu0aaQ1qjjU1d3AXnILBu\nplroe7Gs9Vjs26hUclYMMI/zz1MjZCm0EAGDDxWbMHm+RLjZEK6S8PoOrD4lHsLh\nlUqmUlRGvSJNul6F/v6DckY84gPCL8kI1TwoO4ZBElX7CcesYYMXfCcVQEe7sqVs\nNEg43kOZvTlEnCqjPbFbux6vZF5QKAkKHAy9nOSoFu67NH3U0mdBdI029cGME/G/\nPm6FCsrkq9pNAgMBAAEwDQYJKoZIhvcNAQELBQADggEBANjt0N6kHuqqiKZ1eSm4\nLZH9hDFb+MBBbftefkJwHj1NF4y0jUL5qhsWfCwOxt1JX/4psESwYMuPjMjjJfQE\necfke9DozfEfQllaAsn+GNlpGVQ9BUGOP7YXXZa8mG8nybiVHcN5fIRntBBWpWvm\nI7/dtkzMpt5I94VhC51wNuIhmyBPlOLLvZ0V7kevtjXDjrIza7PeGVlUXYmHHFs/\njLghv7sKMwWt7tI2Wpo0yas6zaZZS/fSySoBa9yUPcWgKRY+Xtbv6wnOYD6QYOsN\ns2mD7P2eCPGbRwlMm7JRBpEdq8XX5mHWrRmes+7yBF7WkV/qGf4yqGFPTWucc+d8\n0Es=\n-----END CERTIFICATE-----\n", + "client-key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCb87YqyPRGEL+g\nyT0EpfPqVk85MIPPIu9NgEwxvZNBHCeUlRMMPLaj78tCsO6gm2LuvJUDSiwqEdcq\nIg4ggwhGn4C/29EOJkF8bRbzoGUnOezJT/50BscZu0aaQ1qjjU1d3AXnILBuplro\ne7Gs9Vjs26hUclYMMI/zz1MjZCm0EAGDDxWbMHm+RLjZEK6S8PoOrD4lHsLhlUqm\nUlRGvSJNul6F/v6DckY84gPCL8kI1TwoO4ZBElX7CcesYYMXfCcVQEe7sqVsNEg4\n3kOZvTlEnCqjPbFbux6vZF5QKAkKHAy9nOSoFu67NH3U0mdBdI029cGME/G/Pm6F\nCsrkq9pNAgMBAAECggEANp53maqB6xwokT6J0Vvx/ou1+XilYWGB4GnjxbP4o+Ah\neKdxYWLOMMJmNPhUywlA8A46Pkm3CBDxg78jpX1e46UvaYKqSENbwiFO3Yq6gq+F\n38fVfXt2NeviQVr/nrJ5ezr5EkbfpBE9W5ke1E2llGcmIFVfD6vebuyY2JdXB8nb\nU33WLVda7ARrG+7e9tNismEbYnEFQfKv2vDMoEi7LslGdZ8rG1WUDW4sHKuVBFNv\nxMA/duhHdNGW/fv1lyBtZSeOTbJrgHkAuWPf3QQD2BypAQ+Mz9DlmbmUHua7W05n\nreCfsmqZ1xnLZH0vxc9f7UJ3XDEBXrVNb0chhn0vIQKBgQDK9A3H17Cw8caKhsTy\nlilwOyw4Xo34mMvsZ9v+SKxdtoR8PMxRIbT8GbKt2/iSNPgcVcj6rTMMdD57USnd\n98VfQv3pDKUdQRJ1wRwmOLzOzGQBXrbc8vX+gTTetqd17XDbET35IqqyHp4hXON4\nMPln0ZBaDaNIL0fB/lCqSaL/yQKBgQDEtrhMZqddPnx5HG/nx0Mqg2k0qF6Jft6E\nUGlhdP/gchZibS6y111mp/kDZo8sCESJNPD/g4CMMw4haPVsAdtKV05/3KDGSwwJ\npktDXjb07KGRrRfYa5svV4R0S8nIFAcTENMTDxVwgs4fMINE0lKNIAp8xzBB4pn6\nVfss2E1wZQKBgQCr8gEK4u5Lu0seaffKHvaUo01fpJxblfiPHZ8A3MlLzCqKp2fj\nBM+1FoCPU+JQ3JeoSfWwi7TIRGP7TlROPnD1uGguXgw1sL/XC/ixWTh9bCT+FCSR\nJTbMnOMSHWXbP4Nx1jXPMVO0/MO0OGJvne5vytilsxA3Q/djn/bvjtuOIQKBgFmm\nnJ/VOPl5/OiFWUrcuXOqqEvjYBJxy5+pth1AYU09MY5yDBJdrKeYbhhqqV179yBB\nDISmvfMnYY1AdHlg7zwWRiRnvK4ijb3oF+0ABzPglFH7/R4ZDISq8ia+U5vn5MF/\nrXLGMRMxyhbU2T6ITC8dJypu7UNZrqs0fGCXw9MxAoGBAKNmWmECNrws3BirKpxK\n9JeYHM7nwUu8hWf8nO6FtCa2vB3DEMpseSK7PHi0JCHylEy0PaivBmjHrl5/LD80\n8h6x48HbclHOJKgMbe0X7y9rqF5BQNTTkFmxYc65Sj221ABK16e9f4wsUB4TmKSb\nqir5oop2mZmGHIrhAws9Ey7/\n-----END PRIVATE KEY-----\n" } } diff --git a/test/integration/helpers/server_spec.rb b/test/integration/helpers/server_spec.rb index cc8cf43d..ed349d69 100644 --- a/test/integration/helpers/server_spec.rb +++ b/test/integration/helpers/server_spec.rb @@ -186,11 +186,32 @@ def server_test(version, type) its('owner') { should cmp 'root' } its('group') { should cmp 'root' } its('mode') { should cmp '0600' } - its('content') { should match /\)6\$W2M{\// } + its('content') { should match %r{\)6\$W2M\{/} } its('content') { should match /TO 'replication'@'%'/ } its('content') { should match /MASTER_HOST='master-host'/ } its('content') { should match /MASTER_USER='replication'/ } - its('content') { should match /MASTER_PASSWORD='\)6\$W2M{\/'/ } + its('content') { should match %r{MASTER_PASSWORD='\)6\$W2M\{/'} } + end + elsif type == 'ssl' + describe file '/etc/mysql/replication.sql' do + it { should be_a_file } + its('owner') { should cmp 'root' } + its('group') { should cmp 'root' } + its('mode') { should cmp '0600' } + if version.to_f >= 8.0 + its('content') { should match %r{CREATE USER IF NOT EXISTS 'replication'@'%' IDENTIFIED BY '\)6\$W2M\{\/';} } + its('content') { should match /GRANT REPLICATION SLAVE ON \*\.\* TO 'replication'@'%';/ } + its('content') { should match /ALTER USER 'replication'@'%' REQUIRE SSL;/ } + else + its('content') { should match %r{GRANT REPLICATION SLAVE ON \*\.\* TO 'replication'@'%' IDENTIFIED BY '\)6\$W2M\{/' REQUIRE SSL;} } + end + its('content') { should match /MASTER_HOST='master-host'/ } + its('content') { should match /MASTER_USER='replication'/ } + its('content') { should match %r{MASTER_PASSWORD='\)6\$W2M\{/'} } + its('content') { should match /MASTER_SSL=1/ } + its('content') { should match %r{MASTER_SSL_CA='/etc/mysql/ssl/cacert.pem'} } + its('content') { should match %r{MASTER_SSL_CERT='/etc/mysql/ssl/server-cert.pem'} } + its('content') { should match %r{MASTER_SSL_KEY='/etc/mysql/ssl/server-key.pem'} } end else describe file '/etc/mysql/replication.sql' do diff --git a/test/integration/ssl-56/ssl_spec.rb b/test/integration/ssl-56/ssl_spec.rb new file mode 100644 index 00000000..a18c64f4 --- /dev/null +++ b/test/integration/ssl-56/ssl_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('5.6', 'ssl') diff --git a/test/integration/ssl-57/ssl_spec.rb b/test/integration/ssl-57/ssl_spec.rb new file mode 100644 index 00000000..2b207a67 --- /dev/null +++ b/test/integration/ssl-57/ssl_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('5.7', 'ssl') diff --git a/test/integration/ssl-80/ssl_spec.rb b/test/integration/ssl-80/ssl_spec.rb new file mode 100644 index 00000000..bc8fbb23 --- /dev/null +++ b/test/integration/ssl-80/ssl_spec.rb @@ -0,0 +1,3 @@ +require_relative '../helpers/server_spec.rb' + +server_test('8.0', 'ssl') From 32c204ecbc80078be34fb2144bcb2384f1dab021 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 9 Aug 2020 11:02:57 -0700 Subject: [PATCH 147/300] Additional tests for replication template Signed-off-by: Lance Albertson --- spec/replication_spec.rb | 70 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/spec/replication_spec.rb b/spec/replication_spec.rb index d1bccfe7..598fd0c2 100644 --- a/spec/replication_spec.rb +++ b/spec/replication_spec.rb @@ -24,8 +24,10 @@ describe 'with replication configured' do override_attributes['percona']['server']['role'] = ['master'] - override_attributes['percona']['server']['replication']['password'] = 's3kr1t' override_attributes['percona']['server']['root_password'] = 's3kr1t' + override_attributes['percona']['server']['replication']['password'] = 's3kr1t' + override_attributes['percona']['server']['replication']['username'] = 'replication' + override_attributes['percona']['server']['replication']['host'] = 'master-host' it 'creates a replication template' do expect(chef_run).to create_template(replication_sql).with( @@ -34,7 +36,71 @@ mode: '0600', sensitive: true ) - expect(chef_run).to render_file(replication_sql).with_content('s3kr1t') + [ + /CREATE USER IF NOT EXISTS 'replication'@'%' IDENTIFIED BY 's3kr1t';/, + /GRANT REPLICATION SLAVE ON \*\.\* TO 'replication'@'%';/, + /MASTER_HOST='master-host'/, + /MASTER_USER='replication'/, + /MASTER_PASSWORD='s3kr1t'/, + ].each do |line| + expect(chef_run).to render_file(replication_sql).with_content(line) + end + end + + context 'version 5.7' do + override_attributes['percona']['version'] = '5.7' + it do + [ + /GRANT REPLICATION SLAVE ON \*\.\* TO 'replication'@'%' IDENTIFIED BY 's3kr1t';/, + /MASTER_HOST='master-host'/, + /MASTER_USER='replication'/, + /MASTER_PASSWORD='s3kr1t'/, + ].each do |line| + expect(chef_run).to render_file(replication_sql).with_content(line) + end + end + end + + context 'ssl enabled' do + override_attributes['percona']['server']['replication']['ssl_enabled'] = true + it do + [ + /ALTER USER 'replication'@'%' REQUIRE SSL;/, + /MASTER_SSL=1/, + %r{MASTER_SSL_CA='/etc/mysql/ssl/cacert.pem'}, + %r{MASTER_SSL_CERT='/etc/mysql/ssl/server-cert.pem'}, + %r{MASTER_SSL_KEY='/etc/mysql/ssl/server-key.pem'}, + ].each do |line| + expect(chef_run).to render_file(replication_sql).with_content(line) + end + end + + context 'version 5.7' do + override_attributes['percona']['version'] = '5.7' + it do + [ + /GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%' IDENTIFIED BY 's3kr1t' REQUIRE SSL;/, + /MASTER_SSL=1/, + %r{MASTER_SSL_CA='/etc/mysql/ssl/cacert.pem'}, + %r{MASTER_SSL_CERT='/etc/mysql/ssl/server-cert.pem'}, + %r{MASTER_SSL_KEY='/etc/mysql/ssl/server-key.pem'}, + ].each do |line| + expect(chef_run).to render_file(replication_sql).with_content(line) + end + end + end + + context 'role slave' do + override_attributes['percona']['server']['role'] = %w(slave) + it do + [ + %r{MASTER_SSL_CERT='/etc/mysql/ssl/client-cert.pem'}, + %r{MASTER_SSL_KEY='/etc/mysql/ssl/client-key.pem'}, + ].each do |line| + expect(chef_run).to render_file(replication_sql).with_content(line) + end + end + end end it 'executes the replication sql' do From fc7fbbb50b8d4448e300e2cca57c13faeebf1c52 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 9 Aug 2020 11:49:59 -0700 Subject: [PATCH 148/300] Use new inclusive terminology and add deprecation warning for old terms This replaces all use of master/slave with source/replica that the cookbook uses internally. This follows the terminology decided upstream by MySQL [1]. For now this cookbook supports both terms but issues a warning. The next major release will raise an error if either terms are still used. [1] https://mysqlhighavailability.com/mysql-terminology-updates/ Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 18 +++++----- CHANGELOG.md | 1 + README.md | 13 +++++-- kitchen.yml | 12 +++---- libraries/passwords.rb | 2 +- recipes/configure_server.rb | 4 +++ recipes/replication.rb | 2 +- recipes/ssl.rb | 12 +++---- spec/configure_server_spec.rb | 17 +++++++++ spec/replication_spec.rb | 35 ++++++++++++++++++- templates/my.cnf.cluster.erb | 22 ++++++------ templates/my.cnf.main.erb | 26 +++++++------- templates/replication.sql.erb | 4 +-- .../test/recipes/{master.rb => source.rb} | 4 +-- test/fixtures/cookbooks/test/recipes/ssl.rb | 4 +-- test/integration/helpers/server_spec.rb | 6 ++-- .../source_spec.rb} | 2 +- .../source_spec.rb} | 2 +- .../source_spec.rb} | 2 +- 19 files changed, 125 insertions(+), 63 deletions(-) rename test/fixtures/cookbooks/test/recipes/{master.rb => source.rb} (58%) rename test/integration/{master-56/master_spec.rb => source-56/source_spec.rb} (61%) rename test/integration/{master-57/master_spec.rb => source-57/source_spec.rb} (61%) rename test/integration/{master-80/master_spec.rb => source-80/source_spec.rb} (61%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d799ca1d..111b2fdb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,12 +54,12 @@ jobs: - 'cluster-56' - 'cluster-57' - 'cluster-80' - - 'master-56' - - 'master-57' - - 'master-80' - 'server-56' - 'server-57' - 'server-80' + - 'source-56' + - 'source-57' + - 'source-80' - 'ssl-56' - 'ssl-57' - 'ssl-80' @@ -68,30 +68,30 @@ jobs: suite: client-56 - os: centos-8 suite: cluster-56 - - os: centos-8 - suite: master-56 - os: centos-8 suite: server-56 + - os: centos-8 + suite: source-56 - os: centos-8 suite: ssl-56 - os: debian-10 suite: client-56 - os: debian-10 suite: cluster-56 - - os: debian-10 - suite: master-56 - os: debian-10 suite: server-56 + - os: debian-10 + suite: source-56 - os: debian-10 suite: ssl-56 - os: ubuntu-2004 suite: client-56 - os: ubuntu-2004 suite: cluster-56 - - os: ubuntu-2004 - suite: master-56 - os: ubuntu-2004 suite: server-56 + - os: ubuntu-2004 + suite: source-56 - os: ubuntu-2004 suite: ssl-56 fail-fast: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bb4d828..65262c88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ This file is used to list changes made in each version of the percona cookbook. ### Deprecated - Deprecate monitoring recipe +- Use new inclusive terminology and add deprecation warning for old terms ## 0.17.2 - 2020-08-06 diff --git a/README.md b/README.md index 2fa7bf62..b32bf738 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,14 @@ the [currently tested versions](https://github.com/phlipper/chef-percona/blob/ma ## Usage -This cookbook installs the Percona MySQL components if not present, and pulls updates if they are installed on the system. +This cookbook installs the Percona MySQL components if not present, and pulls updates if they are installed on the +system. + +This cookbook uses inclusion terminology where applicable replacing terms such as ``master/slave`` to ``source/replica`` +which matches the [terminology decided upstream](https://mysqlhighavailability.com/mysql-terminology-updates/). Older +releases of Percona still use the terms in their configuration so those will remain, however we will be using the newer +terms with attributes, property and variable names. Currently both terms should work however the next major release of +this cookbook will only use the new terminology. ### Encrypted Passwords @@ -515,8 +522,8 @@ In no particular order: - Support for Chef Server - Support the following common database infrastructures: - Single server instance - - Traditional Master/Slave replication - - Multi-master cluster replication + - Traditional Source/Replica replication + - Multi-source cluster replication - Support the most recent Chef runtime environments - Be the easiest way to setup a MySQL distribution through Chef diff --git a/kitchen.yml b/kitchen.yml index 8baf8e98..7bf27972 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -70,9 +70,9 @@ suites: attributes: percona: version: '8.0' - - name: master-56 + - name: source-56 run_list: - - recipe[test::master] + - recipe[test::source] attributes: percona: version: '5.6' @@ -80,15 +80,15 @@ suites: - centos-8 - debian-10 - ubuntu-20.04 - - name: master-57 + - name: source-57 run_list: - - recipe[test::master] + - recipe[test::source] attributes: percona: version: '5.7' - - name: master-80 + - name: source-80 run_list: - - recipe[test::master] + - recipe[test::source] attributes: percona: version: '8.0' diff --git a/libraries/passwords.rb b/libraries/passwords.rb index 6de10dbb..e9f35c08 100644 --- a/libraries/passwords.rb +++ b/libraries/passwords.rb @@ -50,7 +50,7 @@ def old_passwords find_password @mysql_item, 'old_passwords', node_server['old_passwords'] end - # password for user responsbile for replicating in master/slave environment + # password for user responsbile for replicating in source/replica environment def replication_password find_password @mysql_item, node_server['replication']['username'], node_server['replication']['password'] end diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index b8a03a4c..e51f4bab 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -8,6 +8,10 @@ conf = percona['conf'] mysqld = (conf && conf['mysqld']) || {} +if node['percona']['server']['role'].include?('master') || node['percona']['server']['role'].include?('slave') + Chef::Log.warn('Please use source/replica instead of master/slave for the role name. The next major release of the percona cookbook will only support the new terms.') +end + # setup SELinux if needed unless node['percona']['selinux_module_url'].nil? || node['percona']['selinux_module_url'] == '' semodule_filename = node['percona']['selinux_module_url'].split('/')[-1] diff --git a/recipes/replication.rb b/recipes/replication.rb index 9237668a..dab2401b 100644 --- a/recipes/replication.rb +++ b/recipes/replication.rb @@ -18,7 +18,7 @@ mode '0600' sensitive true only_if do - (server['replication']['host'] != '' || server['role'].include?('master')) && !::File.exist?(replication_sql) + (server['replication']['host'] != '' || server['role'].include?('source') || server['role'].include?('master')) && !::File.exist?(replication_sql) end end diff --git a/recipes/ssl.rb b/recipes/ssl.rb index 7ce8ce0f..69edabe3 100644 --- a/recipes/ssl.rb +++ b/recipes/ssl.rb @@ -17,25 +17,25 @@ node['percona']['encrypted_data_bag_item_ssl_replication'] ) -# place the CA certificate, it should be present on both master and slave +# place the CA certificate, it should be present on both source and replica file "#{certs_path}/cacert.pem" do content certs['ca-cert'] sensitive true end %w(cert key).each do |file| - # place certificate and key for master + # place certificate and key for source file "#{certs_path}/server-#{file}.pem" do content certs['server']["server-#{file}"] sensitive true - only_if { server['role'].include?('master') } + only_if { server['role'].include?('source') || server['role'].include?('master') } end - # because in a master-master setup a master could also be a slave - # place slave certificate and key + # because in a source-source setup a source could also be a replica + # place replica certificate and key file "#{certs_path}/client-#{file}.pem" do content certs['client']["client-#{file}"] sensitive true - only_if { server['role'].include?('slave') } + only_if { server['role'].include?('replica') || server['role'].include?('slave') } end end diff --git a/spec/configure_server_spec.rb b/spec/configure_server_spec.rb index 333cc717..f9eff344 100644 --- a/spec/configure_server_spec.rb +++ b/spec/configure_server_spec.rb @@ -8,6 +8,23 @@ stub_command("mysqladmin --user=root --password='' version").and_return(true) end + describe 'inclusion tests' do + context 'role master' do + override_attributes['percona']['server']['role'] = %w(master) + it do + expect(Chef::Log).to receive(:warn).with('Please use source/replica instead of master/slave for the role name. The next major release of the percona cookbook will only support the new terms.') + chef_run + end + end + context 'role slave' do + override_attributes['percona']['server']['role'] = %w(slave) + it do + expect(Chef::Log).to receive(:warn).with('Please use source/replica instead of master/slave for the role name. The next major release of the percona cookbook will only support the new terms.') + chef_run + end + end + end + it 'does not include the `chef-vault` recipe' do expect(chef_run).to_not include_recipe 'chef-vault' end diff --git a/spec/replication_spec.rb b/spec/replication_spec.rb index 598fd0c2..90d153e7 100644 --- a/spec/replication_spec.rb +++ b/spec/replication_spec.rb @@ -23,7 +23,7 @@ end describe 'with replication configured' do - override_attributes['percona']['server']['role'] = ['master'] + override_attributes['percona']['server']['role'] = %w(source) override_attributes['percona']['server']['root_password'] = 's3kr1t' override_attributes['percona']['server']['replication']['password'] = 's3kr1t' override_attributes['percona']['server']['replication']['username'] = 'replication' @@ -47,6 +47,27 @@ end end + context 'role master' do + override_attributes['percona']['server']['role'] = %w(master) + it 'creates a replication template' do + expect(chef_run).to create_template(replication_sql).with( + owner: 'root', + group: 'root', + mode: '0600', + sensitive: true + ) + [ + /CREATE USER IF NOT EXISTS 'replication'@'%' IDENTIFIED BY 's3kr1t';/, + /GRANT REPLICATION SLAVE ON \*\.\* TO 'replication'@'%';/, + /MASTER_HOST='master-host'/, + /MASTER_USER='replication'/, + /MASTER_PASSWORD='s3kr1t'/, + ].each do |line| + expect(chef_run).to render_file(replication_sql).with_content(line) + end + end + end + context 'version 5.7' do override_attributes['percona']['version'] = '5.7' it do @@ -90,6 +111,18 @@ end end + context 'role replica' do + override_attributes['percona']['server']['role'] = %w(replica) + it do + [ + %r{MASTER_SSL_CERT='/etc/mysql/ssl/client-cert.pem'}, + %r{MASTER_SSL_KEY='/etc/mysql/ssl/client-key.pem'}, + ].each do |line| + expect(chef_run).to render_file(replication_sql).with_content(line) + end + end + end + context 'role slave' do override_attributes['percona']['server']['role'] = %w(slave) it do diff --git a/templates/my.cnf.cluster.erb b/templates/my.cnf.cluster.erb index aec40f26..713341c8 100644 --- a/templates/my.cnf.cluster.erb +++ b/templates/my.cnf.cluster.erb @@ -268,7 +268,7 @@ query_cache_type = <%= node["percona"]["server"]["query_cache_type"] %> # sync_binlog ensures that all writes to the binary log are immediately # flushed to disk. This is important, especially for replication, because # if the server crashes and has not written all of the binary log to disk (and flushed it) -# then some rows will not make it to the slave +# then some rows will not make it to the replica sync_binlog = <%= node["percona"]["server"]["sync_binlog"] %> # @@ -294,24 +294,24 @@ log-queries-not-using-indexes = <%= node["percona"]["server"]["log_queries_not_u <% end %> # The following can be used as easy to replay backup logs or for replication. -# note: if you are setting up a replication slave, see README.Debian about +# note: if you are setting up a replication replica, see README.Debian about # other settings you may need to change. # Unique server identification number between 1 and 2^32-1. This value -# is required for both master and slave hosts. It defaults to 1 if -# "master-host" is not set, but will MySQL will not function as a master +# is required for both source and replica hosts. It defaults to 1 if +# "master-host" is not set, but will MySQL will not function as a source # if it is omitted. # server-id = <%= node["percona"]["server"]["server_id"] %> <% unless node["percona"]["server"]["replication"]["ignore_db"].empty? %> -# Tells the slave SQL thread not to replicate any statement where the default database is. +# Tells the replica SQL thread not to replicate any statement where the default database is. <% Array(node["percona"]["server"]["replication"]["ignore_db"]).each do |ignore_db| -%> replicate-ignore-db = <%= ignore_db %> <% end -%> <% end -%> <% unless node["percona"]["server"]["replication"]["ignore_table"].empty? %> -# Creates a replication filter by telling 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. +# Creates a replication filter by telling the replica SQL thread not to replicate any statement that updates the specified table, even if any other tables might be updated by the same statement. <% node["percona"]["server"]["replication"]["ignore_table"].each do |ignore_table| -%> replicate-ignore-table = <%= ignore_table %> <% end -%> @@ -323,22 +323,22 @@ replicate-ignore-table = <%= ignore_table %> log_warnings_suppress=1592 <% end %> -# Make the slave read-only. Only users with the SUPER privilege and the -# replication slave thread will be able to modify data on it. You can +# Make the replica read-only. Only users with the SUPER privilege and the +# replication replica thread will be able to modify data on it. You can # use this to ensure that no applications will accidently modify data on -# the slave instead of the master +# the replica instead of the source <% if node["percona"]["server"]["replication"]["read_only"] %> read_only <% end %> -# Tells the slave server not to start the slave threads when the server starts. +# Tells the replica server not to start the replica threads when the server starts. # This will allow you to tweak system and/or server settings prior to starting # replication. <% if node["percona"]["server"]["replication"]["skip_slave_start"] %> skip-slave-start <% end %> -# Number of times the slave SQL thread will retry a transaction in case it +# Number of times the replica SQL thread will retry a transaction in case it # failed with a deadlock or elapsed lock wait timeout, before giving up and # stopping. slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_transaction_retries"] %> diff --git a/templates/my.cnf.main.erb b/templates/my.cnf.main.erb index 75b1c69b..edf13ca3 100644 --- a/templates/my.cnf.main.erb +++ b/templates/my.cnf.main.erb @@ -270,7 +270,7 @@ query_cache_type = <%= node["percona"]["server"]["query_cache_type"] %> # sync_binlog ensures that all writes to the binary log are immediately # flushed to disk. This is important, especially for replication, because # if the server crashes and has not written all of the binary log to disk (and flushed it) -# then some rows will not make it to the slave +# then some rows will not make it to the replica sync_binlog = <%= node["percona"]["server"]["sync_binlog"] %> # @@ -296,24 +296,24 @@ log-queries-not-using-indexes = <%= node["percona"]["server"]["log_queries_not_u <% end %> # The following can be used as easy to replay backup logs or for replication. -# note: if you are setting up a replication slave, see README.Debian about +# note: if you are setting up a replication replica, see README.Debian about # other settings you may need to change. # Unique server identification number between 1 and 2^32-1. This value -# is required for both master and slave hosts. It defaults to 1 if -# "master-host" is not set, but will MySQL will not function as a master +# is required for both source and replica hosts. It defaults to 1 if +# "master-host" is not set, but will MySQL will not function as a source # if it is omitted. server-id = <%= node["percona"]["server"]["server_id"] %> <% unless node["percona"]["server"]["replication"]["ignore_db"].empty? %> -# Tells the slave SQL thread not to replicate any statement where the default database is. +# Tells the replica SQL thread not to replicate any statement where the default database is. <% Array(node["percona"]["server"]["replication"]["ignore_db"]).each do |ignore_db| -%> replicate-ignore-db = <%= ignore_db %> <% end -%> <% end -%> <% unless node["percona"]["server"]["replication"]["ignore_table"].empty? %> -# Creates a replication filter by telling 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. +# Creates a replication filter by telling the replica SQL thread not to replicate any statement that updates the specified table, even if any other tables might be updated by the same statement. <% node["percona"]["server"]["replication"]["ignore_table"].each do |ignore_table| -%> replicate-ignore-table = <%= ignore_table %> <% end -%> @@ -325,22 +325,22 @@ replicate-ignore-table = <%= ignore_table %> log_warnings_suppress=1592 <% end %> -# Make the slave read-only. Only users with the SUPER privilege and the -# replication slave thread will be able to modify data on it. You can +# Make the replica read-only. Only users with the SUPER privilege and the +# replication replica thread will be able to modify data on it. You can # use this to ensure that no applications will accidently modify data on -# the slave instead of the master +# the replica instead of the source <% if node["percona"]["server"]["replication"]["read_only"] %> read_only <% end %> -# Tells the slave server not to start the slave threads when the server starts. +# Tells the replica server not to start the replica threads when the server starts. # This will allow you to tweak system and/or server settings prior to starting # replication. <% if node["percona"]["server"]["replication"]["skip_slave_start"] %> skip-slave-start <% end %> -# Number of times the slave SQL thread will retry a transaction in case it +# Number of times the replica SQL thread will retry a transaction in case it # failed with a deadlock or elapsed lock wait timeout, before giving up and # stopping. slave_transaction_retries = <%= node["percona"]["server"]["replication"]["slave_transaction_retries"] %> @@ -415,9 +415,9 @@ sync_relay_log_info = <%= node["percona"]["server"]["sync_relay_log_info"] %> # statement in transaction binlog_cache_size = <%= node["percona"]["server"]["binlog_cache_size"] %> -# If you're using replication with chained slaves (A->B->C), you need to +# If you're using replication with chained replicas (A->B->C), you need to # enable this option on server B. It enables logging of updates done by -# the slave thread into the slave's binary log. +# the replica thread into the replica's binary log. <% if node["percona"]["server"]["log_slave_updates"] %> log_slave_updates <% end %> diff --git a/templates/replication.sql.erb b/templates/replication.sql.erb index a06e380b..44893d4d 100644 --- a/templates/replication.sql.erb +++ b/templates/replication.sql.erb @@ -19,10 +19,10 @@ CHANGE MASTER TO <% if node["percona"]["server"]["replication"]["ssl_enabled"] %> MASTER_SSL=1, MASTER_SSL_CA='/etc/mysql/ssl/cacert.pem', - <% if node['percona']['server']['role'].include?('slave') %> + <% if node['percona']['server']['role'].include?('replica') || node['percona']['server']['role'].include?('slave') %> MASTER_SSL_CERT='/etc/mysql/ssl/client-cert.pem', MASTER_SSL_KEY='/etc/mysql/ssl/client-key.pem', - <% elsif node['percona']['server']['role'].include?('master') %> + <% elsif node['percona']['server']['role'].include?('source') || node['percona']['server']['role'].include?('master') %> MASTER_SSL_CERT='/etc/mysql/ssl/server-cert.pem', MASTER_SSL_KEY='/etc/mysql/ssl/server-key.pem', <% end %> diff --git a/test/fixtures/cookbooks/test/recipes/master.rb b/test/fixtures/cookbooks/test/recipes/source.rb similarity index 58% rename from test/fixtures/cookbooks/test/recipes/master.rb rename to test/fixtures/cookbooks/test/recipes/source.rb index e2b0d8ee..07756daf 100644 --- a/test/fixtures/cookbooks/test/recipes/master.rb +++ b/test/fixtures/cookbooks/test/recipes/source.rb @@ -1,5 +1,5 @@ -node.default['percona']['server']['role'] = %w(master) -node.default['percona']['server']['replication']['host'] = 'master-host' +node.default['percona']['server']['role'] = %w(source) +node.default['percona']['server']['replication']['host'] = 'source-host' node.default['percona']['server']['replication']['username'] = 'replication' node.default['percona']['server']['replication']['password'] = ')6$W2M{/' diff --git a/test/fixtures/cookbooks/test/recipes/ssl.rb b/test/fixtures/cookbooks/test/recipes/ssl.rb index c81cd9f7..dc0df703 100644 --- a/test/fixtures/cookbooks/test/recipes/ssl.rb +++ b/test/fixtures/cookbooks/test/recipes/ssl.rb @@ -1,5 +1,5 @@ -node.default['percona']['server']['role'] = %w(master) -node.default['percona']['server']['replication']['host'] = 'master-host' +node.default['percona']['server']['role'] = %w(source) +node.default['percona']['server']['replication']['host'] = 'source-host' node.default['percona']['server']['replication']['username'] = 'replication' node.default['percona']['server']['replication']['password'] = ')6$W2M{/' node.default['percona']['server']['replication']['ssl_enabled'] = true diff --git a/test/integration/helpers/server_spec.rb b/test/integration/helpers/server_spec.rb index ed349d69..4c9c93c2 100644 --- a/test/integration/helpers/server_spec.rb +++ b/test/integration/helpers/server_spec.rb @@ -180,7 +180,7 @@ def server_test(version, type) its('content') { should match /7tCk\(V5I/ } end - if type == 'master' + if type == 'source' describe file '/etc/mysql/replication.sql' do it { should be_a_file } its('owner') { should cmp 'root' } @@ -188,7 +188,7 @@ def server_test(version, type) its('mode') { should cmp '0600' } its('content') { should match %r{\)6\$W2M\{/} } its('content') { should match /TO 'replication'@'%'/ } - its('content') { should match /MASTER_HOST='master-host'/ } + its('content') { should match /MASTER_HOST='source-host'/ } its('content') { should match /MASTER_USER='replication'/ } its('content') { should match %r{MASTER_PASSWORD='\)6\$W2M\{/'} } end @@ -205,7 +205,7 @@ def server_test(version, type) else its('content') { should match %r{GRANT REPLICATION SLAVE ON \*\.\* TO 'replication'@'%' IDENTIFIED BY '\)6\$W2M\{/' REQUIRE SSL;} } end - its('content') { should match /MASTER_HOST='master-host'/ } + its('content') { should match /MASTER_HOST='source-host'/ } its('content') { should match /MASTER_USER='replication'/ } its('content') { should match %r{MASTER_PASSWORD='\)6\$W2M\{/'} } its('content') { should match /MASTER_SSL=1/ } diff --git a/test/integration/master-56/master_spec.rb b/test/integration/source-56/source_spec.rb similarity index 61% rename from test/integration/master-56/master_spec.rb rename to test/integration/source-56/source_spec.rb index 6152392c..7d459976 100644 --- a/test/integration/master-56/master_spec.rb +++ b/test/integration/source-56/source_spec.rb @@ -1,3 +1,3 @@ require_relative '../helpers/server_spec.rb' -server_test('5.6', 'master') +server_test('5.6', 'source') diff --git a/test/integration/master-57/master_spec.rb b/test/integration/source-57/source_spec.rb similarity index 61% rename from test/integration/master-57/master_spec.rb rename to test/integration/source-57/source_spec.rb index 45f9a077..7e8aa079 100644 --- a/test/integration/master-57/master_spec.rb +++ b/test/integration/source-57/source_spec.rb @@ -1,3 +1,3 @@ require_relative '../helpers/server_spec.rb' -server_test('5.7', 'master') +server_test('5.7', 'source') diff --git a/test/integration/master-80/master_spec.rb b/test/integration/source-80/source_spec.rb similarity index 61% rename from test/integration/master-80/master_spec.rb rename to test/integration/source-80/source_spec.rb index 05bcc861..c39dedd5 100644 --- a/test/integration/master-80/master_spec.rb +++ b/test/integration/source-80/source_spec.rb @@ -1,3 +1,3 @@ require_relative '../helpers/server_spec.rb' -server_test('8.0', 'master') +server_test('8.0', 'source') From da4caa545208076d4c63ca47828c8fd30f7cfea2 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 9 Aug 2020 11:54:54 -0700 Subject: [PATCH 149/300] Rename ssl suite to replication This better describes what this suite tests Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 12 ++++++------ kitchen.yml | 12 ++++++------ .../test/recipes/{ssl.rb => replication.rb} | 0 test/integration/helpers/server_spec.rb | 2 +- .../replication_spec.rb} | 2 +- .../replication_spec.rb} | 2 +- .../replication_spec.rb} | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) rename test/fixtures/cookbooks/test/recipes/{ssl.rb => replication.rb} (100%) rename test/integration/{ssl-56/ssl_spec.rb => replication-56/replication_spec.rb} (57%) rename test/integration/{ssl-57/ssl_spec.rb => replication-57/replication_spec.rb} (57%) rename test/integration/{ssl-80/ssl_spec.rb => replication-80/replication_spec.rb} (57%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 111b2fdb..cfc8a70b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,9 +60,9 @@ jobs: - 'source-56' - 'source-57' - 'source-80' - - 'ssl-56' - - 'ssl-57' - - 'ssl-80' + - 'replication-56' + - 'replication-57' + - 'replication-80' exclude: - os: centos-8 suite: client-56 @@ -73,7 +73,7 @@ jobs: - os: centos-8 suite: source-56 - os: centos-8 - suite: ssl-56 + suite: replication-56 - os: debian-10 suite: client-56 - os: debian-10 @@ -83,7 +83,7 @@ jobs: - os: debian-10 suite: source-56 - os: debian-10 - suite: ssl-56 + suite: replication-56 - os: ubuntu-2004 suite: client-56 - os: ubuntu-2004 @@ -93,7 +93,7 @@ jobs: - os: ubuntu-2004 suite: source-56 - os: ubuntu-2004 - suite: ssl-56 + suite: replication-56 fail-fast: false steps: diff --git a/kitchen.yml b/kitchen.yml index 7bf27972..9a6832f7 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -114,9 +114,9 @@ suites: attributes: percona: version: '8.0' - - name: ssl-56 + - name: replication-56 run_list: - - recipe[test::ssl] + - recipe[test::replication] attributes: percona: version: '5.6' @@ -124,15 +124,15 @@ suites: - centos-8 - debian-10 - ubuntu-20.04 - - name: ssl-57 + - name: replication-57 run_list: - - recipe[test::ssl] + - recipe[test::replication] attributes: percona: version: '5.7' - - name: ssl-80 + - name: replication-80 run_list: - - recipe[test::ssl] + - recipe[test::replication] attributes: percona: version: '8.0' diff --git a/test/fixtures/cookbooks/test/recipes/ssl.rb b/test/fixtures/cookbooks/test/recipes/replication.rb similarity index 100% rename from test/fixtures/cookbooks/test/recipes/ssl.rb rename to test/fixtures/cookbooks/test/recipes/replication.rb diff --git a/test/integration/helpers/server_spec.rb b/test/integration/helpers/server_spec.rb index 4c9c93c2..5f2ccd72 100644 --- a/test/integration/helpers/server_spec.rb +++ b/test/integration/helpers/server_spec.rb @@ -192,7 +192,7 @@ def server_test(version, type) its('content') { should match /MASTER_USER='replication'/ } its('content') { should match %r{MASTER_PASSWORD='\)6\$W2M\{/'} } end - elsif type == 'ssl' + elsif type == 'replication' describe file '/etc/mysql/replication.sql' do it { should be_a_file } its('owner') { should cmp 'root' } diff --git a/test/integration/ssl-56/ssl_spec.rb b/test/integration/replication-56/replication_spec.rb similarity index 57% rename from test/integration/ssl-56/ssl_spec.rb rename to test/integration/replication-56/replication_spec.rb index a18c64f4..4d3bb5a6 100644 --- a/test/integration/ssl-56/ssl_spec.rb +++ b/test/integration/replication-56/replication_spec.rb @@ -1,3 +1,3 @@ require_relative '../helpers/server_spec.rb' -server_test('5.6', 'ssl') +server_test('5.6', 'replication') diff --git a/test/integration/ssl-57/ssl_spec.rb b/test/integration/replication-57/replication_spec.rb similarity index 57% rename from test/integration/ssl-57/ssl_spec.rb rename to test/integration/replication-57/replication_spec.rb index 2b207a67..e193172d 100644 --- a/test/integration/ssl-57/ssl_spec.rb +++ b/test/integration/replication-57/replication_spec.rb @@ -1,3 +1,3 @@ require_relative '../helpers/server_spec.rb' -server_test('5.7', 'ssl') +server_test('5.7', 'replication') diff --git a/test/integration/ssl-80/ssl_spec.rb b/test/integration/replication-80/replication_spec.rb similarity index 57% rename from test/integration/ssl-80/ssl_spec.rb rename to test/integration/replication-80/replication_spec.rb index bc8fbb23..7382722c 100644 --- a/test/integration/ssl-80/ssl_spec.rb +++ b/test/integration/replication-80/replication_spec.rb @@ -1,3 +1,3 @@ require_relative '../helpers/server_spec.rb' -server_test('8.0', 'ssl') +server_test('8.0', 'replication') From 5a51c7378ea4d946acf50469af469341f0fa1589 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 10 Aug 2020 11:36:39 -0700 Subject: [PATCH 150/300] Check for file that typically gets created on 8.0 On < 8.0, /var/lib/mysql/user.frm doesn't typically get created so this ensures this works on 8.0 as well. Signed-off-by: Lance Albertson --- recipes/configure_server.rb | 1 + spec/configure_server_spec.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index e51f4bab..b9f1e157 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -129,6 +129,7 @@ command "mysql_install_db --defaults-file=#{percona['main_config_file']} --user=#{user}" end not_if "test -f #{datadir}/mysql/user.frm" + not_if "test -f #{datadir}/mysql.ibd" action :nothing end diff --git a/spec/configure_server_spec.rb b/spec/configure_server_spec.rb index f9eff344..a160ed24 100644 --- a/spec/configure_server_spec.rb +++ b/spec/configure_server_spec.rb @@ -5,6 +5,7 @@ describe 'first run' do before do stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(false) + stub_command('test -f /var/lib/mysql.ibd').and_return(false) stub_command("mysqladmin --user=root --password='' version").and_return(true) end @@ -117,6 +118,7 @@ before do stub_command('test -f /mysql/data/mysql/user.frm').and_return(true) + stub_command('test -f /mysql/data/mysql.ibd').and_return(true) stub_command("mysqladmin --user=root --password='' version").and_return(false) end From a1be0abe6c2360ae5f80af2a46abd5c5603afddb Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 10 Aug 2020 11:38:45 -0700 Subject: [PATCH 151/300] Disabling testing cluster suite in the CI This seems to have a problem on GH that I cannot resolve so we'll leave this out for now. It's likely due to how Galera works during bootstrap. Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfc8a70b..00ba88e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,9 +51,6 @@ jobs: - 'client-56' - 'client-57' - 'client-80' - - 'cluster-56' - - 'cluster-57' - - 'cluster-80' - 'server-56' - 'server-57' - 'server-80' @@ -66,8 +63,6 @@ jobs: exclude: - os: centos-8 suite: client-56 - - os: centos-8 - suite: cluster-56 - os: centos-8 suite: server-56 - os: centos-8 @@ -76,8 +71,6 @@ jobs: suite: replication-56 - os: debian-10 suite: client-56 - - os: debian-10 - suite: cluster-56 - os: debian-10 suite: server-56 - os: debian-10 @@ -86,8 +79,6 @@ jobs: suite: replication-56 - os: ubuntu-2004 suite: client-56 - - os: ubuntu-2004 - suite: cluster-56 - os: ubuntu-2004 suite: server-56 - os: ubuntu-2004 From 6edce2e9e171c563e26c978feb98afc42b4afa74 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 10 Aug 2020 13:21:13 -0700 Subject: [PATCH 152/300] Migrate InSpec tests to proper profiles This makes it much easier to manage these and resuse code. Signed-off-by: Lance Albertson --- kitchen.yml | 87 +++++++++++++++++++ test/integration/client-56/client_spec.rb | 3 - test/integration/client-57/client_spec.rb | 3 - test/integration/client-80/client_spec.rb | 3 - .../controls}/client_spec.rb | 7 +- test/integration/client/inspec.yml | 10 +++ test/integration/cluster-56/cluster_spec.rb | 3 - test/integration/cluster-57/cluster_spec.rb | 3 - test/integration/cluster-80/cluster_spec.rb | 3 - .../replication-56/replication_spec.rb | 3 - .../replication-57/replication_spec.rb | 3 - .../replication-80/replication_spec.rb | 3 - test/integration/server-56/server_spec.rb | 3 - test/integration/server-57/server_spec.rb | 3 - test/integration/server-80/server_spec.rb | 3 - .../controls}/server_spec.rb | 8 +- test/integration/server/inspec.yml | 13 +++ test/integration/source-56/source_spec.rb | 3 - test/integration/source-57/source_spec.rb | 3 - test/integration/source-80/source_spec.rb | 3 - 20 files changed, 123 insertions(+), 47 deletions(-) delete mode 100644 test/integration/client-56/client_spec.rb delete mode 100644 test/integration/client-57/client_spec.rb delete mode 100644 test/integration/client-80/client_spec.rb rename test/integration/{helpers => client/controls}/client_spec.rb (94%) create mode 100644 test/integration/client/inspec.yml delete mode 100644 test/integration/cluster-56/cluster_spec.rb delete mode 100644 test/integration/cluster-57/cluster_spec.rb delete mode 100644 test/integration/cluster-80/cluster_spec.rb delete mode 100644 test/integration/replication-56/replication_spec.rb delete mode 100644 test/integration/replication-57/replication_spec.rb delete mode 100644 test/integration/replication-80/replication_spec.rb delete mode 100644 test/integration/server-56/server_spec.rb delete mode 100644 test/integration/server-57/server_spec.rb delete mode 100644 test/integration/server-80/server_spec.rb rename test/integration/{helpers => server/controls}/server_spec.rb (98%) create mode 100644 test/integration/server/inspec.yml delete mode 100644 test/integration/source-56/source_spec.rb delete mode 100644 test/integration/source-57/source_spec.rb delete mode 100644 test/integration/source-80/source_spec.rb diff --git a/kitchen.yml b/kitchen.yml index 9a6832f7..39253eea 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -15,6 +15,9 @@ provisioner: verifier: name: inspec + inspec_tests: + - path: test/integration/client + - path: test/integration/server platforms: - name: centos-7 @@ -32,6 +35,11 @@ suites: attributes: percona: version: '5.6' + verifier: + controls: + - client + inputs: + version: '5.6' excludes: - centos-8 - debian-10 @@ -42,12 +50,22 @@ suites: attributes: percona: version: '5.7' + verifier: + controls: + - client + inputs: + version: '5.7' - name: client-80 run_list: - recipe[test::client] attributes: percona: version: '8.0' + verifier: + controls: + - client + inputs: + version: '8.0' - name: server-56 run_list: - recipe[test::server] @@ -58,18 +76,33 @@ suites: - centos-8 - debian-10 - ubuntu-20.04 + verifier: + controls: + - server + inputs: + version: '5.6' - name: server-57 run_list: - recipe[test::server] attributes: percona: version: '5.7' + verifier: + controls: + - server + inputs: + version: '5.7' - name: server-80 run_list: - recipe[test::server] attributes: percona: version: '8.0' + verifier: + controls: + - server + inputs: + version: '8.0' - name: source-56 run_list: - recipe[test::source] @@ -80,18 +113,36 @@ suites: - centos-8 - debian-10 - ubuntu-20.04 + verifier: + controls: + - server + inputs: + version: '5.6' + type: 'source' - name: source-57 run_list: - recipe[test::source] attributes: percona: version: '5.7' + verifier: + controls: + - server + inputs: + version: '5.7' + type: 'source' - name: source-80 run_list: - recipe[test::source] attributes: percona: version: '8.0' + verifier: + controls: + - server + inputs: + version: '8.0' + type: 'source' - name: cluster-56 run_list: - recipe[test::cluster] @@ -102,18 +153,36 @@ suites: - centos-8 - debian-10 - ubuntu-20.04 + verifier: + controls: + - server + inputs: + version: '5.6' + type: 'cluster' - name: cluster-57 run_list: - recipe[test::cluster] attributes: percona: version: '5.7' + verifier: + controls: + - server + inputs: + version: '5.7' + type: 'cluster' - name: cluster-80 run_list: - recipe[test::cluster] attributes: percona: version: '8.0' + verifier: + controls: + - server + inputs: + version: '8.0' + type: 'cluster' - name: replication-56 run_list: - recipe[test::replication] @@ -124,15 +193,33 @@ suites: - centos-8 - debian-10 - ubuntu-20.04 + verifier: + controls: + - server + inputs: + version: '5.6' + type: 'replication' - name: replication-57 run_list: - recipe[test::replication] attributes: percona: version: '5.7' + verifier: + controls: + - server + inputs: + version: '5.7' + type: 'replication' - name: replication-80 run_list: - recipe[test::replication] attributes: percona: version: '8.0' + verifier: + controls: + - server + inputs: + version: '8.0' + type: 'replication' diff --git a/test/integration/client-56/client_spec.rb b/test/integration/client-56/client_spec.rb deleted file mode 100644 index 76dc8b77..00000000 --- a/test/integration/client-56/client_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/client_spec.rb' - -client_test('5.6') diff --git a/test/integration/client-57/client_spec.rb b/test/integration/client-57/client_spec.rb deleted file mode 100644 index f5ebc451..00000000 --- a/test/integration/client-57/client_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/client_spec.rb' - -client_test('5.7') diff --git a/test/integration/client-80/client_spec.rb b/test/integration/client-80/client_spec.rb deleted file mode 100644 index c35af487..00000000 --- a/test/integration/client-80/client_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/client_spec.rb' - -client_test('8.0') diff --git a/test/integration/helpers/client_spec.rb b/test/integration/client/controls/client_spec.rb similarity index 94% rename from test/integration/helpers/client_spec.rb rename to test/integration/client/controls/client_spec.rb index bd599771..03a1a0f0 100644 --- a/test/integration/helpers/client_spec.rb +++ b/test/integration/client/controls/client_spec.rb @@ -1,4 +1,9 @@ -def client_test(version) +version = input('version') + +control 'client' do + desc 'Ensure Percona clients are installed.' + impact 1.0 + if os.family == 'debian' describe apt 'http://repo.percona.com/apt' do it { should exist } diff --git a/test/integration/client/inspec.yml b/test/integration/client/inspec.yml new file mode 100644 index 00000000..70d1e670 --- /dev/null +++ b/test/integration/client/inspec.yml @@ -0,0 +1,10 @@ +--- +name: client +title: Integration tests for Percona client installation +version: 0.1.0 +inputs: + - name: version + type: Numeric + required: true +supports: + - os-family: linux diff --git a/test/integration/cluster-56/cluster_spec.rb b/test/integration/cluster-56/cluster_spec.rb deleted file mode 100644 index d15177a7..00000000 --- a/test/integration/cluster-56/cluster_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('5.6', 'cluster') diff --git a/test/integration/cluster-57/cluster_spec.rb b/test/integration/cluster-57/cluster_spec.rb deleted file mode 100644 index 2229e862..00000000 --- a/test/integration/cluster-57/cluster_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('5.7', 'cluster') diff --git a/test/integration/cluster-80/cluster_spec.rb b/test/integration/cluster-80/cluster_spec.rb deleted file mode 100644 index 0f799ff1..00000000 --- a/test/integration/cluster-80/cluster_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('8.0', 'cluster') diff --git a/test/integration/replication-56/replication_spec.rb b/test/integration/replication-56/replication_spec.rb deleted file mode 100644 index 4d3bb5a6..00000000 --- a/test/integration/replication-56/replication_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('5.6', 'replication') diff --git a/test/integration/replication-57/replication_spec.rb b/test/integration/replication-57/replication_spec.rb deleted file mode 100644 index e193172d..00000000 --- a/test/integration/replication-57/replication_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('5.7', 'replication') diff --git a/test/integration/replication-80/replication_spec.rb b/test/integration/replication-80/replication_spec.rb deleted file mode 100644 index 7382722c..00000000 --- a/test/integration/replication-80/replication_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('8.0', 'replication') diff --git a/test/integration/server-56/server_spec.rb b/test/integration/server-56/server_spec.rb deleted file mode 100644 index a9b1529f..00000000 --- a/test/integration/server-56/server_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('5.6', 'server') diff --git a/test/integration/server-57/server_spec.rb b/test/integration/server-57/server_spec.rb deleted file mode 100644 index dc8bc783..00000000 --- a/test/integration/server-57/server_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('5.7', 'server') diff --git a/test/integration/server-80/server_spec.rb b/test/integration/server-80/server_spec.rb deleted file mode 100644 index 7ef9eecc..00000000 --- a/test/integration/server-80/server_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('8.0', 'server') diff --git a/test/integration/helpers/server_spec.rb b/test/integration/server/controls/server_spec.rb similarity index 98% rename from test/integration/helpers/server_spec.rb rename to test/integration/server/controls/server_spec.rb index 5f2ccd72..79f0444a 100644 --- a/test/integration/helpers/server_spec.rb +++ b/test/integration/server/controls/server_spec.rb @@ -1,4 +1,10 @@ -def server_test(version, type) +version = input('version') +type = input('type') + +control 'server' do + desc 'Ensure server is installed' + impact 1.0 + if os.family == 'debian' case type when 'server' diff --git a/test/integration/server/inspec.yml b/test/integration/server/inspec.yml new file mode 100644 index 00000000..2204e0a9 --- /dev/null +++ b/test/integration/server/inspec.yml @@ -0,0 +1,13 @@ +--- +name: server +title: Integration tests for Percona server installation +version: 0.1.0 +inputs: + - name: version + type: Numeric + required: true + - name: type + required: true + value: 'server' +supports: + - os-family: linux diff --git a/test/integration/source-56/source_spec.rb b/test/integration/source-56/source_spec.rb deleted file mode 100644 index 7d459976..00000000 --- a/test/integration/source-56/source_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('5.6', 'source') diff --git a/test/integration/source-57/source_spec.rb b/test/integration/source-57/source_spec.rb deleted file mode 100644 index 7e8aa079..00000000 --- a/test/integration/source-57/source_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('5.7', 'source') diff --git a/test/integration/source-80/source_spec.rb b/test/integration/source-80/source_spec.rb deleted file mode 100644 index c39dedd5..00000000 --- a/test/integration/source-80/source_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require_relative '../helpers/server_spec.rb' - -server_test('8.0', 'source') From 9a688053a6878a1c41c198a5ab8755d36a6e2465 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 10 Aug 2020 15:33:38 -0700 Subject: [PATCH 153/300] Move client package installation for cluster to cluster recipe Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + attributes/client.rb | 20 ++++---------------- recipes/cluster.rb | 17 +++++++++++++++++ recipes/server.rb | 4 +--- spec/cluster_spec.rb | 25 +++++++++++++++++++++++++ spec/server_spec.rb | 3 ++- 6 files changed, 50 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65262c88..44eafcf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ This file is used to list changes made in each version of the percona cookbook. - Convert to InSpec tests and refactor test cookbook recipes - Don't install abi_version packages on Debian/Ubuntu - Standardise files with files in sous-chefs/repo-management +- Move client package installation for cluster to cluster recipe ### Removed diff --git a/attributes/client.rb b/attributes/client.rb index f526f070..60017224 100644 --- a/attributes/client.rb +++ b/attributes/client.rb @@ -14,28 +14,16 @@ case node['platform_family'] when 'debian' default['percona']['client']['packages'] = - if Array(node['percona']['server']['role']).include?('cluster') - %W( - percona-xtradb-cluster-client-#{version} - ) - elsif node['percona']['version'].to_f >= 8.0 + if node['percona']['version'].to_f >= 8.0 %w(percona-server-client) else - %W( - percona-server-client-#{version} - ) + %W(percona-server-client-#{version}) end when 'rhel' default['percona']['client']['packages'] = - if Array(node['percona']['server']['role']).include?('cluster') - %W( - Percona-XtraDB-Cluster-client-#{version} - ) - elsif node['percona']['version'].to_f >= 8.0 + if node['percona']['version'].to_f >= 8.0 %w(percona-server-client) else - %W( - Percona-Server-client-#{version} - ) + %W(Percona-Server-client-#{version}) end end diff --git a/recipes/cluster.rb b/recipes/cluster.rb index b1a91084..1cd309d4 100644 --- a/recipes/cluster.rb +++ b/recipes/cluster.rb @@ -4,7 +4,24 @@ # node.default['percona']['repositories'] = %w(pxc-80) +node.default['percona']['client']['packages'] = + case node['platform_family'] + when 'debian' + if node['percona']['version'].to_f >= 8.0 + %w(percona-xtradb-cluster-client) + else + %W(percona-xtradb-cluster-client-#{node['percona']['version']}) + end + when 'rhel' + if node['percona']['version'].to_f >= 8.0 + %w(percona-xtradb-cluster-client) + else + %W(Percona-XtraDB-Cluster-client-#{node['percona']['version'].tr('.', '')}) + end + end + include_recipe 'percona::package_repo' +include_recipe 'percona::client' # Determine and set wsrep_sst_receive_address if node['percona']['cluster']['wsrep_sst_receive_interface'] diff --git a/recipes/server.rb b/recipes/server.rb index a29c5db0..9af83cd9 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -4,6 +4,7 @@ # include_recipe 'percona::package_repo' +include_recipe 'percona::client' # install packages case node['platform_family'] @@ -13,9 +14,6 @@ action node['percona']['server']['package_action'].to_sym end when 'rhel' - # we need mysqladmin - include_recipe 'percona::client' - package node['percona']['server']['package'] do action node['percona']['server']['package_action'].to_sym end diff --git a/spec/cluster_spec.rb b/spec/cluster_spec.rb index 3767a2be..8669085f 100644 --- a/spec/cluster_spec.rb +++ b/spec/cluster_spec.rb @@ -11,6 +11,7 @@ %w( percona::package_repo + percona::client percona::configure_server percona::access_grants ).each do |r| @@ -30,6 +31,10 @@ it do expect(chef_run).to install_package 'percona-xtradb-cluster-56' end + + it do + expect(chef_run).to install_package 'percona-xtradb-cluster-client-5.6' + end end describe 'CentOS' do @@ -42,6 +47,10 @@ it do expect(chef_run).to install_package 'Percona-XtraDB-Cluster-56' end + + it do + expect(chef_run).to install_package 'Percona-XtraDB-Cluster-client-56' + end end end describe 'version 5.7' do @@ -51,6 +60,10 @@ it do expect(chef_run).to install_package 'percona-xtradb-cluster-57' end + + it do + expect(chef_run).to install_package 'percona-xtradb-cluster-client-5.7' + end end describe 'CentOS' do @@ -63,6 +76,10 @@ it do expect(chef_run).to install_package 'Percona-XtraDB-Cluster-57' end + + it do + expect(chef_run).to install_package 'Percona-XtraDB-Cluster-client-57' + end end end describe 'version 8.0' do @@ -72,6 +89,10 @@ it do expect(chef_run).to install_package 'percona-xtradb-cluster-server' end + + it do + expect(chef_run).to install_package 'percona-xtradb-cluster-client' + end end describe 'CentOS' do @@ -84,6 +105,10 @@ it do expect(chef_run).to install_package 'percona-xtradb-cluster-server' end + + it do + expect(chef_run).to install_package 'percona-xtradb-cluster-client' + end end end end diff --git a/spec/server_spec.rb b/spec/server_spec.rb index 34507246..da06fc5f 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -8,6 +8,8 @@ stub_command('dnf module list mysql | grep -q "^mysql.*\\[x\\]"') end + it { expect(chef_run).to include_recipe('percona::client') } + describe 'Ubuntu' do platform 'ubuntu' @@ -35,7 +37,6 @@ context 'CentOS' do platform 'centos' - it { expect(chef_run).to include_recipe('percona::client') } it { expect(chef_run).to install_package('percona-server-server') } it do From 382e4e4978311ac1da5ee9b2bdb5a0abcbd36139 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 10 Aug 2020 15:34:39 -0700 Subject: [PATCH 154/300] Move all InSpec tests into a single percona profile Signed-off-by: Lance Albertson --- kitchen.yml | 18 ++++++++- test/integration/client/inspec.yml | 10 ----- .../controls/client_spec.rb | 40 +++++++++++++------ .../controls/server_spec.rb | 0 .../inspec/controls/toolkit_spec.rb | 16 ++++++++ .../integration/{server => inspec}/inspec.yml | 5 +-- 6 files changed, 61 insertions(+), 28 deletions(-) delete mode 100644 test/integration/client/inspec.yml rename test/integration/{client => inspec}/controls/client_spec.rb (64%) rename test/integration/{server => inspec}/controls/server_spec.rb (100%) create mode 100644 test/integration/inspec/controls/toolkit_spec.rb rename test/integration/{server => inspec}/inspec.yml (62%) diff --git a/kitchen.yml b/kitchen.yml index 39253eea..63f59a3f 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -16,8 +16,7 @@ provisioner: verifier: name: inspec inspec_tests: - - path: test/integration/client - - path: test/integration/server + - path: test/integration/inspec platforms: - name: centos-7 @@ -38,6 +37,7 @@ suites: verifier: controls: - client + - toolkit inputs: version: '5.6' excludes: @@ -53,6 +53,7 @@ suites: verifier: controls: - client + - toolkit inputs: version: '5.7' - name: client-80 @@ -64,6 +65,7 @@ suites: verifier: controls: - client + - toolkit inputs: version: '8.0' - name: server-56 @@ -78,6 +80,7 @@ suites: - ubuntu-20.04 verifier: controls: + - client - server inputs: version: '5.6' @@ -89,6 +92,7 @@ suites: version: '5.7' verifier: controls: + - client - server inputs: version: '5.7' @@ -100,6 +104,7 @@ suites: version: '8.0' verifier: controls: + - client - server inputs: version: '8.0' @@ -115,6 +120,7 @@ suites: - ubuntu-20.04 verifier: controls: + - client - server inputs: version: '5.6' @@ -127,6 +133,7 @@ suites: version: '5.7' verifier: controls: + - client - server inputs: version: '5.7' @@ -139,6 +146,7 @@ suites: version: '8.0' verifier: controls: + - client - server inputs: version: '8.0' @@ -155,6 +163,7 @@ suites: - ubuntu-20.04 verifier: controls: + - client - server inputs: version: '5.6' @@ -167,6 +176,7 @@ suites: version: '5.7' verifier: controls: + - client - server inputs: version: '5.7' @@ -179,6 +189,7 @@ suites: version: '8.0' verifier: controls: + - client - server inputs: version: '8.0' @@ -195,6 +206,7 @@ suites: - ubuntu-20.04 verifier: controls: + - client - server inputs: version: '5.6' @@ -207,6 +219,7 @@ suites: version: '5.7' verifier: controls: + - client - server inputs: version: '5.7' @@ -219,6 +232,7 @@ suites: version: '8.0' verifier: controls: + - client - server inputs: version: '8.0' diff --git a/test/integration/client/inspec.yml b/test/integration/client/inspec.yml deleted file mode 100644 index 70d1e670..00000000 --- a/test/integration/client/inspec.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: client -title: Integration tests for Percona client installation -version: 0.1.0 -inputs: - - name: version - type: Numeric - required: true -supports: - - os-family: linux diff --git a/test/integration/client/controls/client_spec.rb b/test/integration/inspec/controls/client_spec.rb similarity index 64% rename from test/integration/client/controls/client_spec.rb rename to test/integration/inspec/controls/client_spec.rb index 03a1a0f0..6c5cec8c 100644 --- a/test/integration/client/controls/client_spec.rb +++ b/test/integration/inspec/controls/client_spec.rb @@ -1,4 +1,5 @@ version = input('version') +type = input('type') control 'client' do desc 'Ensure Percona clients are installed.' @@ -10,7 +11,12 @@ it { should be_enabled } end - if version.to_f >= 8.0 + if type == 'cluster' && version.to_f >= 8.0 + describe apt 'http://repo.percona.com/pxc-80/apt' do + it { should exist } + it { should be_enabled } + end + elsif version.to_f >= 8.0 describe apt 'http://repo.percona.com/ps-80/apt' do it { should exist } it { should be_enabled } @@ -27,7 +33,16 @@ its('content') { should match 'release o=Percona Development Team' } end - if version.to_f >= 8.0 + if type == 'cluster' && version.to_f >= 8.0 + describe package 'percona-xtradb-cluster-client' do + it { should be_installed } + its('version') { should >= '1:8' } + end + elsif type == 'cluster' + describe package "percona-xtradb-cluster-client-#{version}" do + it { should be_installed } + end + elsif version.to_f >= 8.0 describe package 'percona-server-client' do it { should be_installed } its('version') { should >= '8' } @@ -49,7 +64,16 @@ it { should be_enabled } end - if version.to_f >= 8.0 + if type == 'cluster' && version.to_f >= 8.0 + describe package 'percona-xtradb-cluster-client' do + it { should be_installed } + its('version') { should >= '8' } + end + elsif type == 'cluster' + describe package "Percona-XtraDB-Cluster-client-#{version.tr('.', '')}" do + it { should be_installed } + end + elsif version.to_f >= 8.0 describe package 'percona-server-client' do it { should be_installed } its('version') { should >= '8' } @@ -61,16 +85,6 @@ end end - if version.to_f >= 8.0 && os.family == 'redhat' && os.release.to_i >= 8 - describe package 'percona-toolkit' do - it { should_not be_installed } - end - else - describe package 'percona-toolkit' do - it { should be_installed } - end - end - describe command 'mysql --version' do its('exit_status') { should eq 0 } if version.to_f >= 8.0 diff --git a/test/integration/server/controls/server_spec.rb b/test/integration/inspec/controls/server_spec.rb similarity index 100% rename from test/integration/server/controls/server_spec.rb rename to test/integration/inspec/controls/server_spec.rb diff --git a/test/integration/inspec/controls/toolkit_spec.rb b/test/integration/inspec/controls/toolkit_spec.rb new file mode 100644 index 00000000..7fdf7f89 --- /dev/null +++ b/test/integration/inspec/controls/toolkit_spec.rb @@ -0,0 +1,16 @@ +version = input('version') + +control 'toolkit' do + desc 'Ensure Percona toolkit are installed.' + impact 1.0 + + if version.to_f >= 8.0 && os.family == 'redhat' && os.release.to_i >= 8 + describe package 'percona-toolkit' do + it { should_not be_installed } + end + else + describe package 'percona-toolkit' do + it { should be_installed } + end + end +end diff --git a/test/integration/server/inspec.yml b/test/integration/inspec/inspec.yml similarity index 62% rename from test/integration/server/inspec.yml rename to test/integration/inspec/inspec.yml index 2204e0a9..98f89868 100644 --- a/test/integration/server/inspec.yml +++ b/test/integration/inspec/inspec.yml @@ -1,13 +1,12 @@ --- -name: server -title: Integration tests for Percona server installation +name: percona +title: Integration tests for the Percona Cookbook version: 0.1.0 inputs: - name: version type: Numeric required: true - name: type - required: true value: 'server' supports: - os-family: linux From 410af7736c41861f6b98e93747cc83815ee9f550 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 10 Aug 2020 15:40:39 -0700 Subject: [PATCH 155/300] Suite to test compatibility with Chef 13 Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 3 +++ CHANGELOG.md | 1 + kitchen.dokken.yml | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00ba88e3..5b774cfd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,11 +41,14 @@ jobs: matrix: os: - 'debian-9' + - 'debian-9-chef-13' - 'debian-10' - 'centos-7' + - 'centos-7-chef-13' - 'centos-8' - 'ubuntu-1604' - 'ubuntu-1804' + - 'ubuntu-1804-chef-13' - 'ubuntu-2004' suite: - 'client-56' diff --git a/CHANGELOG.md b/CHANGELOG.md index 44eafcf6..2ac333b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This file is used to list changes made in each version of the percona cookbook. - Re-add ChefSpec tests - Add ssl suite and tests for ssl recipe - Add master suite and tests for testing the replication recipe +- Suite to test compatibility with Chef 13 ### Fixed diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 46541e33..0d7c06c3 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -20,6 +20,14 @@ platforms: intermediate_instructions: - RUN /usr/bin/apt-get update + - name: debian-9-chef-13 + driver: + image: dokken/debian-9 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + chef_version: 13 + - name: debian-10 driver: image: dokken/debian-10 @@ -32,6 +40,12 @@ platforms: image: dokken/centos-7 pid_one_command: /usr/lib/systemd/systemd + - name: centos-7-chef-13 + driver: + image: dokken/centos-7 + pid_one_command: /usr/lib/systemd/systemd + chef_version: 13 + - name: centos-8 driver: image: dokken/centos-8 @@ -51,6 +65,14 @@ platforms: intermediate_instructions: - RUN /usr/bin/apt-get update + - name: ubuntu-18.04-chef-13 + driver: + image: dokken/ubuntu-18.04 + pid_one_command: /bin/systemd + intermediate_instructions: + - RUN /usr/bin/apt-get update + chef_version: 13 + - name: ubuntu-20.04 driver: image: dokken/ubuntu-20.04 From 7fb4bcfd20864cd8d1868658c7ccce453c57cfe2 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 10 Aug 2020 16:34:32 -0700 Subject: [PATCH 156/300] Update README Signed-off-by: Lance Albertson --- README.md | 310 +++++------------------------------------------------- 1 file changed, 25 insertions(+), 285 deletions(-) diff --git a/README.md b/README.md index b32bf738..833ab6ee 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ MySQL cookbook as much as possible.) Optionally installs: -- [XtraBackup](http://www.percona.com/software/percona-xtrabackup/) hot backup software -- [Percona Toolkit](http://www.percona.com/software/percona-toolkit/) advanced command-line tools -- [XtraDB Cluster](http://www.percona.com/software/percona-xtradb-cluster/) high availability and high scalability solution for MySQL. +- [XtraBackup](https://www.percona.com/software/mysql-database/percona-xtrabackup) hot backup software +- [Percona Toolkit](https://www.percona.com/software/database-tools/percona-toolkit) advanced command-line tools +- [XtraDB Cluster](https://www.percona.com/software/mysql-database/percona-xtradb-cluster) high availability and high scalability solution for MySQL. ## Maintainers @@ -34,22 +34,18 @@ We provide an expanding set of tests against the following 64-bit platforms whic ### Cookbooks -- [apt](https://supermarket.getchef.com/cookbooks/apt) Chef LWRP Cookbook -- [openssl](https://supermarket.getchef.com/cookbooks/openssl) Chef Cookbook -- [yum](https://supermarket.getchef.com/cookbooks/yum) Chef LWRP Cookbook -- [yum-epel](https://supermarket.getchef.com/cookbooks/yum-epel) Chef LWRP Cookbook +- [openssl](https://supermarket.chef.io/cookbooks/openssl) +- [yum-epel](https://supermarket.chef.io/cookbooks/yum-epel) +- [chef-vault](https://supermarket.chef.io/cookbooks/chef-vault) +- [line](https://supermarket.chef.io/cookbooks/line) ### Chef -This cookbook requires Chef >= 11.14.2 due to the use of the `sensitive` attribute for some resources. - -We aim to test the most recent releases of Chef. You can view -the [currently tested versions](https://github.com/phlipper/chef-percona/blob/master/.travis.yml). -(Feel free to submit a pull request if they're out of date!) +This cookbook requires Chef >= 13. ## Recipes -- `percona` - The default no-op recipe. +- `percona` - The default which includes the client recipe. - `percona::package_repo` - Sets up the package repository and installs common packages. - `percona::client` - Installs the Percona MySQL client libraries. - `percona::server` - Installs and configures the Percona MySQL server daemon. @@ -59,6 +55,7 @@ the [currently tested versions](https://github.com/phlipper/chef-percona/blob/ma - `percona::configure_server` - Used internally to manage the server configuration. - `percona::replication` - Used internally to grant permissions for replication. - `percona::access_grants` - Used internally to grant permissions for recipes. +- `percona::ssl` - Used internally to setup ssl certificates for server/client. ## Usage @@ -73,17 +70,17 @@ this cookbook will only use the new terminology. ### Encrypted Passwords -This cookbook requires [Encrypted Data Bags](http://wiki.opscode.com/display/chef/Encrypted+Data+Bags). If you forget to use them or do not use a node attribute to overwrite them empty passwords will be used. +This cookbook requires [Encrypted Data Bags](https://docs.chef.io/secrets/#encrypt-a-data-bag-item). If you forget to use them or do not use a node attribute to overwrite them empty passwords will be used. -To use encrypted passwords, you must create an encrypted data bag. This cookbook assumes a data bag named `passwords`, but you can override the name using the `node[:percona][:encrypted_data_bag]` attribute. You can also optionally specify a data bag secret file to be loaded for the secret key using the `node[:percona][:encrypted_data_bag_secret_file]` attribute. +To use encrypted passwords, you must create an encrypted data bag. This cookbook assumes a data bag named `passwords`, but you can override the name using the `node['percona']['encrypted_data_bag']` attribute. You can also optionally specify a data bag secret file to be loaded for the secret key using the `node['percona']['encrypted_data_bag_secret_file']` attribute. This cookbook expects a `mysql` item and a `system` item. Please refer to the official documentation on how to get this setup. It actually uses a MySQL example so it can be mostly copied. Ensure you cover the data bag items as described below. -You also may set expected item names via attributes `node["percona"]["encrypted_data_bag_item_mysql"]` and `node["percona"]["encrypted_data_bag_item_system"]`. +You also may set expected item names via attributes `node['percona']['encrypted_data_bag_item_mysql']` and `node['percona']['encrypted_data_bag_item_system']`. ### Skip passwords -Set the `["percona"]["skip_passwords"]` attribute to skip setting up passwords. Removes the need for the encrypted data bag if using chef-solo. Is useful for setting up development and ci environments where you just want to use the root user with no password. If you are doing this you may want to set `[:percona][:server][:debian_username]` to be `"root"` also. +Set the `['percona']['skip_passwords']` attribute to skip setting up passwords. Removes the need for the encrypted data bag if using chef-solo. Is useful for setting up development and ci environments where you just want to use the root user with no password. If you are doing this you may want to set `['percona']['server']['debian_username']` to be `"root"` also. ### Skip Configure @@ -95,9 +92,9 @@ The mysql item should contain entries for root, backup, and replication. If no v #### system item -The "system" item should contain an entry for the debian system user as specified in the `node[:percona][:server][:debian_username]` attribute. If no such entry is found, the cookbook will fall back to the default non-encrypted password. +The "system" item should contain an entry for the debian system user as specified in the `node['percona']['server']['debian_username']` attribute. If no such entry is found, the cookbook will fall back to the default non-encrypted password. -Example: "passwords" data bag - this example assumes that `node[:percona][:server][:debian_username] = spud` +Example: "passwords" data bag - this example assumes that `node['percona']['server']['debian_username'] = spud` ```javascript { @@ -118,8 +115,8 @@ Above shows the encrypted password in the data bag. Check out the `encrypted_dat ### Replication over SSL -To enable SSL based replication, you will need to flip the attribute `node[:percona][:server][:replication][:ssl_enabled]` to `true` and add a new data_bag item -to the percona encrypted data_bag (see`node[:percona][:encrypted_data_bag]` attribute) with the id `ssl_replication` ( see `node["percona"]["encrypted_data_bag_item_ssl_replication"]` attribute) that contains this data: +To enable SSL based replication, you will need to flip the attribute `node['percona']['server']['replication']['ssl_enabled']` to `true` and add a new data_bag item +to the percona encrypted data_bag (see`node['percona']['encrypted_data_bag']` attribute) with the id `ssl_replication` ( see `node['percona']['encrypted_data_bag_item_ssl_replication']` attribute) that contains this data: ```javascript { @@ -136,12 +133,12 @@ to the percona encrypted data_bag (see`node[:percona][:encrypted_data_bag]` attr } ``` -All certificates and keys have to be converted to a string (easiest way is to use ruby: */usr/bin/env ruby -e 'p ARGF.read'* **filename**) and placed +All certificates and keys have to be converted to a string (easiest way is to use ruby: `/usr/bin/env ruby -e 'p ARGF.read' `) and placed instead of CA_CERTIFICATE_STRING, SERVER_CERTIFICATE_STRING, SERVER_KEY_STRING, CLIENT_CERTIFICATE_STRING, CLIENT_KEY_STRING. ### Percona XtraDB Cluster -Below is a minimal example setup to bootstrap a Percona XtraDB Cluster. Please see the [official documentation](http://www.percona.com/doc/percona-xtradb-cluster/5.6/index.html) for more information. This is not a perfect example. It is just a sample to get you started. +Below is a minimal example setup to bootstrap a Percona XtraDB Cluster. Please see the [official documentation](https://www.percona.com/doc/percona-xtradb-cluster/8.0/index.html) for more information. This is not a perfect example. It is just a sample to get you started. Wrapper recipe recipes/percona.rb: @@ -178,8 +175,8 @@ end cluster_address = "gcomm://#{cluster_ips.join(',')}" Chef::Log.info "Using Percona XtraDB cluster address of: #{cluster_address}" -node.override["percona"]["cluster"]["wsrep_cluster_address"] = cluster_address -node.override["percona"]["cluster"]["wsrep_node_name"] = node['hostname'] +node.override['percona']['cluster']['wsrep_cluster_address'] = cluster_address +node.override['percona']['cluster']['wsrep_node_name'] = node['hostname'] include_recipe 'percona::cluster' include_recipe 'percona::backup' @@ -211,271 +208,14 @@ default_attributes( Now you need to bring three servers up one at a time with the percona role applied to them. By default the servers will sync up via rsync server state transfer (SST) -## Attributes - -```ruby -default["percona"]["version"] = "8.0" -version = node["percona"]["version"] - -# Always restart percona on configuration changes -default["percona"]["auto_restart"] = true - -case node["platform_family"] -when "debian" - default["percona"]["server"]["socket"] = "/var/run/mysqld/mysqld.sock" - default["percona"]["server"]["default_storage_engine"] = "InnoDB" - default["percona"]["server"]["includedir"] = "/etc/mysql/conf.d/" - default["percona"]["server"]["pidfile"] = "/var/run/mysqld/mysqld.pid" - default["percona"]["server"]["package"] = "percona-server-server-#{version}" -when "rhel" - default["percona"]["server"]["socket"] = "/var/lib/mysql/mysql.sock" - default["percona"]["server"]["default_storage_engine"] = "innodb" - default["percona"]["server"]["includedir"] = "" - default["percona"]["server"]["pidfile"] = "/var/lib/mysql/mysqld.pid" - default["percona"]["server"]["package"] = "Percona-Server-server-#{version.tr(".", "")}" - default["percona"]["server"]["shared_pkg"] = "Percona-Server-shared-#{version.tr(".", "")}" -end - -# Cookbook Settings -default["percona"]["main_config_file"] = value_for_platform_family( - "debian" => "/etc/mysql/my.cnf", - "rhel" => "/etc/my.cnf" -) -default["percona"]["apt"]["keyserver"] = "hkp://keys.gnupg.net:80" -default["percona"]["encrypted_data_bag"] = "passwords" -default["percona"]["encrypted_data_bag_secret_file"] = "" -default["percona"]["use_chef_vault"] = false -default["percona"]["skip_passwords"] = false -default["percona"]["skip_configure"] = false - -# Start percona server on boot -default["percona"]["server"]["enable"] = true - -# SELinux module URL -default["percona"]["selinux_module_url"] = "https://github.com/gguillen/selinux_percona-pxc-56-cluster/raw/master/percona-pxc-56-cluster.pp" - -# install vs. upgrade packages -default["percona"]["server"]["package_action"] = "install" - -# Basic Settings -default["percona"]["server"]["role"] = ["standalone"] -default["percona"]["server"]["username"] = "mysql" -default["percona"]["server"]["datadir"] = "/var/lib/mysql" -default["percona"]["server"]["logdir"] = "/var/log/mysql" -default["percona"]["server"]["tmpdir"] = "/tmp" -default["percona"]["server"]["slave_load_tmpdir"] = "/tmp" -default["percona"]["server"]["debian_username"] = "debian-sys-maint" -default["percona"]["server"]["jemalloc"] = false -default["percona"]["server"]["jemalloc_lib"] = value_for_platform_family( - "debian" => value_for_platform( - "ubuntu" => { - "trusty" => "/usr/lib/x86_64-linux-gnu/libjemalloc.so.1", - "precise" => "/usr/lib/libjemalloc.so.1" - } - ), - "rhel" => "/usr/lib64/libjemalloc.so.1" -) -default["percona"]["server"]["nice"] = 0 -default["percona"]["server"]["open_files_limit"] = 16_384 -default["percona"]["server"]["hostname"] = "localhost" -default["percona"]["server"]["basedir"] = "/usr" -default["percona"]["server"]["port"] = 3306 -default["percona"]["server"]["language"] = "/usr/share/mysql/english" -default["percona"]["server"]["character_set"] = "utf8" -default["percona"]["server"]["collation"] = "utf8_unicode_ci" -default["percona"]["server"]["skip_name_resolve"] = false -default["percona"]["server"]["skip_external_locking"] = true -default["percona"]["server"]["net_read_timeout"] = 120 -default["percona"]["server"]["connect_timeout"] = 10 -default["percona"]["server"]["wait_timeout"] = 28_800 -default["percona"]["server"]["old_passwords"] = 0 -default["percona"]["server"]["bind_address"] = "127.0.0.1" -default["percona"]["server"]["federated"] = false - -%w[debian_password root_password].each do |attribute| - next if attribute?(node["percona"]["server"][attribute]) - default["percona"]["server"][attribute] = random_password -end - -# Fine Tuning -default["percona"]["server"]["key_buffer_size"] = "16M" -default["percona"]["server"]["max_allowed_packet"] = "64M" -default["percona"]["server"]["thread_stack"] = "192K" -default["percona"]["server"]["query_alloc_block_size"] = "16K" -default["percona"]["server"]["memlock"] = false -default["percona"]["server"]["transaction_isolation"] = "REPEATABLE-READ" -default["percona"]["server"]["tmp_table_size"] = "64M" -default["percona"]["server"]["max_heap_table_size"] = "64M" -default["percona"]["server"]["sort_buffer_size"] = "8M" -default["percona"]["server"]["join_buffer_size"] = "8M" -default["percona"]["server"]["thread_cache_size"] = 16 -default["percona"]["server"]["back_log"] = 50 -default["percona"]["server"]["max_connections"] = 30 -default["percona"]["server"]["max_connect_errors"] = 9_999_999 -default["percona"]["server"]["sql_modes"] = [] -default["percona"]["server"]["table_cache"] = 8192 -default["percona"]["server"]["group_concat_max_len"] = 4096 -default["percona"]["server"]["expand_fast_index_creation"] = false -default["percona"]["server"]["read_rnd_buffer_size"] = 262_144 - -# Query Cache Configuration -default["percona"]["server"]["query_cache_size"] = "64M" -default["percona"]["server"]["query_cache_limit"] = "2M" - -# Logging and Replication -default["percona"]["server"]["sync_binlog"] = (node["percona"]["server"]["role"] == "cluster" ? 0 : 1) -default["percona"]["server"]["slow_query_log"] = 1 -default["percona"]["server"]["slow_query_logdir"] = "/var/log/mysql" -default["percona"]["server"]["slow_query_log_file"] = "#{node["percona"]["server"]["slow_query_logdir"]}/mysql-slow.log" -default["percona"]["server"]["long_query_time"] = 2 -default["percona"]["server"]["server_id"] = 1 -default["percona"]["server"]["binlog_do_db"] = [] -default["percona"]["server"]["binlog_ignore_db"] = [] -default["percona"]["server"]["expire_logs_days"] = 10 -default["percona"]["server"]["max_binlog_size"] = "100M" -default["percona"]["server"]["binlog_cache_size"] = "1M" -default["percona"]["server"]["binlog_format"] = "MIXED" -default["percona"]["server"]["log_bin"] = "master-bin" -default["percona"]["server"]["relay_log"] = "slave-relay-bin" -default["percona"]["server"]["log_slave_updates"] = false -default["percona"]["server"]["log_warnings"] = true -default["percona"]["server"]["log_long_format"] = false -default["percona"]["server"]["bulk_insert_buffer_size"] = "64M" - -# MyISAM Specific -default["percona"]["server"]["myisam_recover_options"] = "BACKUP" -default["percona"]["server"]["myisam_sort_buffer_size"] = "128M" -default["percona"]["server"]["myisam_max_sort_file_size"] = "10G" -default["percona"]["server"]["myisam_repair_threads"] = 1 -default["percona"]["server"]["read_buffer_size"] = "8M" - -# InnoDB Specific -default["percona"]["server"]["skip_innodb"] = false -default["percona"]["server"]["innodb_additional_mem_pool_size"] = "32M" -default["percona"]["server"]["innodb_buffer_pool_size"] = "128M" -default["percona"]["server"]["innodb_data_file_path"] = "ibdata1:10M:autoextend" -default["percona"]["server"]["innodb_autoextend_increment"] = "128M" -default["percona"]["server"]["innodb_open_files"] = 2000 -default["percona"]["server"]["innodb_file_per_table"] = true -default["percona"]["server"]["innodb_file_format"] = "Antelope" -default["percona"]["server"]["innodb_data_home_dir"] = "" -default["percona"]["server"]["innodb_thread_concurrency"] = 16 -default["percona"]["server"]["innodb_flush_log_at_trx_commit"] = 1 -default["percona"]["server"]["innodb_fast_shutdown"] = false -default["percona"]["server"]["innodb_log_buffer_size"] = "64M" -default["percona"]["server"]["innodb_log_file_size"] = "5M" -default["percona"]["server"]["innodb_log_files_in_group"] = 2 -default["percona"]["server"]["innodb_max_dirty_pages_pct"] = 80 -default["percona"]["server"]["innodb_flush_method"] = "O_DIRECT" -default["percona"]["server"]["innodb_lock_wait_timeout"] = 120 -default["percona"]["server"]["innodb_import_table_from_xtrabackup"] = 0 - -# Performance Schema -default["percona"]["server"]["performance_schema"] = false - -# Replication Settings -default["percona"]["server"]["replication"]["read_only"] = false -default["percona"]["server"]["replication"]["host"] = "" -default["percona"]["server"]["replication"]["username"] = "" -default["percona"]["server"]["replication"]["password"] = "" -default["percona"]["server"]["replication"]["port"] = 3306 -default["percona"]["server"]["replication"]["ignore_db"] = [] -default["percona"]["server"]["replication"]["ignore_table"] = [] -default["percona"]["server"]["replication"]["ssl_enabled"] = false -default["percona"]["server"]["replication"]["suppress_1592"] = false -default["percona"]["server"]["replication"]["skip_slave_start"] = false -default["percona"]["server"]["replication"]["slave_transaction_retries"] = 10 - -# XtraBackup Settings -default["percona"]["backup"]["configure"] = false -default["percona"]["backup"]["username"] = "backup" -unless attribute?(node["percona"]["backup"]["password"]) - default["percona"]["backup"]["password"] = random_password -end - -# XtraDB Cluster Settings -default["percona"]["cluster"]["package"] = value_for_platform_family( - "debian" => "percona-xtradb-cluster-#{version.tr(".", "")}", - "rhel" => "Percona-XtraDB-Cluster-#{version.tr(".", "")}" -) -default["percona"]["cluster"]["binlog_format"] = "ROW" -default["percona"]["cluster"]["wsrep_provider"] = value_for_platform_family( - "debian" => "/usr/lib/libgalera_smm.so", - "rhel" => "/usr/lib64/libgalera_smm.so" -) -default["percona"]["cluster"]["wsrep_provider_options"] = "" -default["percona"]["cluster"]["wsrep_cluster_address"] = "" -default["percona"]["cluster"]["wsrep_slave_threads"] = 2 -default["percona"]["cluster"]["wsrep_cluster_name"] = "" -default["percona"]["cluster"]["wsrep_sst_method"] = "rsync" -default["percona"]["cluster"]["wsrep_node_name"] = "" -default["percona"]["cluster"]["wsrep_notify_cmd"] = "" -default["percona"]["cluster"]["wsrep_sst_auth"] = "" - -# These both are used to build wsrep_sst_receive_address -default["percona"]["cluster"]["wsrep_sst_receive_interface"] = nil # Works like node["percona"]["server"]["bind_to"] -default["percona"]["cluster"]["wsrep_sst_receive_port"] = "4444" - -default["percona"]["cluster"]["innodb_locks_unsafe_for_binlog"] = 1 -default["percona"]["cluster"]["innodb_autoinc_lock_mode"] = 2 -``` - -### client.rb - -```ruby -# install vs. upgrade packages -default["percona"]["client"]["package_action"] = "install" - -version = value_for_platform_family( - "debian" => node["percona"]["version"], - "rhel" => node["percona"]["version"].tr(".", "") -) - -case node["platform_family"] -when "debian" - abi_version = case version - when "5.5" then "18" - when "5.6" then "18.1" - else "" - end - - default["percona"]["client"]["packages"] = %W[ - libperconaserverclient#{abi_version}-dev percona-server-client-#{version} - ] -when "rhel" - if Array(node["percona"]["server"]["role"]).include?("cluster") - default["percona"]["client"]["packages"] = %W[ - Percona-XtraDB-Cluster-devel-#{version} Percona-XtraDB-Cluster-client-#{version} - ] - else - default["percona"]["client"]["packages"] = %W[ - Percona-Server-devel-#{version} Percona-Server-client-#{version} - ] - end -end -``` - -### package_repo.rb - -```ruby -default["percona"]["yum"]["description"] = "Percona Packages" -default["percona"]["yum"]["baseurl"] = "http://repo.percona.com/centos/#{pversion}/os/#{arch}/" -default["percona"]["yum"]["gpgkey"] = [ - 'https://repo.percona.com/yum/PERCONA-PACKAGING-KEY', - 'https://repo.percona.com/yum/RPM-GPG-KEY-Percona', -] -default["percona"]["yum"]["gpgcheck"] = true -default["percona"]["yum"]["sslverify"] = true -``` - ## Explicit my.cnf templating -In some situation it is preferable to explicitly define the attributes needed in a `my.cnf` file. This is enabled by adding categories to the `node[:percona][:conf]` attributes. All keys found in the `node[:percona][:conf]` map will represent categories in the `my.cnf` file. Each category contains a map of attributes that will be written to the `my.cnf` file for that category. See the example for more details. +In some situations it is preferable to explicitly define the attributes needed in a `my.cnf` file. This is enabled by adding categories to the `node['percona']['conf']` attributes. All keys found in the `node['percona']['conf']` map will represent categories in the `my.cnf` file. Each category contains a map of attributes that will be written to the `my.cnf` file for that category. See the example for more details. ### Example ```ruby -node["percona"]["conf"]["mysqld"]["slow_query_log_file"] = "/var/lib/mysql/data/mysql-slow.log" +node['percona']['conf']['mysqld']['slow_query_log_file'] = "/var/lib/mysql/data/mysql-slow.log" ``` This configuration would write the `mysqld` category to the `my.cnf` file and have an attribute `slow_query_log_file` whose value would be `/var/lib/mysql/data/mysql-slow.log`. @@ -489,7 +229,7 @@ slow_query_log_file = /var/lib/mysql/data/mysql-slow.log ## Dynamically setting the bind address -There's a special attribute `node["percona"]["server"]["bind_to"]` that allows you to dynamically set the bind address. This attribute accepts the values `"public_ip"`, `"private_ip"`, `"loopback"`, or and interface name like `"eth0"`. Based on this, the recipe will find a corresponding ipv4 address, and override the `node["percona"]["server"]["bind_address"]` attribute. +There's a special attribute `node['percona']['server']['bind_to']` that allows you to dynamically set the bind address. This attribute accepts the values `"public_ip"`, `"private_ip"`, `"loopback"`, or and interface name like `"eth0"`. Based on this, the recipe will find a corresponding ipv4 address, and override the `node['percona']['server']['bind_address']` attribute. ## MySQL Gems From b2ccf96db48e3cc187dde3151ee0d46976bd0aa8 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 10 Aug 2020 16:48:47 -0700 Subject: [PATCH 157/300] Cleanup some InSpec tests Signed-off-by: Lance Albertson --- test/integration/inspec/controls/server_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/integration/inspec/controls/server_spec.rb b/test/integration/inspec/controls/server_spec.rb index 79f0444a..d27c38eb 100644 --- a/test/integration/inspec/controls/server_spec.rb +++ b/test/integration/inspec/controls/server_spec.rb @@ -169,9 +169,9 @@ it { should be_running } end - describe command 'pgrep mysql' do - its(:stdout) { should match(/\d+/) } - its(:exit_status) { should eq 0 } + describe processes('mysqld') do + it { should exist } + its('users') { should include 'mysql' } end describe port 3306 do @@ -249,8 +249,8 @@ end describe command "mysqladmin --user='root' --password='7tCk(V5I' variables" do - its(:stdout) { should match %r{datadir\s+| /tmp/mysql/} } - its(:stdout) { should match %r{general_log_file\s+| /tmp/mysql/} } - its(:exit_status) { should eq 0 } + its('stdout') { should match %r{datadir\s+| /tmp/mysql/} } + its('stdout') { should match %r{general_log_file\s+| /tmp/mysql/} } + its('exit_status') { should eq 0 } end end From 58a10a35c5873d9f4e5783549fd5cedd0ecfb004 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 10 Aug 2020 16:57:21 -0700 Subject: [PATCH 158/300] Remove extra debug output Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b774cfd..e0ac42b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,10 +118,6 @@ jobs: sudo docker version sudo docker info KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "journalctl -l" - KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "cat /var/log/mysql/error.log" - KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "mount" - KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "cat /etc/mtab" - KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "ls -l /var/lib/mysql/ /tmp/mysql/" final: needs: [dokken] From b5f1a6ec5a36976b222c2d99314d1921708559f6 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Mon, 10 Aug 2020 17:04:16 -0700 Subject: [PATCH 159/300] Re-enable enforce_idempotency Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 - kitchen.yml | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ac333b5..6aa041a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,6 @@ This file is used to list changes made in each version of the percona cookbook. ### Changed -- Disable enforce_idempotency until we can properly fix it - Convert to InSpec tests and refactor test cookbook recipes - Don't install abi_version packages on Debian/Ubuntu - Standardise files with files in sous-chefs/repo-management diff --git a/kitchen.yml b/kitchen.yml index 63f59a3f..2b19f1a4 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -5,11 +5,8 @@ driver: provisioner: name: chef_solo product_name: chef - # TODO: - # - template[/etc/mysql/grants.sql] - # - execute[mysql-install-privileges] - # enforce_idempotency: true - # multiple_converge: 2 + enforce_idempotency: true + multiple_converge: 2 deprecations_as_errors: true data_bags_path: test/integration/data_bags From 5d9ba781806810cb85fe27868e3e37365226fc98 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Tue, 11 Aug 2020 15:09:46 -0700 Subject: [PATCH 160/300] Fix issue when trying to set node['percona']['version'] in a recipe This works around an annoying issue with attribute precedence. The primary issue is referencing node['percona']['version'] inside of an attribute file. When this happens, wrapper cookbooks no longer have the ability to change what version is installed. By moving this to a helper library this works as expected. Signed-off-by: Lance Albertson --- CHANGELOG.md | 1 + attributes/client.rb | 23 +--- attributes/default.rb | 47 +------- libraries/helpers.rb | 107 ++++++++++++++++++ recipes/backup.rb | 2 +- recipes/client.rb | 8 +- recipes/cluster.rb | 18 +-- recipes/configure_server.rb | 9 +- recipes/server.rb | 18 ++- spec/cluster_spec.rb | 4 +- templates/my.cnf.cluster.erb | 2 +- templates/my.cnf.main.erb | 2 +- .../inspec/controls/server_spec.rb | 2 +- 13 files changed, 134 insertions(+), 109 deletions(-) create mode 100644 libraries/helpers.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 6aa041a9..24ded51b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ This file is used to list changes made in each version of the percona cookbook. - Fixed enabled ChefSpec tests - Use the correct syntax on 8.0 for SSL replication - Use correct cert path for master/slave +- Fix issue when trying to set node['percona']['version'] in a recipe ### Changed diff --git a/attributes/client.rb b/attributes/client.rb index 60017224..d4dceb00 100644 --- a/attributes/client.rb +++ b/attributes/client.rb @@ -5,25 +5,4 @@ # install vs. upgrade packages default['percona']['client']['package_action'] = 'install' - -version = value_for_platform_family( - 'debian' => node['percona']['version'], - 'rhel' => node['percona']['version'].tr('.', '') -) - -case node['platform_family'] -when 'debian' - default['percona']['client']['packages'] = - if node['percona']['version'].to_f >= 8.0 - %w(percona-server-client) - else - %W(percona-server-client-#{version}) - end -when 'rhel' - default['percona']['client']['packages'] = - if node['percona']['version'].to_f >= 8.0 - %w(percona-server-client) - else - %W(Percona-Server-client-#{version}) - end -end +default['percona']['client']['packages'] = [] diff --git a/attributes/default.rb b/attributes/default.rb index 992415ff..f808e14d 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -55,14 +55,7 @@ # Basic Settings default['percona']['server']['role'] = ['standalone'] -default['percona']['server']['package'] = - if node['percona']['version'].to_f >= 8.0 - 'percona-server-server' - elsif platform_family?('debian') - "percona-server-server-#{node['percona']['version']}" - else - "Percona-Server-server-#{node['percona']['version'].tr('.', '')}" - end +default['percona']['server']['package'] = [] default['percona']['server']['username'] = 'mysql' default['percona']['server']['datadir'] = '/var/lib/mysql' default['percona']['server']['logdir'] = '/var/log/mysql' @@ -70,24 +63,6 @@ default['percona']['server']['slave_load_tmpdir'] = '/tmp' default['percona']['server']['debian_username'] = 'debian-sys-maint' default['percona']['server']['jemalloc'] = false -default['percona']['server']['jemalloc_package'] = - case node['platform'] - when 'debian' - node['platform_version'].to_i >= 10 ? 'libjemalloc2' : 'libjemalloc1' - when 'ubuntu' - node['platform_version'].to_f >= 20.04 ? 'libjemalloc2' : 'libjemalloc1' - when 'centos', 'redhat' - 'jemalloc' - end -default['percona']['server']['jemalloc_lib'] = - case node['platform'] - when 'debian' - node['platform_version'].to_i >= 10 ? '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' : '/usr/lib/x86_64-linux-gnu/libjemalloc.so.1' - when 'ubuntu' - node['platform_version'].to_f >= 20.04 ? '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' : '/usr/lib/x86_64-linux-gnu/libjemalloc.so.1' - when 'centos', 'redhat' - node['platform_version'].to_i >= 8 ? '/usr/lib64/libjemalloc.so.2' : '/usr/lib64/libjemalloc.so.1' - end default['percona']['server']['nice'] = 0 default['percona']['server']['open_files_limit'] = 16_384 default['percona']['server']['hostname'] = 'localhost' @@ -225,31 +200,11 @@ # XtraBackup Settings default['percona']['backup']['configure'] = false default['percona']['backup']['username'] = 'backup' -default['percona']['backup']['package_name'] = - case node['platform_family'] - when 'debian' - case node['platform'] - when 'debian' - node['platform_version'].to_i >= 10 ? 'percona-xtrabackup-80' : 'xtrabackup' - when 'ubuntu' - node['platform_version'].to_f >= 20.04 ? 'percona-xtrabackup-80' : 'xtrabackup' - end - when 'rhel' - node['platform_version'].to_i >= 8 ? 'percona-xtrabackup-80' : 'percona-xtrabackup' - end unless attribute?(node['percona']['backup']['password']) default['percona']['backup']['password'] = random_password end # XtraDB Cluster Settings -default['percona']['cluster']['package'] = - if node['percona']['version'].to_f >= 8.0 - 'percona-xtradb-cluster-server' - elsif platform_family?('rhel') - "Percona-XtraDB-Cluster-#{node['percona']['version'].tr('.', '')}" - else - "percona-xtradb-cluster-#{node['percona']['version'].tr('.', '')}" - end default['percona']['cluster']['binlog_format'] = 'ROW' default['percona']['cluster']['wsrep_provider'] = value_for_platform_family( 'debian' => '/usr/lib/libgalera_smm.so', diff --git a/libraries/helpers.rb b/libraries/helpers.rb new file mode 100644 index 00000000..c707fcc4 --- /dev/null +++ b/libraries/helpers.rb @@ -0,0 +1,107 @@ +module Percona + module Cookbook + module Helpers + def percona_version + case node['platform_family'] + when 'debian' + node['percona']['version'] + when 'rhel' + node['percona']['version'].tr('.', '') + end + end + + def percona_client_packages + case node['platform_family'] + when 'debian' + if node['percona']['version'].to_f >= 8.0 + %w(percona-server-client) + else + %W(percona-server-client-#{percona_version}) + end + when 'rhel' + if node['percona']['version'].to_f >= 8.0 + %w(percona-server-client) + else + %W(Percona-Server-client-#{percona_version}) + end + end + end + + def percona_server_package + if node['percona']['version'].to_f >= 8.0 + 'percona-server-server' + elsif platform_family?('debian') + "percona-server-server-#{percona_version}" + else + "Percona-Server-server-#{percona_version}" + end + end + + def percona_cluster_client_package + case node['platform_family'] + when 'debian' + if node['percona']['version'].to_f >= 8.0 + %w(percona-xtradb-cluster-client) + else + %W(percona-xtradb-cluster-client-#{percona_version}) + end + when 'rhel' + if node['percona']['version'].to_f >= 8.0 + %w(percona-xtradb-cluster-client) + else + %W(Percona-XtraDB-Cluster-client-#{percona_version}) + end + end + end + + def percona_cluster_package + if node['percona']['version'].to_f >= 8.0 + 'percona-xtradb-cluster-server' + elsif platform_family?('rhel') + "Percona-XtraDB-Cluster-#{percona_version}" + else + "percona-xtradb-cluster-#{percona_version}" + end + end + + def percona_backup_package + case node['platform_family'] + when 'debian' + case node['platform'] + when 'debian' + node['platform_version'].to_i >= 10 ? 'percona-xtrabackup-80' : 'xtrabackup' + when 'ubuntu' + node['platform_version'].to_f >= 20.04 ? 'percona-xtrabackup-80' : 'xtrabackup' + end + when 'rhel' + node['platform_version'].to_i >= 8 ? 'percona-xtrabackup-80' : 'percona-xtrabackup' + end + end + + def percona_jemalloc_package + case node['platform'] + when 'debian' + node['platform_version'].to_i >= 10 ? 'libjemalloc2' : 'libjemalloc1' + when 'ubuntu' + node['platform_version'].to_f >= 20.04 ? 'libjemalloc2' : 'libjemalloc1' + when 'centos', 'redhat' + 'jemalloc' + end + end + + def percona_jemalloc_lib + case node['platform'] + when 'debian' + node['platform_version'].to_i >= 10 ? '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' : '/usr/lib/x86_64-linux-gnu/libjemalloc.so.1' + when 'ubuntu' + node['platform_version'].to_f >= 20.04 ? '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' : '/usr/lib/x86_64-linux-gnu/libjemalloc.so.1' + when 'centos', 'redhat' + node['platform_version'].to_i >= 8 ? '/usr/lib64/libjemalloc.so.2' : '/usr/lib64/libjemalloc.so.1' + end + end + end + end +end + +Chef::Recipe.include ::Percona::Cookbook::Helpers +Chef::Resource.include ::Percona::Cookbook::Helpers diff --git a/recipes/backup.rb b/recipes/backup.rb index 991f8cc6..b0204a4a 100644 --- a/recipes/backup.rb +++ b/recipes/backup.rb @@ -8,7 +8,7 @@ include_recipe 'percona::package_repo' package 'xtrabackup' do - package_name node['percona']['backup']['package_name'] + package_name percona_backup_package end # access grants diff --git a/recipes/client.rb b/recipes/client.rb index 34f3cae6..d18df527 100644 --- a/recipes/client.rb +++ b/recipes/client.rb @@ -5,8 +5,8 @@ include_recipe 'percona::package_repo' -node['percona']['client']['packages'].each do |percona_client_pkg| - package percona_client_pkg do - action node['percona']['client']['package_action'].to_sym - end +pkgs = node['percona']['client']['packages'].empty? ? percona_client_packages : node['percona']['client']['packages'] + +package pkgs do + action node['percona']['client']['package_action'].to_sym end diff --git a/recipes/cluster.rb b/recipes/cluster.rb index 1cd309d4..bb5162a2 100644 --- a/recipes/cluster.rb +++ b/recipes/cluster.rb @@ -4,21 +4,7 @@ # node.default['percona']['repositories'] = %w(pxc-80) -node.default['percona']['client']['packages'] = - case node['platform_family'] - when 'debian' - if node['percona']['version'].to_f >= 8.0 - %w(percona-xtradb-cluster-client) - else - %W(percona-xtradb-cluster-client-#{node['percona']['version']}) - end - when 'rhel' - if node['percona']['version'].to_f >= 8.0 - %w(percona-xtradb-cluster-client) - else - %W(Percona-XtraDB-Cluster-client-#{node['percona']['version'].tr('.', '')}) - end - end +node.default['percona']['client']['packages'] = percona_cluster_client_package include_recipe 'percona::package_repo' include_recipe 'percona::client' @@ -37,7 +23,7 @@ include_recipe 'yum-epel' if platform_family?('rhel') # install packages -package node['percona']['cluster']['package'] +package percona_cluster_package unless node['percona']['skip_configure'] include_recipe 'percona::configure_server' diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index b9f1e157..c0090857 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -35,7 +35,7 @@ passwords = EncryptedPasswords.new(node, percona['encrypted_data_bag']) if node['percona']['server']['jemalloc'] - package node['percona']['server']['jemalloc_package'] + package percona_jemalloc_package end template '/root/.my.cnf' do @@ -159,9 +159,10 @@ mode '0644' sensitive true manage_symlink_source true - if Array(server['role']).include?('cluster') - variables(wsrep_sst_auth: wsrep_sst_auth) - end + variables( + jemalloc_lib: percona_jemalloc_lib, + wsrep_sst_auth: wsrep_sst_auth + ) notifies :run, 'execute[setup mysql datadir]', :immediately if node['percona']['auto_restart'] notifies :restart, 'service[mysql]', :immediately diff --git a/recipes/server.rb b/recipes/server.rb index 9af83cd9..b97d0a75 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -6,18 +6,14 @@ include_recipe 'percona::package_repo' include_recipe 'percona::client' -# install packages -case node['platform_family'] -when 'debian' - package node['percona']['server']['package'] do - options '--force-yes' - action node['percona']['server']['package_action'].to_sym - end -when 'rhel' - package node['percona']['server']['package'] do - action node['percona']['server']['package_action'].to_sym - end +pkg = node['percona']['server']['package'].empty? ? percona_server_package : node['percona']['server']['package'] +package pkg do + action node['percona']['server']['package_action'].to_sym +end + +# install packages +if platform_family?('rhel') # Work around issue with 5.7 on RHEL if node['percona']['version'].to_f >= 5.7 execute 'systemctl daemon-reload' do diff --git a/spec/cluster_spec.rb b/spec/cluster_spec.rb index 8669085f..40387ca2 100644 --- a/spec/cluster_spec.rb +++ b/spec/cluster_spec.rb @@ -29,7 +29,7 @@ describe 'Ubuntu' do it do - expect(chef_run).to install_package 'percona-xtradb-cluster-56' + expect(chef_run).to install_package 'percona-xtradb-cluster-5.6' end it do @@ -58,7 +58,7 @@ describe 'Ubuntu' do it do - expect(chef_run).to install_package 'percona-xtradb-cluster-57' + expect(chef_run).to install_package 'percona-xtradb-cluster-5.7' end it do diff --git a/templates/my.cnf.cluster.erb b/templates/my.cnf.cluster.erb index 713341c8..cd9d002d 100644 --- a/templates/my.cnf.cluster.erb +++ b/templates/my.cnf.cluster.erb @@ -30,7 +30,7 @@ socket = <%= node["percona"]["server"]["socket"] %> nice = <%= node["percona"]["server"]["nice"] %> open-files-limit = <%= node["percona"]["server"]["open_files_limit"] %> <% if node["percona"]["server"]["jemalloc"] %> -malloc-lib = <%= node["percona"]["server"]["jemalloc_lib"] %> +malloc-lib = <%= @jemalloc_lib %> <% end %> <% if node["percona"]["server"]["skip_syslog"] %> skip-syslog diff --git a/templates/my.cnf.main.erb b/templates/my.cnf.main.erb index edf13ca3..6f81ae8e 100644 --- a/templates/my.cnf.main.erb +++ b/templates/my.cnf.main.erb @@ -33,7 +33,7 @@ socket = <%= node["percona"]["server"]["socket"] %> nice = <%= node["percona"]["server"]["nice"] %> open-files-limit = <%= node["percona"]["server"]["open_files_limit"] %> <% if node["percona"]["server"]["jemalloc"] %> -malloc-lib = <%= node["percona"]["server"]["jemalloc_lib"] %> +malloc-lib = <%= @jemalloc_lib %> <% end %> <% if node["percona"]["server"]["skip_syslog"] %> skip-syslog diff --git a/test/integration/inspec/controls/server_spec.rb b/test/integration/inspec/controls/server_spec.rb index d27c38eb..ddd71ebd 100644 --- a/test/integration/inspec/controls/server_spec.rb +++ b/test/integration/inspec/controls/server_spec.rb @@ -25,7 +25,7 @@ its('version') { should >= '1:8.0' } end else - describe package "percona-xtradb-cluster-#{version.tr('.', '')}" do + describe package "percona-xtradb-cluster-server-#{version}" do it { should be_installed } end end From f743f7141c71af0172cb7bcc934df15d0961801f Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 13 Aug 2020 11:33:31 -0700 Subject: [PATCH 161/300] Improve readability Signed-off-by: Lance Albertson --- attributes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index f808e14d..8a53f1d9 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -136,7 +136,7 @@ default['percona']['server']['log_bin_basename'] = 'master-bin' # 5.6~> default: datadir + '/' + hostname + '-bin' default['percona']['server']['relay_log'] = 'slave-relay-bin' default['percona']['server']['log_slave_updates'] = false -default['percona']['server']['log_warnings'] = !(node['percona']['version'].to_f >= 8.0) +default['percona']['server']['log_warnings'] = node['percona']['version'].to_f < 8.0 default['percona']['server']['log_long_format'] = false default['percona']['server']['bulk_insert_buffer_size'] = '64M' default['percona']['server']['sync_master_info'] = false From d1bbb631b957854059c04e713f8a70e7f886208f Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 13 Aug 2020 11:34:20 -0700 Subject: [PATCH 162/300] Switch to ::File.exist instead of using a shell out using test Signed-off-by: Lance Albertson --- recipes/configure_server.rb | 3 +-- spec/configure_server_spec.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index c0090857..c304aa0f 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -128,8 +128,7 @@ else command "mysql_install_db --defaults-file=#{percona['main_config_file']} --user=#{user}" end - not_if "test -f #{datadir}/mysql/user.frm" - not_if "test -f #{datadir}/mysql.ibd" + not_if { ::File.exist?("#{datadir}/mysql/user.frm") || ::File.exist?("#{datadir}/mysql.ibd") } action :nothing end diff --git a/spec/configure_server_spec.rb b/spec/configure_server_spec.rb index a160ed24..3bb81521 100644 --- a/spec/configure_server_spec.rb +++ b/spec/configure_server_spec.rb @@ -4,8 +4,9 @@ platform 'ubuntu' describe 'first run' do before do - stub_command('test -f /var/lib/mysql/mysql/user.frm').and_return(false) - stub_command('test -f /var/lib/mysql.ibd').and_return(false) + allow(File).to receive(:exist?).and_call_original + allow(File).to receive(:exist?).with('var/lib/mysql/mysql/user.frm').and_return(false) + allow(File).to receive(:exist?).with('/var/lib/mysql.ibd').and_return(false) stub_command("mysqladmin --user=root --password='' version").and_return(true) end @@ -117,8 +118,9 @@ override_attributes['percona']['conf']['mysqld']['includedir'] = '/mysql/conf.d' before do - stub_command('test -f /mysql/data/mysql/user.frm').and_return(true) - stub_command('test -f /mysql/data/mysql.ibd').and_return(true) + allow(File).to receive(:exist?).and_call_original + allow(File).to receive(:exist?).with('var/lib/mysql/mysql/user.frm').and_return(true) + allow(File).to receive(:exist?).with('/var/lib/mysql.ibd').and_return(true) stub_command("mysqladmin --user=root --password='' version").and_return(false) end From ceece691aab3544944da8e7d2db49d8778b6513d Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 13 Aug 2020 11:39:06 -0700 Subject: [PATCH 163/300] Switch to using to_i instead of to_f where it makes sense This hopefully keeps us from having issues down the road if a release went from x.9 to x.10. Signed-off-by: Lance Albertson --- attributes/default.rb | 2 +- libraries/helpers.rb | 12 ++++++------ recipes/package_repo.rb | 4 ++-- recipes/toolkit.rb | 3 +-- templates/grants.sql.erb | 4 ++-- templates/my.cnf.cluster.erb | 4 ++-- templates/my.cnf.main.erb | 4 ++-- templates/replication.sql.erb | 2 +- test/integration/inspec/controls/client_spec.rb | 14 +++++++------- test/integration/inspec/controls/server_spec.rb | 10 +++++----- test/integration/inspec/controls/toolkit_spec.rb | 2 +- 11 files changed, 30 insertions(+), 31 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 8a53f1d9..eb9a5fc6 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -136,7 +136,7 @@ default['percona']['server']['log_bin_basename'] = 'master-bin' # 5.6~> default: datadir + '/' + hostname + '-bin' default['percona']['server']['relay_log'] = 'slave-relay-bin' default['percona']['server']['log_slave_updates'] = false -default['percona']['server']['log_warnings'] = node['percona']['version'].to_f < 8.0 +default['percona']['server']['log_warnings'] = node['percona']['version'].to_i < 8 default['percona']['server']['log_long_format'] = false default['percona']['server']['bulk_insert_buffer_size'] = '64M' default['percona']['server']['sync_master_info'] = false diff --git a/libraries/helpers.rb b/libraries/helpers.rb index c707fcc4..9c487547 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -13,13 +13,13 @@ def percona_version def percona_client_packages case node['platform_family'] when 'debian' - if node['percona']['version'].to_f >= 8.0 + if node['percona']['version'].to_i >= 8 %w(percona-server-client) else %W(percona-server-client-#{percona_version}) end when 'rhel' - if node['percona']['version'].to_f >= 8.0 + if node['percona']['version'].to_i >= 8 %w(percona-server-client) else %W(Percona-Server-client-#{percona_version}) @@ -28,7 +28,7 @@ def percona_client_packages end def percona_server_package - if node['percona']['version'].to_f >= 8.0 + if node['percona']['version'].to_i >= 8 'percona-server-server' elsif platform_family?('debian') "percona-server-server-#{percona_version}" @@ -40,13 +40,13 @@ def percona_server_package def percona_cluster_client_package case node['platform_family'] when 'debian' - if node['percona']['version'].to_f >= 8.0 + if node['percona']['version'].to_i >= 8 %w(percona-xtradb-cluster-client) else %W(percona-xtradb-cluster-client-#{percona_version}) end when 'rhel' - if node['percona']['version'].to_f >= 8.0 + if node['percona']['version'].to_i >= 8 %w(percona-xtradb-cluster-client) else %W(Percona-XtraDB-Cluster-client-#{percona_version}) @@ -55,7 +55,7 @@ def percona_cluster_client_package end def percona_cluster_package - if node['percona']['version'].to_f >= 8.0 + if node['percona']['version'].to_i >= 8 'percona-xtradb-cluster-server' elsif platform_family?('rhel') "Percona-XtraDB-Cluster-#{percona_version}" diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index b384df75..0cabfe48 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -21,7 +21,7 @@ key node['percona']['apt']['key'] end - if node['percona']['version'].to_f >= 8.0 + if node['percona']['version'].to_i >= 8 node['percona']['repositories'].each do |repo| apt_repository "percona-#{repo}" do uri "http://repo.percona.com/#{repo}/apt" @@ -41,7 +41,7 @@ sslverify node['percona']['yum']['sslverify'] end - if node['percona']['version'].to_f >= 8.0 + if node['percona']['version'].to_i >= 8 node['percona']['repositories'].each do |repo| yum_repository "percona-#{repo}" do description node['percona']['yum']['description'] + ' - ' + repo diff --git a/recipes/toolkit.rb b/recipes/toolkit.rb index 328b69d3..01ae45c9 100644 --- a/recipes/toolkit.rb +++ b/recipes/toolkit.rb @@ -5,7 +5,6 @@ include_recipe 'percona::package_repo' -unless node['percona']['version'].to_f >= 8.0 && platform_family?('rhel') && - node['platform_version'].to_i >= 8 +unless node['percona']['version'].to_i >= 8 && platform_family?('rhel') && node['platform_version'].to_i >= 8 package 'percona-toolkit' end diff --git a/templates/grants.sql.erb b/templates/grants.sql.erb index 5b896223..5002bf80 100644 --- a/templates/grants.sql.erb +++ b/templates/grants.sql.erb @@ -12,7 +12,7 @@ SET PASSWORD FOR '<%= @debian_user %>'@'localhost' = PASSWORD('<%= @debian_passw <% if node["percona"]["backup"]["configure"] %> # Grant permissions for the XtraBackup user # Ensure the user exists, then revoke all grants, then re-grant specific permissions -<% if node["percona"]["version"].to_f >= 8.0 %> +<% if node["percona"]["version"].to_i >= 8 %> CREATE USER IF NOT EXISTS '<%= node["percona"]["backup"]["username"] %>'@'localhost' IDENTIFIED BY '<%= @backup_password %>'; GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '<%= node["percona"]["backup"]["username"] %>'@'localhost'; REVOKE ALL PRIVILEGES, GRANT OPTION FROM '<%= node["percona"]["backup"]["username"] %>'@'localhost'; @@ -25,7 +25,7 @@ GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '<%= node["percona"]["ba <% end -%> # Set the server root password. This should be preseeded by the package installation. -<% if node["percona"]["version"].to_f >= 8.0 %> +<% if node["percona"]["version"].to_i >= 8 %> ALTER USER 'root'@'localhost' IDENTIFIED BY '<%= @root_password %>'; <% else -%> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<%= @root_password %>'); diff --git a/templates/my.cnf.cluster.erb b/templates/my.cnf.cluster.erb index cd9d002d..3fd5bd9d 100644 --- a/templates/my.cnf.cluster.erb +++ b/templates/my.cnf.cluster.erb @@ -246,7 +246,7 @@ table_definition_cache = <%= node["percona"]["server"]["table_definition_cache" table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> #thread_concurrency = 10 -<%- if node["percona"]["version"].to_f < 8.0 %> +<%- if node["percona"]["version"].to_i < 8 %> # # # * Query Cache Configuration @@ -511,7 +511,7 @@ innodb_autoextend_increment = <%= node["percona"]["server"]["innodb_autoextend_i <% if node["percona"]["server"]["innodb_file_per_table"] %> innodb_file_per_table <% end %> -<%- if node["percona"]["version"].to_f < 8.0 %> +<%- if node["percona"]["version"].to_i < 8 %> # The file format to use for new InnoDB tables. # Currently Antelope and Barracuda are supported. diff --git a/templates/my.cnf.main.erb b/templates/my.cnf.main.erb index 6f81ae8e..50a626ed 100644 --- a/templates/my.cnf.main.erb +++ b/templates/my.cnf.main.erb @@ -232,7 +232,7 @@ table_definition_cache = <%= node["percona"]["server"]["table_definition_cache" table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> #thread_concurrency = 10 -<%- if node["percona"]["version"].to_f < 8.0 %> +<%- if node["percona"]["version"].to_i < 8 %> # # # * Query Cache Configuration @@ -530,7 +530,7 @@ innodb_autoextend_increment = <%= node["percona"]["server"]["innodb_autoextend_i <% if node["percona"]["server"]["innodb_file_per_table"] %> innodb_file_per_table <% end %> -<%- if node["percona"]["version"].to_f < 8.0 %> +<%- if node["percona"]["version"].to_i < 8 %> # The file format to use for new InnoDB tables. # Currently Antelope and Barracuda are supported. diff --git a/templates/replication.sql.erb b/templates/replication.sql.erb index 44893d4d..b1aa1477 100644 --- a/templates/replication.sql.erb +++ b/templates/replication.sql.erb @@ -1,6 +1,6 @@ -- Generated by Chef for <%= node["hostname"] %>. -- Local modifications will be overwritten. -<% if node["percona"]["version"].to_f >= 8.0 %> +<% if node["percona"]["version"].to_i >= 8 %> CREATE USER IF NOT EXISTS '<%=node["percona"]["server"]["replication"]["username"]%>'@'%' IDENTIFIED BY '<%= @replication_password %>'; GRANT REPLICATION SLAVE ON *.* TO '<%=node["percona"]["server"]["replication"]["username"]%>'@'%'; <% if node["percona"]["server"]["replication"]["ssl_enabled"] -%> diff --git a/test/integration/inspec/controls/client_spec.rb b/test/integration/inspec/controls/client_spec.rb index 6c5cec8c..2f8c8e81 100644 --- a/test/integration/inspec/controls/client_spec.rb +++ b/test/integration/inspec/controls/client_spec.rb @@ -11,12 +11,12 @@ it { should be_enabled } end - if type == 'cluster' && version.to_f >= 8.0 + if type == 'cluster' && version.to_i >= 8 describe apt 'http://repo.percona.com/pxc-80/apt' do it { should exist } it { should be_enabled } end - elsif version.to_f >= 8.0 + elsif version.to_i >= 8 describe apt 'http://repo.percona.com/ps-80/apt' do it { should exist } it { should be_enabled } @@ -33,7 +33,7 @@ its('content') { should match 'release o=Percona Development Team' } end - if type == 'cluster' && version.to_f >= 8.0 + if type == 'cluster' && version.to_i >= 8 describe package 'percona-xtradb-cluster-client' do it { should be_installed } its('version') { should >= '1:8' } @@ -42,7 +42,7 @@ describe package "percona-xtradb-cluster-client-#{version}" do it { should be_installed } end - elsif version.to_f >= 8.0 + elsif version.to_i >= 8 describe package 'percona-server-client' do it { should be_installed } its('version') { should >= '8' } @@ -64,7 +64,7 @@ it { should be_enabled } end - if type == 'cluster' && version.to_f >= 8.0 + if type == 'cluster' && version.to_i >= 8 describe package 'percona-xtradb-cluster-client' do it { should be_installed } its('version') { should >= '8' } @@ -73,7 +73,7 @@ describe package "Percona-XtraDB-Cluster-client-#{version.tr('.', '')}" do it { should be_installed } end - elsif version.to_f >= 8.0 + elsif version.to_i >= 8 describe package 'percona-server-client' do it { should be_installed } its('version') { should >= '8' } @@ -87,7 +87,7 @@ describe command 'mysql --version' do its('exit_status') { should eq 0 } - if version.to_f >= 8.0 + if version.to_i >= 8 its('stdout') { should match /Ver #{version.tr('.', '\.')}.+/ } else its('stdout') { should match /Distrib #{version.tr('.', '\.')}.+/ } diff --git a/test/integration/inspec/controls/server_spec.rb b/test/integration/inspec/controls/server_spec.rb index ddd71ebd..c7d56bbf 100644 --- a/test/integration/inspec/controls/server_spec.rb +++ b/test/integration/inspec/controls/server_spec.rb @@ -8,7 +8,7 @@ if os.family == 'debian' case type when 'server' - if version.to_f >= 8.0 + if version.to_i >= 8 describe package 'percona-server-server' do it { should be_installed } its('version') { should >= '8.0' } @@ -19,7 +19,7 @@ end end when 'cluster' - if version.to_f >= 8.0 + if version.to_i >= 8 describe package 'percona-xtradb-cluster-server' do it { should be_installed } its('version') { should >= '1:8.0' } @@ -45,7 +45,7 @@ end describe package xtrabackup_pkg do - if version.to_f >= 8.0 && type == 'cluster' + if version.to_i >= 8 && type == 'cluster' it { should_not be_installed } else it { should be_installed } @@ -204,7 +204,7 @@ its('owner') { should cmp 'root' } its('group') { should cmp 'root' } its('mode') { should cmp '0600' } - if version.to_f >= 8.0 + if version.to_i >= 8 its('content') { should match %r{CREATE USER IF NOT EXISTS 'replication'@'%' IDENTIFIED BY '\)6\$W2M\{\/';} } its('content') { should match /GRANT REPLICATION SLAVE ON \*\.\* TO 'replication'@'%';/ } its('content') { should match /ALTER USER 'replication'@'%' REQUIRE SSL;/ } @@ -231,7 +231,7 @@ its('group') { should cmp 'mysql' } end - mysql_file = version.to_f >= 8.0 ? '/tmp/mysql/mysql.ibd' : '/tmp/mysql/mysql/user.frm' + mysql_file = version.to_i >= 8 ? '/tmp/mysql/mysql.ibd' : '/tmp/mysql/mysql/user.frm' mysql_mode = version.to_f < 5.7 ? '0660' : '0640' describe file '/tmp/mysql/ibdata1' do diff --git a/test/integration/inspec/controls/toolkit_spec.rb b/test/integration/inspec/controls/toolkit_spec.rb index 7fdf7f89..9d0ca652 100644 --- a/test/integration/inspec/controls/toolkit_spec.rb +++ b/test/integration/inspec/controls/toolkit_spec.rb @@ -4,7 +4,7 @@ desc 'Ensure Percona toolkit are installed.' impact 1.0 - if version.to_f >= 8.0 && os.family == 'redhat' && os.release.to_i >= 8 + if version.to_i >= 8 && os.family == 'redhat' && os.release.to_i >= 8 describe package 'percona-toolkit' do it { should_not be_installed } end From 90fa61fe7281c09d18dbfc4790f30e587b83203b Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 13 Aug 2020 11:40:59 -0700 Subject: [PATCH 164/300] Add spacing to improve readability Signed-off-by: Lance Albertson --- kitchen.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kitchen.yml b/kitchen.yml index 2b19f1a4..8aa32d50 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -41,6 +41,7 @@ suites: - centos-8 - debian-10 - ubuntu-20.04 + - name: client-57 run_list: - recipe[test::client] @@ -53,6 +54,7 @@ suites: - toolkit inputs: version: '5.7' + - name: client-80 run_list: - recipe[test::client] @@ -65,6 +67,7 @@ suites: - toolkit inputs: version: '8.0' + - name: server-56 run_list: - recipe[test::server] @@ -81,6 +84,7 @@ suites: - server inputs: version: '5.6' + - name: server-57 run_list: - recipe[test::server] @@ -93,6 +97,7 @@ suites: - server inputs: version: '5.7' + - name: server-80 run_list: - recipe[test::server] @@ -105,6 +110,7 @@ suites: - server inputs: version: '8.0' + - name: source-56 run_list: - recipe[test::source] @@ -122,6 +128,7 @@ suites: inputs: version: '5.6' type: 'source' + - name: source-57 run_list: - recipe[test::source] @@ -135,6 +142,7 @@ suites: inputs: version: '5.7' type: 'source' + - name: source-80 run_list: - recipe[test::source] @@ -148,6 +156,7 @@ suites: inputs: version: '8.0' type: 'source' + - name: cluster-56 run_list: - recipe[test::cluster] @@ -165,6 +174,7 @@ suites: inputs: version: '5.6' type: 'cluster' + - name: cluster-57 run_list: - recipe[test::cluster] @@ -178,6 +188,7 @@ suites: inputs: version: '5.7' type: 'cluster' + - name: cluster-80 run_list: - recipe[test::cluster] @@ -191,6 +202,7 @@ suites: inputs: version: '8.0' type: 'cluster' + - name: replication-56 run_list: - recipe[test::replication] @@ -208,6 +220,7 @@ suites: inputs: version: '5.6' type: 'replication' + - name: replication-57 run_list: - recipe[test::replication] @@ -221,6 +234,7 @@ suites: inputs: version: '5.7' type: 'replication' + - name: replication-80 run_list: - recipe[test::replication] From 14ccce1c55ae8b9b99d448c6733721781b0647c1 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Fri, 14 Aug 2020 12:21:55 -0700 Subject: [PATCH 165/300] Release 1.0.0 Signed-off-by: Lance Albertson --- CHANGELOG.md | 2 +- metadata.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24ded51b..f17c7359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 1.0.0 - 2020-08-14 ### Added diff --git a/metadata.rb b/metadata.rb index af956b65..1333a417 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '0.17.2' +version '1.0.0' chef_version '>= 13.0' depends 'openssl' From 7296f7efa5ffcc0eff6acd5e9024a424b9de669d Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Wed, 19 Aug 2020 13:23:27 -0700 Subject: [PATCH 166/300] Add devel package attribute to client recipe Signed-off-by: Ethan Hampton --- .github/workflows/ci.yml | 9 ++++ README.md | 8 ++- attributes/client.rb | 1 + kitchen.yml | 52 +++++++++++++++++++ libraries/helpers.rb | 19 +++++++ recipes/client.rb | 1 + spec/client_spec.rb | 28 ++++++++++ .../inspec/controls/client_spec.rb | 49 +++++++++++++++++ 8 files changed, 165 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0ac42b2..3c39fea8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,9 @@ jobs: - 'client-56' - 'client-57' - 'client-80' + - 'devel-56' + - 'devel-57' + - 'devel-80' - 'server-56' - 'server-57' - 'server-80' @@ -66,6 +69,8 @@ jobs: exclude: - os: centos-8 suite: client-56 + - os: centos-8 + suite: devel-56 - os: centos-8 suite: server-56 - os: centos-8 @@ -74,6 +79,8 @@ jobs: suite: replication-56 - os: debian-10 suite: client-56 + - os: debian-10 + suite: devel-56 - os: debian-10 suite: server-56 - os: debian-10 @@ -82,6 +89,8 @@ jobs: suite: replication-56 - os: ubuntu-2004 suite: client-56 + - os: ubuntu-2004 + suite: devel-56 - os: ubuntu-2004 suite: server-56 - os: ubuntu-2004 diff --git a/README.md b/README.md index 833ab6ee..94f0030a 100644 --- a/README.md +++ b/README.md @@ -113,10 +113,14 @@ Example: "passwords" data bag - this example assumes that `node['percona']['serv Above shows the encrypted password in the data bag. Check out the `encrypted_data_bag_secret` setting in `knife.rb` to setup your data bag secret during bootstrapping. +### Install client development package + +To install the package including header files needed to compile software using the client library (`percona-server-devel` on Centos and `libperconaserverclient-dev` on Debian), set `node['percona']['client']['install_devel_package']` to `true`. This will add those packages to the list to be installed when running the `percona::client` recipe. This attribute is disabled by default. + ### Replication over SSL -To enable SSL based replication, you will need to flip the attribute `node['percona']['server']['replication']['ssl_enabled']` to `true` and add a new data_bag item -to the percona encrypted data_bag (see`node['percona']['encrypted_data_bag']` attribute) with the id `ssl_replication` ( see `node['percona']['encrypted_data_bag_item_ssl_replication']` attribute) that contains this data: +To enable SSL based replication, you will need to flip the attribute `node['percona']['server']['replication']['ssl_enabled']` to `true` and add a new data\_bag item +to the percona encrypted data\_bag (see`node['percona']['encrypted_data_bag']` attribute) with the id `ssl_replication` ( see `node['percona']['encrypted_data_bag_item_ssl_replication']` attribute) that contains this data: ```javascript { diff --git a/attributes/client.rb b/attributes/client.rb index d4dceb00..0cba4134 100644 --- a/attributes/client.rb +++ b/attributes/client.rb @@ -6,3 +6,4 @@ # install vs. upgrade packages default['percona']['client']['package_action'] = 'install' default['percona']['client']['packages'] = [] +default['percona']['client']['install_devel_package'] = false diff --git a/kitchen.yml b/kitchen.yml index 8aa32d50..2f64ed40 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -68,6 +68,58 @@ suites: inputs: version: '8.0' + - name: devel-56 + run_list: + - recipe[test::client] + attributes: + percona: + version: '5.6' + client: + install_devel_package: true + verifier: + controls: + - client + - toolkit + inputs: + version: '5.6' + devel: true + excludes: + - centos-8 + - debian-10 + - ubuntu-20.04 + + - name: devel-57 + run_list: + - recipe[test::client] + attributes: + percona: + version: '5.7' + client: + install_devel_package: true + verifier: + controls: + - client + - toolkit + inputs: + version: '5.7' + devel: true + + - name: devel-80 + run_list: + - recipe[test::client] + attributes: + percona: + version: '8.0' + client: + install_devel_package: true + verifier: + controls: + - client + - toolkit + inputs: + version: '8.0' + devel: true + - name: server-56 run_list: - recipe[test::server] diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 9c487547..bfb963d1 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -27,6 +27,25 @@ def percona_client_packages end end + def percona_devel_package + case node['platform_family'] + when 'rhel' + if node['percona']['version'].to_i >= 8 + 'percona-server-devel' + else + "Percona-Server-devel-#{percona_version}" + end + when 'debian' + if node['percona']['version'].to_i >= 8 + 'libperconaserverclient21-dev' + elsif node['percona']['version'] == '5.7' + 'libperconaserverclient20-dev' + elsif node['percona']['version'] == '5.6' + 'libperconaserverclient18.1-dev' + end + end + end + def percona_server_package if node['percona']['version'].to_i >= 8 'percona-server-server' diff --git a/recipes/client.rb b/recipes/client.rb index d18df527..5e7b5c1c 100644 --- a/recipes/client.rb +++ b/recipes/client.rb @@ -6,6 +6,7 @@ include_recipe 'percona::package_repo' pkgs = node['percona']['client']['packages'].empty? ? percona_client_packages : node['percona']['client']['packages'] +pkgs << percona_devel_package if node['percona']['client']['install_devel_package'] package pkgs do action node['percona']['client']['package_action'].to_sym diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 730ae866..8d90283b 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -13,6 +13,10 @@ expect(chef_run).to install_package 'percona-server-client' end + it do + expect(chef_run).to_not install_package 'libperconaserverclient21-dev' + end + context 'version 5.7' do override_attributes['percona']['version'] = '5.7' it do @@ -35,6 +39,10 @@ expect(chef_run).to install_package 'percona-server-client' end + it do + expect(chef_run).to_not install_package 'percona-server-devel' + end + context 'version 5.7' do override_attributes['percona']['version'] = '5.7' it do @@ -70,4 +78,24 @@ end end end + + describe 'when `install_devel_package` is `true`' do + context 'Ubuntu' do + platform 'ubuntu' + override_attributes['percona']['client']['install_devel_package'] = true + + it do + expect(chef_run).to install_package %w(percona-server-client libperconaserverclient21-dev) + end + end + + context 'CentOS' do + platform 'centos' + override_attributes['percona']['client']['install_devel_package'] = true + + it do + expect(chef_run).to install_package %w(percona-server-client percona-server-devel) + end + end + end end diff --git a/test/integration/inspec/controls/client_spec.rb b/test/integration/inspec/controls/client_spec.rb index 2f8c8e81..88a755d9 100644 --- a/test/integration/inspec/controls/client_spec.rb +++ b/test/integration/inspec/controls/client_spec.rb @@ -1,5 +1,6 @@ version = input('version') type = input('type') +devel = input('devel') control 'client' do desc 'Ensure Percona clients are installed.' @@ -53,6 +54,34 @@ end end + if devel == true + if version.to_i >= 8 + describe package 'libperconaserverclient21-dev' do + it { should be_installed } + end + elsif version == '5.7' + describe package 'libperconaserverclient20-dev' do + it { should be_installed } + end + elsif version == '5.6' + describe package 'libperconaserverclient18.1-dev' do + it { should be_installed } + end + end + elsif version.to_i >= 8 + describe package 'libperconaserverclient21-dev' do + it { should_not be_installed } + end + elsif version == '5.7' + describe package 'libperconaserverclient20-dev' do + it { should_not be_installed } + end + elsif version == '5.6' + describe package 'libperconaserverclient18.1-dev' do + it { should_not be_installed } + end + end + else describe yum.repo 'percona' do it { should exist } @@ -83,6 +112,26 @@ it { should be_installed } end end + + if devel == true + if version.to_i >= 8 + describe package 'percona-server-devel' do + it { should be_installed } + end + else + describe package "Percona-Server-devel-#{version.tr('.', '')}" do + it { should be_installed } + end + end + else + describe package "Percona-Server-devel-#{version.tr('.', '')}" do + it { should_not be_installed } + end + describe package 'percona-server-devel' do + it { should_not be_installed } + end + end + end describe command 'mysql --version' do From 6324d35aa025cd361e570233843894cb3096f7d9 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 20 Aug 2020 13:43:07 -0700 Subject: [PATCH 167/300] Release 1.1.0 Signed-off-by: Lance Albertson --- CHANGELOG.md | 4 ++++ metadata.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f17c7359..6fce02f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ This file is used to list changes made in each version of the percona cookbook. +## 1.1.0 - 2020-08-20 + +- Add devel package attribute to client recipe + ## 1.0.0 - 2020-08-14 ### Added diff --git a/metadata.rb b/metadata.rb index 1333a417..2dfde3b4 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '1.0.0' +version '1.1.0' chef_version '>= 13.0' depends 'openssl' From daa615dba9495d6bf8a71d4201dfdd52a00a3eb4 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Tue, 15 Sep 2020 00:03:07 +0000 Subject: [PATCH 168/300] Cookstyle 6.17.6 Fixes Issues found and resolved with: libraries/helpers.rb - 125:1 refactor: ChefCorrectness/IncorrectLibraryInjection - Libraries should be injected into the Chef::DSL::Recipe class and not Chef::Recipe or Chef::Provider classes directly. Signed-off-by: Xorima Bot --- CHANGELOG.md | 4 ++++ libraries/helpers.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fce02f5..b41bedb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + +- resolved cookstyle error: libraries/helpers.rb:125:1 refactor: `ChefCorrectness/IncorrectLibraryInjection` + ## 1.1.0 - 2020-08-20 - Add devel package attribute to client recipe diff --git a/libraries/helpers.rb b/libraries/helpers.rb index bfb963d1..ed9d7caf 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -122,5 +122,5 @@ def percona_jemalloc_lib end end -Chef::Recipe.include ::Percona::Cookbook::Helpers +Chef::DSL::Recipe.include ::Percona::Cookbook::Helpers Chef::Resource.include ::Percona::Cookbook::Helpers From c9e038ef5d5f3255b2267acb6b1dec47115f074a Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Wed, 16 Sep 2020 09:58:43 -0700 Subject: [PATCH 169/300] Release 1.1.1 Signed-off-by: Lance Albertson --- CHANGELOG.md | 2 +- metadata.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b41bedb9..77939c98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 1.1.1 - 2020-09-16 - resolved cookstyle error: libraries/helpers.rb:125:1 refactor: `ChefCorrectness/IncorrectLibraryInjection` diff --git a/metadata.rb b/metadata.rb index 2dfde3b4..dd8f877e 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '1.1.0' +version '1.1.1' chef_version '>= 13.0' depends 'openssl' From bb4f5426460dce7cfacbcf4a4c777b424991de7d Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Fri, 25 Sep 2020 13:02:41 +0000 Subject: [PATCH 170/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .github/workflows/stale.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 00000000..5b05e16d --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,28 @@ +--- +name: Mark stale issues and pull requests + +"on": + schedule: + - cron: "0 0 * * *" + +jobs: + stale: + + runs-on: ubuntu-latest + + steps: + - uses: actions/stale@v3 + - with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + close-issue-message: > + Closing due to inactivity. + If this is still an issue please reopen or open another issue. + Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help! + Thanks, Sous-Chefs. + days-before-close: 7 + days-before-stale: 365 + stale-issue-message: > + Marking stale due to inactivity. + Remove stale label or comment or this will be closed in 7 days. + Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help! + Thanks, Sous-Chefs. From c3828995656f11b0d48dbfa672780a914d7d0cfe Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Sat, 26 Sep 2020 13:01:54 +0000 Subject: [PATCH 171/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 5b05e16d..67d738d3 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/stale@v3 - - with: + with: repo-token: ${{ secrets.GITHUB_TOKEN }} close-issue-message: > Closing due to inactivity. From 2445a27ffd317b99be20be7a7a55de80df0c3841 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Tue, 29 Sep 2020 13:02:42 +0000 Subject: [PATCH 172/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .github/workflows/stale.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 67d738d3..0f337015 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -13,16 +13,16 @@ jobs: steps: - uses: actions/stale@v3 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - close-issue-message: > - Closing due to inactivity. - If this is still an issue please reopen or open another issue. - Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help! - Thanks, Sous-Chefs. - days-before-close: 7 - days-before-stale: 365 - stale-issue-message: > - Marking stale due to inactivity. - Remove stale label or comment or this will be closed in 7 days. - Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help! - Thanks, Sous-Chefs. + repo-token: ${{ secrets.GITHUB_TOKEN }} + close-issue-message: > + Closing due to inactivity. + If this is still an issue please reopen or open another issue. + Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help! + Thanks, Sous-Chefs. + days-before-close: 7 + days-before-stale: 365 + stale-issue-message: > + Marking stale due to inactivity. + Remove stale label or comment or this will be closed in 7 days. + Alternatively drop by the #sous-chefs channel on the [Chef Community Slack](http://community-slack.chef.io/) and we'll be happy to help! + Thanks, Sous-Chefs. From 2b277079e4f8e357284841704b32fd3e0f3d0823 Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Mon, 21 Sep 2020 11:43:59 -0700 Subject: [PATCH 173/300] Add database and user resources Removes support for mysql_chef_gem and mysql2_chef_gem in favor of resources similar to mariadb Signed-off-by: Ethan Hampton --- .github/workflows/ci.yml | 9 + README.md | 27 +- documentation/resource_percona_database.md | 50 +++ documentation/resource_percona_user.md | 64 ++++ kitchen.yml | 43 +++ libraries/hashed_passwords.rb | 44 +++ libraries/helpers.rb | 87 +++++ libraries/provider_mysql2_chef_gem.rb | 27 -- libraries/provider_mysql_chef_gem.rb | 27 -- resources/database.rb | 87 +++++ resources/user.rb | 314 ++++++++++++++++++ .../cookbooks/test/recipes/user_database.rb | 168 ++++++++++ .../inspec/controls/resources_spec.rb | 56 ++++ 13 files changed, 927 insertions(+), 76 deletions(-) create mode 100644 documentation/resource_percona_database.md create mode 100644 documentation/resource_percona_user.md create mode 100644 libraries/hashed_passwords.rb delete mode 100644 libraries/provider_mysql2_chef_gem.rb delete mode 100644 libraries/provider_mysql_chef_gem.rb create mode 100644 resources/database.rb create mode 100644 resources/user.rb create mode 100644 test/fixtures/cookbooks/test/recipes/user_database.rb create mode 100644 test/integration/inspec/controls/resources_spec.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c39fea8..78b178a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,9 @@ jobs: - 'replication-56' - 'replication-57' - 'replication-80' + - 'resources-56' + - 'resources-57' + - 'resources-80' exclude: - os: centos-8 suite: client-56 @@ -77,6 +80,8 @@ jobs: suite: source-56 - os: centos-8 suite: replication-56 + - os: centos-8 + suite: resources-56 - os: debian-10 suite: client-56 - os: debian-10 @@ -87,6 +92,8 @@ jobs: suite: source-56 - os: debian-10 suite: replication-56 + - os: debian-10 + suite: resources-56 - os: ubuntu-2004 suite: client-56 - os: ubuntu-2004 @@ -97,6 +104,8 @@ jobs: suite: source-56 - os: ubuntu-2004 suite: replication-56 + - os: ubuntu-2004 + suite: resources-56 fail-fast: false steps: diff --git a/README.md b/README.md index 94f0030a..5259c6bc 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,11 @@ This cookbook requires Chef >= 13. - `percona::access_grants` - Used internally to grant permissions for recipes. - `percona::ssl` - Used internally to setup ssl certificates for server/client. +## Resources + +- [`user`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_user.md) +- [`database`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_database.md) + ## Usage This cookbook installs the Percona MySQL components if not present, and pulls updates if they are installed on the @@ -235,28 +240,6 @@ slow_query_log_file = /var/lib/mysql/data/mysql-slow.log There's a special attribute `node['percona']['server']['bind_to']` that allows you to dynamically set the bind address. This attribute accepts the values `"public_ip"`, `"private_ip"`, `"loopback"`, or and interface name like `"eth0"`. Based on this, the recipe will find a corresponding ipv4 address, and override the `node['percona']['server']['bind_address']` attribute. -## MySQL Gems - -This cookbook provides a MySQL and MySQL2 gem installer specifically designed for -use with Percona. Since they share namespaces with other providers you most -likely want to call them directly targeting the provider, example provided below: - -```ruby -mysql2_chef_gem 'default' do - provider Chef::Provider::Mysql2ChefGem::Percona - action :install -end - -mysql_chef_gem 'default' do - provider Chef::Provider::MysqlChefGem::Percona - action :install -end -``` - -Also keep in mind that since these providers are subclasses of the mysql_chef_gem -and mysql2_chef_gem cookbooks they need to be added to your metadata.rb file as -depends to ensure they pull in the needed resource files. - ## Goals In no particular order: diff --git a/documentation/resource_percona_database.md b/documentation/resource_percona_database.md new file mode 100644 index 00000000..b6ec5441 --- /dev/null +++ b/documentation/resource_percona_database.md @@ -0,0 +1,50 @@ +# percona\_database + +Manage databases and execute SQL queries on them. It works by establishing a control connection to the Percona server using the percona client (be sure it is installed before using this resource). + +## Actions + +- create - (default) to create a named database +- drop - to drop a named database +- query - to execute a SQL query + +## Properties + +Name | Types | Description | Default | Required? +----------------- | ----------------- | ------------------------------------------------------------ | ----------------------------------------- | --------- +`user` | String | the username of the control connection | `root` | no +`password` | String | password of the user used to connect to | | no +`host` | String | host to connect to | `localhost` | no +`port` | String | port of the host to connect to | `3306` | no +`database_name` | String | the name of the database to manage | `name` if not specified | no +`encoding` | String | | `utf8` | no +`collation` | String | | `utf8_general_ci` | no +`sql` | String | the SQL query to execute | | no + +When `host` has the value `localhost`, it will try to connect using a Unix socket, or TCP/IP if no socket is defined. + +### Examples + +```ruby +# Create a database +percona_database 'wordpress-cust01' do + host '127.0.0.1' + user 'root' + password node['wordpress-cust01']['mysql']['initial_root_password'] + action :create +end + +# Drop a database +percona_database 'baz' do + action :drop +end + +# Query a database +percona_database 'flush the privileges' do + sql 'flush privileges' + action :query +end +``` + +**The `query` action will NOT select a database before running the query, nor return the actual results from the SQL query.** + diff --git a/documentation/resource_percona_user.md b/documentation/resource_percona_user.md new file mode 100644 index 00000000..be19ac84 --- /dev/null +++ b/documentation/resource_percona_user.md @@ -0,0 +1,64 @@ +# percona\_user + +Manage users and grant them privileges on database objects. + +## Actions + +- create - (default) to create a user +- drop - to drop a user +- grant - to grant privileges to a user +- revoke - to revoke privileges from a user + +## Properties + +Name | Types | Description | Default | Required? +----------------- | ---------------------- | ------------------------------------------------------------ | ----------------------------------------- | --------- +`ctrl_user` | String | the username of the control connection | `root` | no +`ctrl_password` | String | password of the user used to connect to | | no +`ctrl_host` | String | host to connect to | `localhost` | no +`ctrl_port` | String | port of the host to connect to | `3306` | no +`username` | String | The database user to be managed | `name` if not defined | no +`host` | String | The host from which the user is allowed to connect | `localhost` | no +`password` | String, HashedPassword | password the user will be asked for to connect | | yes +`privileges` | Array | | `[:all]` | no +`database_name` | String | | | no +`table` | String | | | no +`grant_option` | true/false | | `false` | no +`require_ssl` | true/false | | `false` | no +`require_x509` | true/false | | `false` | no +`use_native_auth` | true/false | if using percona >8, use `mysql_native_password` for auth | `true` | no + +### `use_native_auth` + +This property should be set to `false` if the user is local (host of `localhost`) to provide better security. The property still works for remote users but does not provide any idempotency guarantees. `use_native_auth` has no effect for percona <8. + +## Examples + +```ruby +# Create an user but grant no privileges +percona_user 'disenfranchised' do + password 'super_secret' + action :create +end + +# Create an user using a hashed password string instead of plain text one +percona_user 'disenfranchised' do + password hashed_password('md5eacdbf8d9847a76978bd515fae200a2a') + action :create +end + +# Drop a user +percona_user 'foo_user' do + action :drop +end + +# Grant SELECT, UPDATE, and INSERT privileges to all tables in foo db from all hosts +percona_user 'foo_user' do + password 'super_secret' + database_name 'foo' + host '%' + privileges [:select,:update,:insert] + action :grant +end +``` + diff --git a/kitchen.yml b/kitchen.yml index 2f64ed40..52883d50 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -300,3 +300,46 @@ suites: inputs: version: '8.0' type: 'replication' + + - name: resources-56 + run_list: + - recipe[test::user_database] + attributes: + percona: + version: '5.6' + excludes: + - centos-8 + - debian-10 + - ubuntu-20.04 + verifier: + controls: + - percona_database + - percona_user + inputs: + version: '5.6' + + - name: resources-57 + run_list: + - recipe[test::user_database] + attributes: + percona: + version: '5.7' + verifier: + controls: + - percona_database + - percona_user + inputs: + version: '5.8' + + - name: resources-80 + run_list: + - recipe[test::user_database] + attributes: + percona: + version: '8.0' + verifier: + controls: + - percona_database + - percona_user + inputs: + version: '8.0' diff --git a/libraries/hashed_passwords.rb b/libraries/hashed_passwords.rb new file mode 100644 index 00000000..fd34b74e --- /dev/null +++ b/libraries/hashed_passwords.rb @@ -0,0 +1,44 @@ +# +# Author:: Maksim Horbul () +# Cookbook:: mariadb +# Library:: hashed_password +# +# Copyright:: 2016-2020, Eligible, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +class HashedPassword + # Initializes an object of the MysqlPassword type + # @param [String] hashed_password mysql native hashed password + # @return [MysqlPassword] + def initialize(hashed_password) + @hashed_password = hashed_password + end + + # String representation of the object + # @return [String] hashed password string + def to_s + @hashed_password + end + + module Helper + # helper method wrappers the string into a MysqlPassword object + # @param [String] hashed_password mysql native hashed password + # @return [MysqlPassword] object + def hashed_password(hashed_password) + HashedPassword.new hashed_password + end + # For backward compatibility, because method was renamed + alias_method :mysql_hashed_password, :hashed_password + end +end diff --git a/libraries/helpers.rb b/libraries/helpers.rb index ed9d7caf..cf32589d 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -118,6 +118,93 @@ def percona_jemalloc_lib node['platform_version'].to_i >= 8 ? '/usr/lib64/libjemalloc.so.2' : '/usr/lib64/libjemalloc.so.1' end end + + include Chef::Mixin::ShellOut + require 'securerandom' + ####### + # Function to execute an SQL statement + # Input: + # query : Query could be a single String or an Array of String. + # database : a string containing the name of the database to query in, nil if no database choosen + # ctrl : a Hash which could contain: + # - user : String or nil + # - password : String or nil + # - host : String or nil + # - port : String or Integer or nil + # - socket : String or nil + # Output: A String with cmd to execute the query (but do not execute it!) + # + def sql_command_string(query, database, ctrl, grep_for = nil) + raw_query = query.is_a?(String) ? query : query.join(";\n") + Chef::Log.debug("Control Hash: [#{ctrl.to_json}]\n") + cmd = "/usr/bin/mysql -B -e \"#{raw_query}\"" + cmd << " --user=#{ctrl[:user]}" if ctrl && ctrl.key?(:user) && !ctrl[:user].nil? + cmd << " -p#{ctrl[:password]}" if ctrl && ctrl.key?(:password) && !ctrl[:password].nil? + cmd << " -h #{ctrl[:host]}" if ctrl && ctrl.key?(:host) && !ctrl[:host].nil? && ctrl[:host] != 'localhost' + cmd << " -P #{ctrl[:port]}" if ctrl && ctrl.key?(:port) && !ctrl[:port].nil? && ctrl[:host] != 'localhost' + cmd << " -S #{default_socket}" if ctrl && ctrl.key?(:host) && !ctrl[:host].nil? && ctrl[:host] == 'localhost' + cmd << " #{database}" unless database.nil? + cmd << " | grep #{grep_for}" if grep_for + Chef::Log.debug("Executing this command: [#{cmd}]\n") + cmd + end + + ####### + # Function to execute an SQL statement in the default database. + # Input: Query could be a single String or an Array of String. + # Output: A String with -separated columns and \n-separated rows. + # This is easiest for 1-field (1-row, 1-col) results, otherwise + # it will be complex to parse the results. + def execute_sql(query, db_name, ctrl) + cmd = shell_out(sql_command_string(query, db_name, ctrl), + user: 'root') + if cmd.exitstatus != 0 + Chef::Log.fatal("mysql failed executing this SQL statement:\n#{query}") + Chef::Log.fatal(cmd.stderr) + raise 'SQL ERROR' + end + cmd.stdout + end + + # Returns status code of sql query + def execute_sql_exitstatus(query, ctrl) + shell_out(sql_command_string(query, nil, ctrl), user: 'root').exitstatus + end + + def parse_one_row(row, titles) + return_hash = {} + index = 0 + row.split("\t").each do |column| + return_hash[titles[index]] = column + index += 1 + end + return_hash + end + + def parse_mysql_batch_result(mysql_batch_result) + results = mysql_batch_result.split("\n") + titles = [] + index = 0 + return_array = [] + results.each do |row| + if index == 0 + titles = row.split("\t") + else + return_array[index - 1] = parse_one_row(row, titles) + end + index += 1 + end + return_array + end + + def default_socket + case node['platform_family'] + when 'rhel', 'fedora', 'amazon' + '/var/lib/mysql/mysql.sock' + when 'debian' + '/var/run/mysqld/mysqld.sock' + end + end end end end diff --git a/libraries/provider_mysql2_chef_gem.rb b/libraries/provider_mysql2_chef_gem.rb deleted file mode 100644 index 13a73e7c..00000000 --- a/libraries/provider_mysql2_chef_gem.rb +++ /dev/null @@ -1,27 +0,0 @@ -class Chef - class Provider - class Mysql2ChefGem - # Provider to install MySQL2 gem on systems using Percona databases - class Percona < Chef::Provider::LWRPBase - action :install do - converge_by 'install mysql2 chef_gem and dependencies' do - recipe_eval do - run_context.include_recipe 'build-essential' - run_context.include_recipe 'percona::client' - end - - chef_gem 'mysql2' do - action :install - end - end - end - - action :remove do - chef_gem 'mysql2' do - action :remove - end - end - end - end - end -end diff --git a/libraries/provider_mysql_chef_gem.rb b/libraries/provider_mysql_chef_gem.rb deleted file mode 100644 index 8f2bf2b2..00000000 --- a/libraries/provider_mysql_chef_gem.rb +++ /dev/null @@ -1,27 +0,0 @@ -class Chef - class Provider - class MysqlChefGem - # Provider to install MySQL gem on systems using Percona databases - class Percona < Chef::Provider::LWRPBase - action :install do - converge_by 'install mysql chef_gem and dependencies' do - recipe_eval do - run_context.include_recipe 'build-essential' - run_context.include_recipe 'percona::client' - end - - chef_gem 'mysql' do - action :install - end - end - end - - action :remove do - chef_gem 'mysql' do - action :remove - end - end - end - end - end -end diff --git a/resources/database.rb b/resources/database.rb new file mode 100644 index 00000000..8ea69823 --- /dev/null +++ b/resources/database.rb @@ -0,0 +1,87 @@ +# +# Cookbook:: percona +# Resource:: database +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +provides :percona_database + +include Percona::Cookbook::Helpers + +property :database_name, String, name_property: true +property :host, [String, nil], default: 'localhost', desired_state: false +property :port, [Integer, nil], default: 3306, desired_state: false +property :user, [String, nil], default: 'root', desired_state: false +property :socket, [String, nil], desired_state: false +property :password, [String, nil], sensitive: true, desired_state: false +property :encoding, String, default: 'utf8' +property :collation, String, default: 'utf8_general_ci' +property :sql, String + +action :create do + if current_resource.nil? + converge_by "Creating database '#{new_resource.database_name}'" do + create_sql = "CREATE DATABASE IF NOT EXISTS \\`#{new_resource.database_name}\\`" + create_sql << " CHARACTER SET = #{new_resource.encoding}" if new_resource.encoding + create_sql << " COLLATE = #{new_resource.collation}" if new_resource.collation + run_query(create_sql, nil) + end + else + converge_if_changed :encoding do + run_query("ALTER SCHEMA \\`#{new_resource.database_name}\\` CHARACTER SET #{new_resource.encoding}", nil) + end + converge_if_changed :collation do + run_query("ALTER SCHEMA \\`#{new_resource.database_name}\\` COLLATE #{new_resource.collation}", nil) + end + end +end + +action :drop do + return if current_resource.nil? + converge_by "Dropping database '#{new_resource.database_name}'" do + run_query("DROP DATABASE IF EXISTS \\`#{new_resource.database_name}\\`", nil) + end +end + +action :query do + run_query(new_resource.sql, nil) +end + +load_current_value do + lsocket = (socket && host == 'localhost') ? socket : nil + ctrl = { user: user, password: password + }.merge!(lsocket.nil? ? { host: host, port: port } : { socket: lsocket }) + query = "SHOW DATABASES LIKE '#{database_name}'" + results = execute_sql(query, nil, ctrl).split("\n") + current_value_does_not_exist! if results.count == 0 + + results = execute_sql("SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '#{database_name}'", nil, ctrl) + results.split("\n").each do |row| + columns = row.split("\t") + if columns[0] != 'DEFAULT_CHARACTER_SET_NAME' + encoding columns[0] + collation columns[1] + end + end +end + +action_class do + include Percona::Cookbook::Helpers + + def run_query(query, database) + socket = (new_resource.socket && new_resource.host == 'localhost') ? new_resource.socket : nil + ctrl_hash = { host: new_resource.host, port: new_resource.port, user: new_resource.user, password: new_resource.password, socket: socket } + Chef::Log.debug("#{@new_resource}: Performing query [#{query}]") + execute_sql(query, database, ctrl_hash) + end +end diff --git a/resources/user.rb b/resources/user.rb new file mode 100644 index 00000000..11434ce9 --- /dev/null +++ b/resources/user.rb @@ -0,0 +1,314 @@ +# +# Cookbook:: percona +# Resource:: user +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +provides :percona_user + +include Percona::Cookbook::Helpers + +property :username, String, name_property: true +property :password, [String, HashedPassword, NilClass], default: nil, sensitive: true +property :host, String, default: 'localhost', desired_state: false +property :database_name, String +property :table, String +property :privileges, Array, default: [:all] +property :grant_option, [true, false], default: false +property :require_ssl, [true, false], default: false +property :require_x509, [true, false], default: false +property :use_native_auth, [true, false], default: true +# Credentials used for control connection +property :ctrl_user, [String, NilClass], default: 'root', desired_state: false +property :ctrl_password, [String, NilClass], sensitive: true, desired_state: false +property :ctrl_host, [String, NilClass], default: 'localhost', desired_state: false +property :ctrl_port, [Integer, NilClass], default: 3306, desired_state: false + +action :create do + if current_resource.nil? + converge_by "Creating user '#{new_resource.username}'@'#{new_resource.host}'" do + create_sql = "CREATE USER '#{new_resource.username}'@'#{new_resource.host}'" + unless database_has_password_column + create_sql << ' REQUIRE SSL' if new_resource.require_ssl + create_sql << ' REQUIRE X509' if new_resource.require_x509 + create_sql << ' WITH GRANT OPTION' if new_resource.grant_option + end + run_query create_sql + update_user_password if new_resource.password + end + elsif !test_user_password + update_user_password + end +end + +load_current_value do + socket = ctrl_host == 'localhost' ? default_socket : nil + ctrl = { user: ctrl_user, password: ctrl_password + }.merge!(socket.nil? ? { host: ctrl_host, port: ctrl_port.to_s } : { socket: socket }) + query = "SELECT User,Host FROM mysql.user WHERE User='#{username}' AND Host='#{host}';" + results = execute_sql(query, nil, ctrl) + current_value_does_not_exist! if results.split("\n").count <= 1 +end + +action_class do + include Percona::Cookbook::Helpers + + def run_query(query) + socket = new_resource.ctrl_host == 'localhost' ? default_socket : nil + ctrl_hash = { host: new_resource.ctrl_host, port: new_resource.ctrl_port, username: new_resource.ctrl_user, password: new_resource.ctrl_password, socket: socket } + Chef::Log.debug("#{@new_resource}: Performing query [#{query}]") + execute_sql(query, nil, ctrl_hash) + end + + def database_has_password_column + begin + result = run_query("SHOW COLUMNS FROM mysql.user WHERE Field='Password';") + rescue + return false + end + result.split("\n").count > 1 + end + + def redact_password(query, password) + if password.nil? || password == '' + query + else + query.gsub(password.to_s, 'REDACTED') + end + end + + def test_user_password + if database_has_password_column + test_sql = 'SELECT User,Host,Password FROM mysql.user ' \ + "WHERE User='#{new_resource.username}' AND Host='#{new_resource.host}' " + test_sql << if new_resource.password.is_a? HashedPassword + "AND Password='#{new_resource.password}'" + else + "AND Password=PASSWORD('#{new_resource.password}')" + end + run_query(test_sql).split("\n").count > 1 + else # Works for any authentication method as long as the host is localhost + test_sql = "SELECT 'user can login'" + socket = new_resource.ctrl_host == 'localhost' ? default_socket : nil + ctrl_hash = { host: new_resource.ctrl_host, port: new_resource.ctrl_port, user: new_resource.username, password: new_resource.password, socket: socket } + Chef::Log.debug("#{@new_resource}: Performing query [#{test_sql}]") + + if execute_sql_exitstatus(test_sql, ctrl_hash) == 0 + true + else # handles mysql_native_password authentication method + test_sql = 'SELECT User,Host,authentication_string FROM mysql.user ' \ + "WHERE User='#{new_resource.username}' AND Host='#{new_resource.host}' " # \ + test_sql << if new_resource.password.is_a? HashedPassword + "AND authentication_string='#{new_resource.password}'" + elsif new_resource.password != '' + # This is the password auth algorithm implmented by PASSWORD() which no longer exists on mysql 8 + "AND authentication_string=CONCAT('*', UPPER(SHA1(UNHEX(SHA1('#{new_resource.password}')))))" + else + "AND authentication_string=''" + end + run_query(test_sql).split("\n").count > 1 + end + end + end + + def update_user_password + converge_by "Update password for user '#{new_resource.username}'@'#{new_resource.host}'" do + if database_has_password_column + password_sql = "SET PASSWORD FOR '#{new_resource.username}'@'#{new_resource.host}' = " + password_sql << if new_resource.password.is_a? HashedPassword + "'#{new_resource.password}'" + else + " PASSWORD('#{new_resource.password}')" + end + else + # "ALTER USER is now the preferred statement for assigning passwords." + # http://dev.mysql.com/doc/refman/5.7/en/set-password.html + password_sql = "ALTER USER '#{new_resource.username}'@'#{new_resource.host}' " + password_sql << if new_resource.password.is_a? HashedPassword + "IDENTIFIED WITH mysql_native_password AS '#{new_resource.password}'" + elsif new_resource.use_native_auth + "IDENTIFIED WITH mysql_native_password BY '#{new_resource.password}'" + else + "IDENTIFIED BY '#{new_resource.password}'" + end + end + run_query password_sql + end + end + + def desired_privs + possible_global_privs = [ + :select, + :insert, + :update, + :delete, + :create, + :drop, + :references, + :index, + :alter, + :create_tmp_table, + :lock_tables, + :create_view, + :show_view, + :create_routine, + :alter_routine, + :execute, + :event, + :trigger, + :reload, + :shutdown, + :process, + :file, + :show_db, + :super, + :repl_slave, + :repl_client, + :create_user, + ] + possible_db_privs = [ + :select, + :insert, + :update, + :delete, + :create, + :drop, + :references, + :index, + :alter, + :create_tmp_table, + :lock_tables, + :create_view, + :show_view, + :create_routine, + :alter_routine, + :execute, + :event, + :trigger, + ] + + # convert :all to the individual db or global privs + if new_resource.privileges == [:all] && new_resource.database_name + possible_db_privs + elsif new_resource.privileges == [:all] + possible_global_privs + else + new_resource.privileges + end + end + + def revokify_key(key) + return '' if key.nil? + + # Some keys need to be translated as outlined by the table found here: + # https://dev.mysql.com/doc/refman/5.7/en/privileges-provided.html + result = key.to_s.downcase.tr('_', ' ').gsub('repl ', 'replication ').gsub('create tmp table', 'create temporary tables').gsub('show db', 'show databases') + result.gsub(/ priv$/, '') + end +end + +action :drop do + return if current_resource.nil? + converge_by "Dropping user '#{new_resource.username}'@'#{new_resource.host}'" do + drop_sql = 'DROP USER' + drop_sql << " '#{new_resource.username}'@'#{new_resource.host}'" + run_query drop_sql + end +end + +action :grant do + db_name = new_resource.database_name ? "\\`#{new_resource.database_name}\\`" : '*' + tbl_name = new_resource.table || '*' + test_table = new_resource.database_name ? 'mysql.db' : 'mysql.user' + + # Test + incorrect_privs = nil + test_sql = "SELECT * from #{test_table}" + test_sql << " WHERE User='#{new_resource.username}'" + test_sql << " AND Host='#{new_resource.host}'" + test_sql << " AND Db='#{new_resource.database_name}'" if new_resource.database_name + test_sql_results = run_query test_sql + + incorrect_privs = true if test_sql_results.split("\n").count == 0 + # These should all be 'Y' + unless test_sql_results.split("\n").count <= 1 + parsed_result = parse_mysql_batch_result(test_sql_results) + Chef::Log.debug(parsed_result) + parsed_result.each do |r| + desired_privs.each do |p| + key = p.to_s.capitalize.tr(' ', '_').gsub('Replication_', 'Repl_').gsub('Create_temporary_tables', 'Create_tmp_table').gsub('Show_databases', 'Show_db') + key = "#{key}_priv" + incorrect_privs = true if r[key] != 'Y' + end + end + end + + password_up_to_date = incorrect_privs || test_user_password + + # Repair + if incorrect_privs + converge_by "Granting privs for '#{new_resource.username}'@'#{new_resource.host}'" do + repair_sql = "GRANT #{new_resource.privileges.join(',')}" + repair_sql << " ON #{db_name}.#{tbl_name}" + repair_sql << " TO '#{new_resource.username}'@'#{new_resource.host}'" + if database_has_password_column + repair_sql << ' REQUIRE SSL' if new_resource.require_ssl + repair_sql << ' REQUIRE X509' if new_resource.require_x509 + repair_sql << ' WITH GRANT OPTION' if new_resource.grant_option + end + + redacted_sql = redact_password(repair_sql, new_resource.password) + Chef::Log.debug("#{@new_resource}: granting with sql [#{redacted_sql}]") + run_query(repair_sql) + run_query('FLUSH PRIVILEGES') + end + else + # The grants are correct, but perhaps the password needs updating? + update_user_password unless password_up_to_date + end +end + +action :revoke do + db_name = new_resource.database_name ? "\\`#{new_resource.database_name}\\`" : '*' + tbl_name = new_resource.table || '*' + test_table = new_resource.database_name ? 'mysql.db' : 'mysql.user' + + privs_to_revoke = [] + test_sql = "SELECT * from #{test_table}" + test_sql << " WHERE User='#{new_resource.username}'" + test_sql << " AND Host='#{new_resource.host}'" + test_sql << " AND Db='#{new_resource.database_name}'" if new_resource.database_name + test_sql_results = run_query test_sql + + # These should all be 'N' + test_sql_results.each do |r| + desired_privs.each do |p| + key = p.to_s.capitalize.tr(' ', '_').gsub('Replication_', 'Repl_').gsub('Create_temporary_tables', 'Create_tmp_table').gsub('Show_databases', 'Show_db') + key = "#{key}_priv" + privs_to_revoke << revokify_key(p) if r[key] != 'N' + end + end + + # Repair + unless privs_to_revoke.empty? + converge_by "Revoking privs for '#{new_resource.username}'@'#{new_resource.host}'" do + revoke_statement = "REVOKE #{privs_to_revoke.join(',')}" + revoke_statement << " ON #{db_name}.#{tbl_name}" + revoke_statement << " FROM \\`#{new_resource.username}\\`@\\`#{new_resource.host}\\` " + + Chef::Log.debug("#{@new_resource}: revoking access with statement [#{revoke_statement}]") + run_query revoke_statement + run_query 'FLUSH PRIVILEGES' + end + end +end diff --git a/test/fixtures/cookbooks/test/recipes/user_database.rb b/test/fixtures/cookbooks/test/recipes/user_database.rb new file mode 100644 index 00000000..38f86075 --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/user_database.rb @@ -0,0 +1,168 @@ +::Chef::DSL::Recipe.include HashedPassword::Helper + +node.default['percona']['skip_passwords'] = true +node.default['percona']['server']['debian_username'] = 'root' +node.default['percona']['server']['debian_password'] = '' +include_recipe 'percona::server' + +# Create a schema to test mysql_database :drop against +bash 'create datatrout' do + code <<-EOF + echo 'CREATE SCHEMA datatrout;' | /usr/bin/mysql -u root; + touch /tmp/troutmarker + EOF + not_if { ::File.exist?('/tmp/troutmarker') } + action :run +end + +# Create a database for testing existing grant operations +bash 'create datasalmon' do + code <<-EOF + echo 'CREATE SCHEMA datasalmon;' | /usr/bin/mysql -u root; + touch /tmp/salmonmarker + EOF + not_if { ::File.exist?('/tmp/salmonmarker') } + action :run +end + +# Create a user to test mysql_database_user :drop against +bash 'create kermit' do + code <<-EOF + echo "CREATE USER 'kermit'@'localhost';" | /usr/bin/mysql -u root; + touch /tmp/kermitmarker + EOF + not_if { ::File.exist?('/tmp/kermitmarker') } + action :run +end + +# Create a user to test mysql_database_user password update via :create +bash 'create rowlf' do + code <<-EOF + echo "CREATE USER 'rowlf'@'localhost' IDENTIFIED BY 'hunter2';" | /usr/bin/mysql -u root; + touch /tmp/rowlfmarker + EOF + not_if { ::File.exist?('/tmp/rowlfmarker') } + action :run +end + +# Create a user to test mysql_database_user password update via :create using a password hash +bash 'create statler' do + code <<-EOF + echo "CREATE USER 'statler'@'localhost' IDENTIFIED BY 'hunter2';" | /usr/bin/mysql -u root; + touch /tmp/statlermarker + EOF + not_if { ::File.exist?('/tmp/statlermarker') } + action :run +end + +# Create a user to test mysql_database_user password update via :grant +bash 'create rizzo' do + code <<-EOF + echo "CREATE USER 'rizzo'@'127.0.0.1' IDENTIFIED BY 'hunter2'; GRANT SELECT ON datasalmon.* TO 'rizzo'@'127.0.0.1';" | /usr/bin/mysql -u root; + touch /tmp/rizzomarker + EOF + not_if { ::File.exist?('/tmp/rizzomarker') } + action :run +end + +## Resources we're testing +percona_database 'databass' do + action :create + password '' +end + +percona_database 'datatrout' do + action :drop + password '' +end + +percona_user 'piggy' do + action :create + ctrl_password '' +end + +percona_user 'kermit' do + action :drop + ctrl_password '' +end + +percona_user 'rowlf' do + password '123456' # hashed: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 + ctrl_password '' + action :create +end + +percona_user 'gonzo' do + password 'abcdef' + ctrl_password '' + host '10.10.10.%' + action :create +end + +# create gonzo again to ensure the create action is idempotent +percona_user 'gonzo' do + password 'abcdef' + ctrl_password '' + host '10.10.10.%' + action :create +end + +hash = hashed_password('*2027D9391E714343187E07ACB41AE8925F30737E'); # 'l33t' + +percona_user 'statler' do + password hash + ctrl_password '' + action :create +end + +percona_user 'fozzie' do + database_name 'databass' + password 'wokkawokka' + host 'mars' + privileges [:select, :update, :insert] + require_ssl true + ctrl_password '' + action [:create, :grant] +end + +hash2 = hashed_password('*F798E7C0681068BAE3242AA2297D2360DBBDA62B'); # 'zokkazokka' + +percona_user 'moozie' do + database_name 'databass' + password hash2 + ctrl_password '' + host '127.0.0.1' + privileges [:select, :update, :insert] + require_ssl false + action [:create, :grant] +end + +# all the grants exist ('Granting privs' should not show up), but the password is different +# and should get updated +percona_user 'rizzo' do + database_name 'datasalmon' + password 'salmon' + ctrl_password '' + host '127.0.0.1' + privileges [:select] + require_ssl false + action :grant +end + +# Should converge normally for all versions +# Checks to insure SHA2 password algo works for percona 8 +# with the host set to localhost +percona_user 'beaker' do + password 'meep' + host 'localhost' + ctrl_password '' + use_native_auth false + action :create +end + +percona_database 'flush privileges' do + database_name 'databass' + password '' + sql 'flush privileges' + action :query +end diff --git a/test/integration/inspec/controls/resources_spec.rb b/test/integration/inspec/controls/resources_spec.rb new file mode 100644 index 00000000..905a300f --- /dev/null +++ b/test/integration/inspec/controls/resources_spec.rb @@ -0,0 +1,56 @@ +control 'percona_database' do + impact 1.0 + title 'test creation and removal of databases' + + sql = mysql_session('root') + + describe sql.query('show databases') do + its(:stdout) { should match(/databass/) } + its(:stdout) { should_not match(/datatrout/) } + end +end + +control 'percona_user' do + impact 1.0 + title 'test creation, granting and removal of users' + + version = input('version') + password_column = version.to_f >= 5.7 ? 'authentication_string' : 'password' + + sql = mysql_session('root') + + describe sql.query('select User,Host from mysql.user') do + its(:stdout) { should match(/fozzie/) } + its(:stdout) { should_not match(/kermit/) } + end + + describe sql.query("SELECT #{password_column} FROM mysql.user WHERE user='fozzie' AND host='mars'") do + its(:stdout) { should include '*EF112B3D562CB63EA3275593C10501B59C4A390D' } + end + + describe sql.query("SELECT #{password_column} FROM mysql.user WHERE user='moozie' AND host='127.0.0.1'") do + its(:stdout) { should include '*F798E7C0681068BAE3242AA2297D2360DBBDA62B' } + end + + sql2 = mysql_session('moozie', 'zokkazokka', '127.0.0.1') + + describe sql2.query('show tables from databass') do + its(:exit_status) { should eq 0 } + end + + describe sql.query("SELECT #{password_column} FROM mysql.user WHERE user='rowlf' AND host = 'localhost'") do + its(:stdout) { should include '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' } + end + + describe sql.query("SELECT #{password_column} FROM mysql.user WHERE user='statler' AND host='localhost'") do + its(:stdout) { should include '*2027D9391E714343187E07ACB41AE8925F30737E' } + end + + describe sql.query('select Host from mysql.user where User like \'gonzo\'') do + its(:stdout) { should include '10.10.10.%' } + end + + describe sql.query("SELECT #{password_column} FROM mysql.user WHERE user='rizzo' AND host='127.0.0.1'") do + its(:stdout) { should include '*125EA03B506F7C876D9321E9055F37601461E970' } + end +end From a0908503ebab2c5f088e78770aa4637e9edcae06 Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Tue, 22 Sep 2020 09:25:08 -0700 Subject: [PATCH 174/300] Update README.md Co-authored-by: Lance Albertson --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5259c6bc..defc9138 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,8 @@ This cookbook requires Chef >= 13. ## Resources -- [`user`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_user.md) -- [`database`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_database.md) +- [`percona_user`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_user.md) +- [`percona_database`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_database.md) ## Usage From 2d9fd41c070628148507ef3a3a8ea87842f6be80 Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Tue, 22 Sep 2020 10:35:30 -0700 Subject: [PATCH 175/300] Update CHANGELOG.md Signed-off-by: Ethan Hampton --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77939c98..3a74b72d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + +### Added + +- Add `percona_database` resource for creating, querying and removing databases +- Add `percona_user` resource for creating, modifying and removing database users + +### Removed + +- Remove `mysql_chef_gem` and `mysql2_chef_gem` providers in favor of the `percona_database` and `percona_user` resources + ## 1.1.1 - 2020-09-16 - resolved cookstyle error: libraries/helpers.rb:125:1 refactor: `ChefCorrectness/IncorrectLibraryInjection` From 57615370871a50c11ac0cd36d319269198faa37b Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Tue, 22 Sep 2020 10:37:15 -0700 Subject: [PATCH 176/300] Fix yaml lint error Signed-off-by: Ethan Hampton --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78b178a6..57d5a4c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ --- name: ci -on: +"on": pull_request: push: branches: From f6f728e1bdc8a902d2d721d9a75bf4bd6f54c139 Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Mon, 28 Sep 2020 15:25:11 -0700 Subject: [PATCH 177/300] Change resource names to include 'mysql' --- CHANGELOG.md | 6 ++--- README.md | 4 +-- ....md => resource_percona_mysql_database.md} | 8 +++--- ...user.md => resource_percona_mysql_user.md} | 10 +++---- resources/{database.rb => mysql_database.rb} | 2 +- resources/{user.rb => mysql_user.rb} | 2 +- .../cookbooks/test/recipes/user_database.rb | 26 +++++++++---------- 7 files changed, 29 insertions(+), 29 deletions(-) rename documentation/{resource_percona_database.md => resource_percona_mysql_database.md} (93%) rename documentation/{resource_percona_user.md => resource_percona_mysql_user.md} (95%) rename resources/{database.rb => mysql_database.rb} (99%) rename resources/{user.rb => mysql_user.rb} (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a74b72d..b470c359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,12 @@ This file is used to list changes made in each version of the percona cookbook. ### Added -- Add `percona_database` resource for creating, querying and removing databases -- Add `percona_user` resource for creating, modifying and removing database users +- Add `percona_mysql_database` resource for creating, querying and removing databases +- Add `percona_mysql_user` resource for creating, modifying and removing database users ### Removed -- Remove `mysql_chef_gem` and `mysql2_chef_gem` providers in favor of the `percona_database` and `percona_user` resources +- Remove `mysql_chef_gem` and `mysql2_chef_gem` providers in favor of the `percona_mysql_database` and `percona_mysql_user` resources ## 1.1.1 - 2020-09-16 diff --git a/README.md b/README.md index defc9138..cbfe1726 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,8 @@ This cookbook requires Chef >= 13. ## Resources -- [`percona_user`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_user.md) -- [`percona_database`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_database.md) +- [`percona_mysql_user`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_user.md) +- [`percona_mysql_database`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_database.md) ## Usage diff --git a/documentation/resource_percona_database.md b/documentation/resource_percona_mysql_database.md similarity index 93% rename from documentation/resource_percona_database.md rename to documentation/resource_percona_mysql_database.md index b6ec5441..48e093c1 100644 --- a/documentation/resource_percona_database.md +++ b/documentation/resource_percona_mysql_database.md @@ -1,4 +1,4 @@ -# percona\_database +# percona\_mysql\_database Manage databases and execute SQL queries on them. It works by establishing a control connection to the Percona server using the percona client (be sure it is installed before using this resource). @@ -27,7 +27,7 @@ When `host` has the value `localhost`, it will try to connect using a Unix socke ```ruby # Create a database -percona_database 'wordpress-cust01' do +percona_mysql_database 'wordpress-cust01' do host '127.0.0.1' user 'root' password node['wordpress-cust01']['mysql']['initial_root_password'] @@ -35,12 +35,12 @@ percona_database 'wordpress-cust01' do end # Drop a database -percona_database 'baz' do +percona_mysql_database 'baz' do action :drop end # Query a database -percona_database 'flush the privileges' do +percona_mysql_database 'flush the privileges' do sql 'flush privileges' action :query end diff --git a/documentation/resource_percona_user.md b/documentation/resource_percona_mysql_user.md similarity index 95% rename from documentation/resource_percona_user.md rename to documentation/resource_percona_mysql_user.md index be19ac84..17cb1662 100644 --- a/documentation/resource_percona_user.md +++ b/documentation/resource_percona_mysql_user.md @@ -1,4 +1,4 @@ -# percona\_user +# percona\_mysql\_user Manage users and grant them privileges on database objects. @@ -36,24 +36,24 @@ This property should be set to `false` if the user is local (host of `localhost` ```ruby # Create an user but grant no privileges -percona_user 'disenfranchised' do +percona_mysql_user 'disenfranchised' do password 'super_secret' action :create end # Create an user using a hashed password string instead of plain text one -percona_user 'disenfranchised' do +percona_mysql_user 'disenfranchised' do password hashed_password('md5eacdbf8d9847a76978bd515fae200a2a') action :create end # Drop a user -percona_user 'foo_user' do +percona_mysql_user 'foo_user' do action :drop end # Grant SELECT, UPDATE, and INSERT privileges to all tables in foo db from all hosts -percona_user 'foo_user' do +percona_mysql_user 'foo_user' do password 'super_secret' database_name 'foo' host '%' diff --git a/resources/database.rb b/resources/mysql_database.rb similarity index 99% rename from resources/database.rb rename to resources/mysql_database.rb index 8ea69823..0d15a1f3 100644 --- a/resources/database.rb +++ b/resources/mysql_database.rb @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -provides :percona_database +provides :percona_mysql_database include Percona::Cookbook::Helpers diff --git a/resources/user.rb b/resources/mysql_user.rb similarity index 99% rename from resources/user.rb rename to resources/mysql_user.rb index 11434ce9..5e4a75f4 100644 --- a/resources/user.rb +++ b/resources/mysql_user.rb @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -provides :percona_user +provides :percona_mysql_user include Percona::Cookbook::Helpers diff --git a/test/fixtures/cookbooks/test/recipes/user_database.rb b/test/fixtures/cookbooks/test/recipes/user_database.rb index 38f86075..62b154f0 100644 --- a/test/fixtures/cookbooks/test/recipes/user_database.rb +++ b/test/fixtures/cookbooks/test/recipes/user_database.rb @@ -66,33 +66,33 @@ end ## Resources we're testing -percona_database 'databass' do +percona_mysql_database 'databass' do action :create password '' end -percona_database 'datatrout' do +percona_mysql_database 'datatrout' do action :drop password '' end -percona_user 'piggy' do +percona_mysql_user 'piggy' do action :create ctrl_password '' end -percona_user 'kermit' do +percona_mysql_user 'kermit' do action :drop ctrl_password '' end -percona_user 'rowlf' do +percona_mysql_user 'rowlf' do password '123456' # hashed: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 ctrl_password '' action :create end -percona_user 'gonzo' do +percona_mysql_user 'gonzo' do password 'abcdef' ctrl_password '' host '10.10.10.%' @@ -100,7 +100,7 @@ end # create gonzo again to ensure the create action is idempotent -percona_user 'gonzo' do +percona_mysql_user 'gonzo' do password 'abcdef' ctrl_password '' host '10.10.10.%' @@ -109,13 +109,13 @@ hash = hashed_password('*2027D9391E714343187E07ACB41AE8925F30737E'); # 'l33t' -percona_user 'statler' do +percona_mysql_user 'statler' do password hash ctrl_password '' action :create end -percona_user 'fozzie' do +percona_mysql_user 'fozzie' do database_name 'databass' password 'wokkawokka' host 'mars' @@ -127,7 +127,7 @@ hash2 = hashed_password('*F798E7C0681068BAE3242AA2297D2360DBBDA62B'); # 'zokkazokka' -percona_user 'moozie' do +percona_mysql_user 'moozie' do database_name 'databass' password hash2 ctrl_password '' @@ -139,7 +139,7 @@ # all the grants exist ('Granting privs' should not show up), but the password is different # and should get updated -percona_user 'rizzo' do +percona_mysql_user 'rizzo' do database_name 'datasalmon' password 'salmon' ctrl_password '' @@ -152,7 +152,7 @@ # Should converge normally for all versions # Checks to insure SHA2 password algo works for percona 8 # with the host set to localhost -percona_user 'beaker' do +percona_mysql_user 'beaker' do password 'meep' host 'localhost' ctrl_password '' @@ -160,7 +160,7 @@ action :create end -percona_database 'flush privileges' do +percona_mysql_database 'flush privileges' do database_name 'databass' password '' sql 'flush privileges' From 1253acc5c8181823b727b6b4803de5e56e4690ef Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Fri, 2 Oct 2020 14:24:54 -0700 Subject: [PATCH 178/300] Fix documentation and naming conflicts Signed-off-by: Ethan Hampton --- .../resource_percona_mysql_database.md | 3 +- documentation/resource_percona_mysql_user.md | 3 +- libraries/hashed_passwords.rb | 43 ++++++++++--------- resources/mysql_database.rb | 1 + resources/mysql_user.rb | 3 +- .../cookbooks/test/recipes/user_database.rb | 2 +- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/documentation/resource_percona_mysql_database.md b/documentation/resource_percona_mysql_database.md index 48e093c1..52ac3155 100644 --- a/documentation/resource_percona_mysql_database.md +++ b/documentation/resource_percona_mysql_database.md @@ -1,6 +1,6 @@ # percona\_mysql\_database -Manage databases and execute SQL queries on them. It works by establishing a control connection to the Percona server using the percona client (be sure it is installed before using this resource). +Manage Percona MySQL databases and execute SQL queries on them. It works by establishing a control connection to the Percona server using the percona client (be sure it is installed before using this resource). ## Actions @@ -47,4 +47,3 @@ end ``` **The `query` action will NOT select a database before running the query, nor return the actual results from the SQL query.** - diff --git a/documentation/resource_percona_mysql_user.md b/documentation/resource_percona_mysql_user.md index 17cb1662..241fe760 100644 --- a/documentation/resource_percona_mysql_user.md +++ b/documentation/resource_percona_mysql_user.md @@ -1,6 +1,6 @@ # percona\_mysql\_user -Manage users and grant them privileges on database objects. +Manage Percona MySQL users and grant them privileges on database objects. ## Actions @@ -61,4 +61,3 @@ percona_mysql_user 'foo_user' do action :grant end ``` - diff --git a/libraries/hashed_passwords.rb b/libraries/hashed_passwords.rb index fd34b74e..2b725590 100644 --- a/libraries/hashed_passwords.rb +++ b/libraries/hashed_passwords.rb @@ -16,29 +16,30 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +module Percona + module Cookbook + class HashedPassword + # Initializes an object of the MysqlPassword type + # @param [String] hashed_password mysql native hashed password + # @return [MysqlPassword] + def initialize(hashed_password) + @hashed_password = hashed_password + end -class HashedPassword - # Initializes an object of the MysqlPassword type - # @param [String] hashed_password mysql native hashed password - # @return [MysqlPassword] - def initialize(hashed_password) - @hashed_password = hashed_password - end - - # String representation of the object - # @return [String] hashed password string - def to_s - @hashed_password - end + # String representation of the object + # @return [String] hashed password string + def to_s + @hashed_password + end - module Helper - # helper method wrappers the string into a MysqlPassword object - # @param [String] hashed_password mysql native hashed password - # @return [MysqlPassword] object - def hashed_password(hashed_password) - HashedPassword.new hashed_password + module Helper + # helper method wrappers the string into a MysqlPassword object + # @param [String] hashed_password mysql native hashed password + # @return [MysqlPassword] object + def hashed_password(hashed_password) + HashedPassword.new hashed_password + end + end end - # For backward compatibility, because method was renamed - alias_method :mysql_hashed_password, :hashed_password end end diff --git a/resources/mysql_database.rb b/resources/mysql_database.rb index 0d15a1f3..a7e804ff 100644 --- a/resources/mysql_database.rb +++ b/resources/mysql_database.rb @@ -17,6 +17,7 @@ provides :percona_mysql_database include Percona::Cookbook::Helpers +include Percona::Cookbook property :database_name, String, name_property: true property :host, [String, nil], default: 'localhost', desired_state: false diff --git a/resources/mysql_user.rb b/resources/mysql_user.rb index 5e4a75f4..392c65d0 100644 --- a/resources/mysql_user.rb +++ b/resources/mysql_user.rb @@ -17,9 +17,10 @@ provides :percona_mysql_user include Percona::Cookbook::Helpers +include Percona::Cookbook property :username, String, name_property: true -property :password, [String, HashedPassword, NilClass], default: nil, sensitive: true +property :password, [String, HashedPassword, NilClass], default: nil, sensitive: true property :host, String, default: 'localhost', desired_state: false property :database_name, String property :table, String diff --git a/test/fixtures/cookbooks/test/recipes/user_database.rb b/test/fixtures/cookbooks/test/recipes/user_database.rb index 62b154f0..289b23ce 100644 --- a/test/fixtures/cookbooks/test/recipes/user_database.rb +++ b/test/fixtures/cookbooks/test/recipes/user_database.rb @@ -1,4 +1,4 @@ -::Chef::DSL::Recipe.include HashedPassword::Helper +::Chef::DSL::Recipe.include Percona::Cookbook::HashedPassword::Helper node.default['percona']['skip_passwords'] = true node.default['percona']['server']['debian_username'] = 'root' From 5ae2ca3fcdc92151902af2b5ba35a8a37826ede8 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Thu, 8 Oct 2020 13:03:04 +0000 Subject: [PATCH 179/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .editorconfig | 10 +++++++++- .gitignore | 19 ++++++++++--------- .yamllint | 1 + 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.editorconfig b/.editorconfig index 1656a6d5..cc21b046 100755 --- a/.editorconfig +++ b/.editorconfig @@ -1,11 +1,19 @@ -#https://EditorConfig.org +# https://EditorConfig.org + # top-most EditorConfig file root=true +# Unix-style newlines with a newline ending every file [*] end_of_line = lf insert_final_newline = true + +# 2 space indentation indent_style = space indent_size = 2 + +# Avoid issues parsing cookbook files later charset = utf-8 + +# Avoid cookstyle warnings trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore index e085291b..be3b9a8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,7 @@ *.rbc .config -coverage InstalledFiles -lib/bundler/man pkg -rdoc -spec/reports test/tmp test/version_tmp tmp @@ -14,27 +10,32 @@ _Store *# .#* \#*# -.*.sw[a-z] *.un~ *.tmp *.bk *.bkup -# ruby/bundler files +# editor files +.idea +.*.sw[a-z] + +# ruby/bundler/rspec files .ruby-version .ruby-gemset .rvmrc Gemfile.lock .bundle *.gem +coverage +spec/reports -# YARD artifacts +# YARD / rdoc artifacts .yardoc _yardoc doc/ -.idea +rdoc -# chef stuff +# chef infra stuff Berksfile.lock .kitchen kitchen.local.yml diff --git a/.yamllint b/.yamllint index ecfdffb8..2d696128 100644 --- a/.yamllint +++ b/.yamllint @@ -4,3 +4,4 @@ rules: line-length: max: 256 level: warning + document-start: disable From 07f41fa8a23b26114702e06a10e40c4e26b5385b Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Fri, 23 Oct 2020 14:19:37 -0700 Subject: [PATCH 180/300] Release 2.0.0 Signed-off-by: Lance Albertson --- CHANGELOG.md | 2 +- metadata.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b470c359..4dfacd66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 2.0.0 - 2020-10-23 ### Added diff --git a/metadata.rb b/metadata.rb index dd8f877e..ef4a33bc 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '1.1.1' +version '2.0.0' chef_version '>= 13.0' depends 'openssl' From 9bb203af1f1c6f1d5805d31c36a8fc2f19ef0d0a Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Tue, 15 Dec 2020 11:10:40 -0800 Subject: [PATCH 181/300] Fix resource links in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cbfe1726..d8368c1d 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,8 @@ This cookbook requires Chef >= 13. ## Resources -- [`percona_mysql_user`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_user.md) -- [`percona_mysql_database`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_database.md) +- [`percona_mysql_user`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_mysql_user.md) +- [`percona_mysql_database`](https://github.com/sous-chefs/percona/blob/master/documentation/resource_percona_mysql_database.md) ## Usage From edfa860009b4384217cb26ccba28ce7b0ec85ff8 Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Tue, 15 Dec 2020 13:27:36 -0800 Subject: [PATCH 182/300] Update changelog Signed-off-by: Ethan Hampton --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dfacd66..8c035c36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + +- Fix links to resources in README + ## 2.0.0 - 2020-10-23 ### Added From 2db761873dbe45e2c91e79889a73fa25b537a804 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 15 Dec 2020 23:17:59 +0000 Subject: [PATCH 183/300] Update changelog for 2.0.1 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c035c36..82642edb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 2.0.1 - *2020-12-15* - Fix links to resources in README @@ -110,5 +110,5 @@ This file is used to list changes made in each version of the percona cookbook. - Many changes -[Unreleased]: https://github.com/sous-chefs/percona/compare/v0.16.1...HEAD +[2.0.1 - *2020-12-15*]: https://github.com/sous-chefs/percona/compare/v0.16.1...HEAD [0.16.1]: https://github.com/sous-chefs/percona/compare/v0.16.0...v0.16.1 From 456045545f91017cf60e75a300c85c907a22687d Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 15 Dec 2020 23:18:00 +0000 Subject: [PATCH 184/300] Update metadata for 2.0.1 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index ef4a33bc..e9cbaae9 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '2.0.0' +version '2.0.1' chef_version '>= 13.0' depends 'openssl' From cdaf5c1edb36e9129b0f06d8b659a5929c2f460f Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 15 Dec 2020 23:18:02 +0000 Subject: [PATCH 185/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82642edb..d0bc6624 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 2.0.1 - *2020-12-15* - Fix links to resources in README From 1979fd67dbd4279aaa0e1c7719a4ee7ec6f150c7 Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Fri, 8 Jan 2021 11:49:24 -0800 Subject: [PATCH 186/300] Fix user resource grant errors Signed-off-by: Ethan Hampton --- CHANGELOG.md | 2 ++ resources/mysql_user.rb | 5 ++++- test/fixtures/cookbooks/test/recipes/user_database.rb | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0bc6624..1a582d17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- Fix error when granting multiword privileges (ex. `REPLICATION CLIENT`) to users through `percona_mysql_user` + ## 2.0.1 - *2020-12-15* - Fix links to resources in README diff --git a/resources/mysql_user.rb b/resources/mysql_user.rb index 392c65d0..e9b730d2 100644 --- a/resources/mysql_user.rb +++ b/resources/mysql_user.rb @@ -259,7 +259,10 @@ def revokify_key(key) # Repair if incorrect_privs converge_by "Granting privs for '#{new_resource.username}'@'#{new_resource.host}'" do - repair_sql = "GRANT #{new_resource.privileges.join(',')}" + formatted_privileges = new_resource.privileges.map do |p| + p.to_s.upcase.tr('_', ' ').gsub('REPL ', 'REPLICATION ').gsub('CREATE TMP TABLE', 'CREATE TEMPORARY TABLES').gsub('SHOW DB', 'SHOW DATABASES') + end + repair_sql = "GRANT #{formatted_privileges.join(',')}" repair_sql << " ON #{db_name}.#{tbl_name}" repair_sql << " TO '#{new_resource.username}'@'#{new_resource.host}'" if database_has_password_column diff --git a/test/fixtures/cookbooks/test/recipes/user_database.rb b/test/fixtures/cookbooks/test/recipes/user_database.rb index 289b23ce..5936823f 100644 --- a/test/fixtures/cookbooks/test/recipes/user_database.rb +++ b/test/fixtures/cookbooks/test/recipes/user_database.rb @@ -115,6 +115,15 @@ action :create end +# test global permissions +percona_mysql_user 'camilla' do + password 'bokbokbok' + privileges [:select, :repl_client, :create_tmp_table, :show_db] + require_ssl true + ctrl_password '' + action [:create, :grant] +end + percona_mysql_user 'fozzie' do database_name 'databass' password 'wokkawokka' From 801b3fe1757c7affd7c9f3e2dec8f324d4f53cad Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Fri, 8 Jan 2021 11:55:41 -0800 Subject: [PATCH 187/300] Cookstyle fixes Signed-off-by: Ethan Hampton --- CHANGELOG.md | 2 +- libraries/passwords.rb | 2 +- recipes/configure_server.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a582d17..bc13cdce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased -- Fix error when granting multiword privileges (ex. `REPLICATION CLIENT`) to users through `percona_mysql_user` +- Fix error when granting multi-word privileges (ex. `REPLICATION CLIENT`) to users through `percona_mysql_user` ## 2.0.1 - *2020-12-15* diff --git a/libraries/passwords.rb b/libraries/passwords.rb index e9f35c08..14cc750f 100644 --- a/libraries/passwords.rb +++ b/libraries/passwords.rb @@ -20,7 +20,7 @@ def find_password(item, user, default = nil) # load password from the vault pwds = ChefVault::Item.load(bag, item) if vault # load the encrypted data bag item, using a secret if specified - pwds = Chef::EncryptedDataBagItem.load(@bag, item, secret) unless vault # rubocop:disable ChefModernize/DatabagHelpers + pwds = Chef::EncryptedDataBagItem.load(@bag, item, secret) unless vault # rubocop:disable Chef/Modernize/DatabagHelpers # now, let's look for the user password password = pwds[user] rescue diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index c304aa0f..024d391f 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -52,7 +52,7 @@ ipaddr = Percona::ConfigHelper.bind_to(node, server['bind_to']) if ipaddr && server['bind_address'] != ipaddr node.override['percona']['server']['bind_address'] = ipaddr - node.save unless Chef::Config[:solo] # rubocop:disable ChefCorrectness/CookbookUsesNodeSave + node.save unless Chef::Config[:solo] # rubocop:disable Chef/Correctness/CookbookUsesNodeSave end log "Can't find ip address for #{server['bind_to']}" do From dc69d51ef67c9e7d58f1613b7db0d5cd15aa0790 Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Thu, 14 Jan 2021 17:35:03 -0800 Subject: [PATCH 188/300] Remove support for Ubuntu 16.04 Signed-off-by: Ethan Hampton --- .github/workflows/ci.yml | 1 - CHANGELOG.md | 1 + README.md | 2 +- kitchen.dokken.yml | 7 ------- kitchen.yml | 1 - metadata.rb | 4 ++-- 6 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57d5a4c6..5508b49d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,6 @@ jobs: - 'centos-7' - 'centos-7-chef-13' - 'centos-8' - - 'ubuntu-1604' - 'ubuntu-1804' - 'ubuntu-1804-chef-13' - 'ubuntu-2004' diff --git a/CHANGELOG.md b/CHANGELOG.md index bc13cdce..f9a6ff85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased - Fix error when granting multi-word privileges (ex. `REPLICATION CLIENT`) to users through `percona_mysql_user` +- Remove support for Ubuntu 16.04 ## 2.0.1 - *2020-12-15* diff --git a/README.md b/README.md index d8368c1d..ffa3ca86 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ We provide an expanding set of tests against the following 64-bit platforms whic - CentOS 7+ - Debian 9+ -- Ubuntu 16.04+ LTS +- Ubuntu 18.04+ LTS ### Cookbooks diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 0d7c06c3..4975e814 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -51,13 +51,6 @@ platforms: image: dokken/centos-8 pid_one_command: /usr/lib/systemd/systemd - - name: ubuntu-16.04 - driver: - image: dokken/ubuntu-16.04 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - - name: ubuntu-18.04 driver: image: dokken/ubuntu-18.04 diff --git a/kitchen.yml b/kitchen.yml index 52883d50..120d7993 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -20,7 +20,6 @@ platforms: - name: centos-8 - name: debian-9 - name: debian-10 - - name: ubuntu-16.04 - name: ubuntu-18.04 - name: ubuntu-20.04 diff --git a/metadata.rb b/metadata.rb index e9cbaae9..b3e883b2 100644 --- a/metadata.rb +++ b/metadata.rb @@ -13,7 +13,7 @@ depends 'chef-vault' depends 'line' -supports 'centos' +supports 'centos', '>=7' supports 'debian' supports 'redhat' -supports 'ubuntu' +supports 'ubuntu', '>= 18.04' From caed87f3a3ec557a8bd3704b0d08d4364954d662 Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Thu, 14 Jan 2021 17:44:38 -0800 Subject: [PATCH 189/300] Fix metadata number format Signed-off-by: Ethan Hampton --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index b3e883b2..5920f4ca 100644 --- a/metadata.rb +++ b/metadata.rb @@ -13,7 +13,7 @@ depends 'chef-vault' depends 'line' -supports 'centos', '>=7' +supports 'centos', '>= 7.0' supports 'debian' supports 'redhat' supports 'ubuntu', '>= 18.04' From 9809564ba72b33ee89f079f0b14b2d60569aa8e0 Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Fri, 15 Jan 2021 12:55:42 -0800 Subject: [PATCH 190/300] Remove OS version requirements from metadata Signed-off-by: Ethan Hampton --- metadata.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata.rb b/metadata.rb index 5920f4ca..e9cbaae9 100644 --- a/metadata.rb +++ b/metadata.rb @@ -13,7 +13,7 @@ depends 'chef-vault' depends 'line' -supports 'centos', '>= 7.0' +supports 'centos' supports 'debian' supports 'redhat' -supports 'ubuntu', '>= 18.04' +supports 'ubuntu' From a2ae11c49c9f6962bc038ef21b996c1621c37a80 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 19 Jan 2021 21:16:08 +0000 Subject: [PATCH 191/300] Update changelog for 2.1.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9a6ff85..9c838c47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 2.1.0 - *2021-01-19* - Fix error when granting multi-word privileges (ex. `REPLICATION CLIENT`) to users through `percona_mysql_user` - Remove support for Ubuntu 16.04 From 55f2521b5397ad7434689113ec82b6931617aa7a Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 19 Jan 2021 21:16:09 +0000 Subject: [PATCH 192/300] Update metadata for 2.1.0 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index e9cbaae9..dff060d1 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '2.0.1' +version '2.1.0' chef_version '>= 13.0' depends 'openssl' From 291afe90fe7d0d577286fa3a45aee2cd13e3e517 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 19 Jan 2021 21:16:12 +0000 Subject: [PATCH 193/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c838c47..cec80d8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 2.1.0 - *2021-01-19* - Fix error when granting multi-word privileges (ex. `REPLICATION CLIENT`) to users through `percona_mysql_user` From fa5980ea99d1e7e4d4bb82f81b98fff2ec6290c3 Mon Sep 17 00:00:00 2001 From: Xorima Bot Date: Tue, 11 May 2021 14:55:41 +0000 Subject: [PATCH 194/300] Standardise files with files in sous-chefs/repo-management Signed-off-by: Xorima Bot --- .github/workflows/md-links.yml | 2 +- .github/workflows/stale.yml | 5 +---- .yamllint | 6 ++++++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/md-links.yml b/.github/workflows/md-links.yml index 150e75c6..d3a2e2b2 100644 --- a/.github/workflows/md-links.yml +++ b/.github/workflows/md-links.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@master + uses: actions/checkout@main - name: markdown-link-check uses: gaurav-nelson/github-action-markdown-link-check@v1 with: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 0f337015..9e2ff38e 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -2,14 +2,11 @@ name: Mark stale issues and pull requests "on": - schedule: - - cron: "0 0 * * *" + schedule: [cron: "0 0 * * *"] jobs: stale: - runs-on: ubuntu-latest - steps: - uses: actions/stale@v3 with: diff --git a/.yamllint b/.yamllint index 2d696128..1b5cea09 100644 --- a/.yamllint +++ b/.yamllint @@ -5,3 +5,9 @@ rules: max: 256 level: warning document-start: disable + braces: + forbid: false + min-spaces-inside: 0 + max-spaces-inside: 1 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 From a18af315aad2777efea8b1baa77d11f9424d5cf9 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 1 Jun 2021 13:58:16 +0100 Subject: [PATCH 195/300] Standardise files with files in sous-chefs/repo-management (#450) Signed-off-by: Dan Webb --- .delivery/project.toml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.delivery/project.toml b/.delivery/project.toml index 6d5e3617..0d6f0ae9 100644 --- a/.delivery/project.toml +++ b/.delivery/project.toml @@ -1 +1,9 @@ -remote_file = "https://raw.githubusercontent.com/chef-cookbooks/community_cookbook_tools/master/delivery/project.toml" +[local_phases] +unit = "rspec spec/" +lint = 'cookstyle --display-cop-names --extra-details' +syntax = "echo skipping" +provision = "echo skipping" +deploy = "echo skipping" +smoke = "echo skipping" +functional = "echo skipping" +cleanup = "echo skipping" From 401f55e2686bf98ba2a5c01a3519343ef2bb9a8b Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 1 Jun 2021 05:58:19 -0700 Subject: [PATCH 196/300] Update changelog for 2.1.1 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cec80d8f..ca84621d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 2.1.1 - *2021-06-01* ## 2.1.0 - *2021-01-19* From 3df8a6061f519c27bbf54e59f1f1c336f5052022 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 1 Jun 2021 05:58:19 -0700 Subject: [PATCH 197/300] Update metadata for 2.1.1 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index dff060d1..2d57d1b3 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '2.1.0' +version '2.1.1' chef_version '>= 13.0' depends 'openssl' From 6e9d276cde44e96d2e848501d1fd656edc0496f8 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 1 Jun 2021 05:58:21 -0700 Subject: [PATCH 198/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca84621d..3a857f5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 2.1.1 - *2021-06-01* ## 2.1.0 - *2021-01-19* From 8ac19d6371241de6558714ab7d161e47df2246f4 Mon Sep 17 00:00:00 2001 From: Jason Field Date: Wed, 16 Jun 2021 17:32:22 +0100 Subject: [PATCH 199/300] prep for main --- .github/ISSUE_TEMPLATE.md | 20 -------------------- .github/PULL_REQUEST_TEMPLATE.md | 13 ------------- .github/workflows/ci.yml | 29 +++++++++++------------------ .github/workflows/md-links.yml | 4 ++-- 4 files changed, 13 insertions(+), 53 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 651e753a..00000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,20 +0,0 @@ -### Cookbook version -[Version of the cookbook where you are encountering the issue] - -### Chef-client version -[Version of chef-client in your environment] - -### Platform Details -[Operating system distribution and release version. Cloud provider if running in the cloud] - -### Scenario: -[What you are trying to achieve and you can't?] - -### Steps to Reproduce: -[If you are filing an issue what are the things we need to do in order to repro your problem? How are you using this cookbook or any resources it includes?] - -### Expected Result: -[What are you expecting to happen as the consequence of above reproduction steps?] - -### Actual Result: -[What actually happens after the reproduction steps? Include the error output or a link to a gist if possible.] diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bce1ae57..00000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,13 +0,0 @@ -### Description - -[Describe what this change achieves] - -### Issues Resolved - -[List any existing issues this PR resolves] - -### Contribution Check List - -- [ ] All tests pass. -- [ ] New functionality includes testing. -- [ ] New functionality has been documented in the README if applicable \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5508b49d..9cf16f00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,16 +5,16 @@ name: ci pull_request: push: branches: - - master + - main jobs: delivery: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@master + uses: actions/checkout@v2 - name: Run Chef Delivery - uses: actionshub/chef-delivery@master + uses: actionshub/chef-delivery@main env: CHEF_LICENSE: accept-no-persist @@ -22,19 +22,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@master + uses: actions/checkout@v2 - name: Run yaml Lint - uses: actionshub/yamllint@master + uses: actionshub/yamllint@main mdl: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@master + uses: actions/checkout@v2 - name: Run Markdown Lint - uses: actionshub/markdownlint@master + uses: actionshub/markdownlint@main - dokken: + integration: needs: [mdl, yamllint, delivery] runs-on: ubuntu-latest strategy: @@ -109,9 +109,9 @@ jobs: steps: - name: Check out code - uses: actions/checkout@master + uses: actions/checkout@v2 - name: Install Chef - uses: actionshub/chef-install@master + uses: actionshub/chef-install@main # https://github.com/actions/virtual-environments/issues/181#issuecomment-610874237 - name: Disable apparmor for mysqld run: | @@ -120,7 +120,7 @@ jobs: sudo apt-get -y install apparmor-profiles sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld - name: Dokken - uses: actionshub/kitchen-dokken@master + uses: actionshub/test-kitchen@main env: CHEF_LICENSE: accept-no-persist KITCHEN_LOCAL_YAML: kitchen.dokken.yml @@ -135,10 +135,3 @@ jobs: sudo docker version sudo docker info KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "journalctl -l" - - final: - needs: [dokken] - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@master diff --git a/.github/workflows/md-links.yml b/.github/workflows/md-links.yml index d3a2e2b2..ba887a16 100644 --- a/.github/workflows/md-links.yml +++ b/.github/workflows/md-links.yml @@ -4,14 +4,14 @@ name: md-links "on": pull_request: push: - branches: [master] + branches: [main] jobs: md-links: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@main + uses: actions/checkout@v2 - name: markdown-link-check uses: gaurav-nelson/github-action-markdown-link-check@v1 with: From 9cb25bee8108af15ce70c16a7b46865e577759b5 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 30 Aug 2021 07:45:03 +0100 Subject: [PATCH 200/300] Automated PR: Standardising Files (#451) * Standardise files with files in sous-chefs/repo-management Signed-off-by: kitchen-porter * Fix changelog Signed-off-by: Lance Albertson Co-authored-by: Lance Albertson --- .github/CODEOWNERS | 2 +- CHANGELOG.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c652e311..7cc52a97 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @sous-chefs/percona +* @sous-chefs/maintainers diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a857f5d..21f6ce55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,12 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- Standardise files with files in sous-chefs/repo-management + ## 2.1.1 - *2021-06-01* +- Standardise files with files in sous-chefs/repo-management + ## 2.1.0 - *2021-01-19* - Fix error when granting multi-word privileges (ex. `REPLICATION CLIENT`) to users through `percona_mysql_user` From 9b9d438f4e99077680525501e29aa563a67d58e1 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 30 Aug 2021 07:45:06 +0100 Subject: [PATCH 201/300] Update changelog for 2.1.2 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21f6ce55..2b901359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 2.1.2 - *2021-08-30* - Standardise files with files in sous-chefs/repo-management From 261f9d15da850f75ef123c4e5f1c2ea74d0ce9b9 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 30 Aug 2021 07:45:06 +0100 Subject: [PATCH 202/300] Update metadata for 2.1.2 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 2d57d1b3..dd1b71f0 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '2.1.1' +version '2.1.2' chef_version '>= 13.0' depends 'openssl' From b7df7562d2f82acbb59876cb6f0ca8f409cc1d37 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 30 Aug 2021 07:45:08 +0100 Subject: [PATCH 203/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b901359..e914ce4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 2.1.2 - *2021-08-30* - Standardise files with files in sous-chefs/repo-management From 1ece28b4bbe128bc3a9938aa08ba4db7386d578c Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Fri, 17 Sep 2021 08:42:45 -0700 Subject: [PATCH 204/300] Chef 17 updates (#448) * Chef 17 updates - Chef 17 updates: enable `unified_mode` on all resources - Remove dependency on openssl cookbook and create `percona_secure_random` method to replace that functionality Signed-off-by: Lance Albertson * Remove Chef 13 testing Signed-off-by: Lance Albertson * Remove dependency on chef-vault cookbook and require Chef >= 16 Signed-off-by: Lance Albertson * Use full gpg key id for apt repos and switch to using keyserver.ubuntu.com Signed-off-by: Lance Albertson * Use an empty password for testing Signed-off-by: Lance Albertson * Move mysql dnf module disabling to before yum repos Without doing this first, the package is not seen by Chef for some reason. Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 3 --- CHANGELOG.md | 6 +++++ README.md | 4 +--- attributes/default.rb | 10 ++++----- attributes/package_repo.rb | 4 ++-- kitchen.dokken.yml | 22 ------------------- libraries/helpers.rb | 6 +++++ metadata.rb | 4 +--- recipes/configure_server.rb | 3 --- recipes/package_repo.rb | 10 ++++----- resources/mysql_database.rb | 1 + resources/mysql_user.rb | 1 + spec/configure_server_spec.rb | 8 ++----- spec/package_repo_spec.rb | 8 +++---- .../inspec/controls/resources_spec.rb | 4 ++-- 15 files changed, 35 insertions(+), 59 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cf16f00..e367b615 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,13 +41,10 @@ jobs: matrix: os: - 'debian-9' - - 'debian-9-chef-13' - 'debian-10' - 'centos-7' - - 'centos-7-chef-13' - 'centos-8' - 'ubuntu-1804' - - 'ubuntu-1804-chef-13' - 'ubuntu-2004' suite: - 'client-56' diff --git a/CHANGELOG.md b/CHANGELOG.md index e914ce4d..8c921d19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- Chef 17 updates: enable `unified_mode` on all resources +- Remove dependency on openssl cookbook and create `percona_secure_random` method to replace that functionality +- Remove dependency on chef-vault cookbook and require Chef >= 16 +- Use full gpg key id for apt repos and switch to using keyserver.ubuntu.com +- Move mysql dnf module disabling to before yum repos + ## 2.1.2 - *2021-08-30* - Standardise files with files in sous-chefs/repo-management diff --git a/README.md b/README.md index ffa3ca86..ffc3761a 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,12 @@ We provide an expanding set of tests against the following 64-bit platforms whic ### Cookbooks -- [openssl](https://supermarket.chef.io/cookbooks/openssl) - [yum-epel](https://supermarket.chef.io/cookbooks/yum-epel) -- [chef-vault](https://supermarket.chef.io/cookbooks/chef-vault) - [line](https://supermarket.chef.io/cookbooks/line) ### Chef -This cookbook requires Chef >= 13. +This cookbook requires Chef >= 16. ## Recipes diff --git a/attributes/default.rb b/attributes/default.rb index eb9a5fc6..fff8dd77 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -3,10 +3,8 @@ # Attributes:: default # -# include the openssl cookbook password library -if defined?(::OpenSSLCookbook::RandomPassword) - ::Chef::Node.include ::OpenSSLCookbook::RandomPassword -end +# include the percona_secure_random method +::Chef::Node.include ::Percona::Cookbook::Helpers default['percona']['version'] = '8.0' @@ -83,7 +81,7 @@ %w(debian_password root_password).each do |attribute| next if attribute?(node['percona']['server'][attribute]) - default['percona']['server'][attribute] = random_password + default['percona']['server'][attribute] = percona_secure_random end # Fine Tuning @@ -201,7 +199,7 @@ default['percona']['backup']['configure'] = false default['percona']['backup']['username'] = 'backup' unless attribute?(node['percona']['backup']['password']) - default['percona']['backup']['password'] = random_password + default['percona']['backup']['password'] = percona_secure_random end # XtraDB Cluster Settings diff --git a/attributes/package_repo.rb b/attributes/package_repo.rb index c2245223..3956f25f 100644 --- a/attributes/package_repo.rb +++ b/attributes/package_repo.rb @@ -7,8 +7,8 @@ # From 8.0 onward, Percona has split up each product into individual repositories # See https://www.percona.com/doc/percona-repo-config/index.html for more information default['percona']['repositories'] = %w(ps-80) -default['percona']['apt']['key'] = '8507EFA5' -default['percona']['apt']['keyserver'] = 'hkp://keys.gnupg.net:80' +default['percona']['apt']['key'] = '9334A25F8507EFA5' +default['percona']['apt']['keyserver'] = 'keyserver.ubuntu.com' default['percona']['apt']['uri'] = 'http://repo.percona.com/apt' default['percona']['yum']['description'] = 'Percona Packages' default['percona']['yum']['baseurl'] = 'http://repo.percona.com/yum/release/$releasever/RPMS' diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 4975e814..fab60aa8 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -20,14 +20,6 @@ platforms: intermediate_instructions: - RUN /usr/bin/apt-get update - - name: debian-9-chef-13 - driver: - image: dokken/debian-9 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - chef_version: 13 - - name: debian-10 driver: image: dokken/debian-10 @@ -40,12 +32,6 @@ platforms: image: dokken/centos-7 pid_one_command: /usr/lib/systemd/systemd - - name: centos-7-chef-13 - driver: - image: dokken/centos-7 - pid_one_command: /usr/lib/systemd/systemd - chef_version: 13 - - name: centos-8 driver: image: dokken/centos-8 @@ -58,14 +44,6 @@ platforms: intermediate_instructions: - RUN /usr/bin/apt-get update - - name: ubuntu-18.04-chef-13 - driver: - image: dokken/ubuntu-18.04 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - chef_version: 13 - - name: ubuntu-20.04 driver: image: dokken/ubuntu-20.04 diff --git a/libraries/helpers.rb b/libraries/helpers.rb index cf32589d..d95fa17b 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -205,6 +205,12 @@ def default_socket '/var/run/mysqld/mysqld.sock' end end + + def percona_secure_random + r = SecureRandom.hex + Chef::Log.debug "Generated password: #{r}" + r + end end end end diff --git a/metadata.rb b/metadata.rb index dd1b71f0..676babb5 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,11 +6,9 @@ source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' version '2.1.2' -chef_version '>= 13.0' +chef_version '>= 16.0' -depends 'openssl' depends 'yum-epel' -depends 'chef-vault' depends 'line' supports 'centos' diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 024d391f..829d37c4 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -28,9 +28,6 @@ end end -# install chef-vault if needed -include_recipe 'chef-vault' if node['percona']['use_chef_vault'] - # construct an encrypted passwords helper -- giving it the node and bag name passwords = EncryptedPasswords.new(node, percona['encrypted_data_bag']) diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index 0cabfe48..2ec7bba7 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -33,6 +33,11 @@ end when 'rhel' + execute 'dnf -y module disable mysql' do + only_if { node['platform_version'].to_i >= 8 } + not_if 'dnf module list mysql | grep -q "^mysql.*\[x\]"' + end + yum_repository 'percona' do description node['percona']['yum']['description'] baseurl "#{node['percona']['yum']['baseurl']}/$basearch" @@ -60,9 +65,4 @@ gpgcheck node['percona']['yum']['gpgcheck'] sslverify node['percona']['yum']['sslverify'] end - - execute 'dnf -y module disable mysql' do - only_if { node['platform_version'].to_i >= 8 } - not_if 'dnf module list mysql | grep -q "^mysql.*\[x\]"' - end end diff --git a/resources/mysql_database.rb b/resources/mysql_database.rb index a7e804ff..d958ce2f 100644 --- a/resources/mysql_database.rb +++ b/resources/mysql_database.rb @@ -15,6 +15,7 @@ # limitations under the License. # provides :percona_mysql_database +unified_mode true include Percona::Cookbook::Helpers include Percona::Cookbook diff --git a/resources/mysql_user.rb b/resources/mysql_user.rb index e9b730d2..936fcbeb 100644 --- a/resources/mysql_user.rb +++ b/resources/mysql_user.rb @@ -15,6 +15,7 @@ # limitations under the License. # provides :percona_mysql_user +unified_mode true include Percona::Cookbook::Helpers include Percona::Cookbook diff --git a/spec/configure_server_spec.rb b/spec/configure_server_spec.rb index 3bb81521..e693ae33 100644 --- a/spec/configure_server_spec.rb +++ b/spec/configure_server_spec.rb @@ -27,10 +27,6 @@ end end - it 'does not include the `chef-vault` recipe' do - expect(chef_run).to_not include_recipe 'chef-vault' - end - it 'creates the main server config file' do expect(chef_run).to create_template('/etc/mysql/my.cnf').with( owner: 'root', @@ -361,8 +357,8 @@ stub_command("mysqladmin --user=root --password='' version").and_return(false) end - it 'includes the `chef-vault` recipe' do - expect(chef_run).to include_recipe 'chef-vault' + it 'converges successfully' do + expect { chef_run }.to_not raise_error end end end diff --git a/spec/package_repo_spec.rb b/spec/package_repo_spec.rb index 26b76427..9a691878 100644 --- a/spec/package_repo_spec.rb +++ b/spec/package_repo_spec.rb @@ -12,8 +12,8 @@ expect(chef_run).to add_apt_repository('percona').with( uri: 'http://repo.percona.com/apt', components: %w(main), - keyserver: 'hkp://keys.gnupg.net:80', - key: %w(8507EFA5) + keyserver: 'keyserver.ubuntu.com', + key: %w(9334A25F8507EFA5) ) end @@ -29,8 +29,8 @@ expect(chef_run).to add_apt_repository('percona-ps-80').with( uri: 'http://repo.percona.com/ps-80/apt', components: %w(main), - keyserver: 'hkp://keys.gnupg.net:80', - key: %w(8507EFA5) + keyserver: 'keyserver.ubuntu.com', + key: %w(9334A25F8507EFA5) ) end diff --git a/test/integration/inspec/controls/resources_spec.rb b/test/integration/inspec/controls/resources_spec.rb index 905a300f..a57cb13a 100644 --- a/test/integration/inspec/controls/resources_spec.rb +++ b/test/integration/inspec/controls/resources_spec.rb @@ -2,7 +2,7 @@ impact 1.0 title 'test creation and removal of databases' - sql = mysql_session('root') + sql = mysql_session('root', '') describe sql.query('show databases') do its(:stdout) { should match(/databass/) } @@ -17,7 +17,7 @@ version = input('version') password_column = version.to_f >= 5.7 ? 'authentication_string' : 'password' - sql = mysql_session('root') + sql = mysql_session('root', '') describe sql.query('select User,Host from mysql.user') do its(:stdout) { should match(/fozzie/) } From 26971c387f0fa32e217ea998e905068b43f24969 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:42:48 +0100 Subject: [PATCH 205/300] Update changelog for 3.0.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c921d19..59098e1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.0.0 - *2021-09-17* - Chef 17 updates: enable `unified_mode` on all resources - Remove dependency on openssl cookbook and create `percona_secure_random` method to replace that functionality From 0c4846bde2e9ccbce920927d256e49e397a66f58 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:42:49 +0100 Subject: [PATCH 206/300] Update metadata for 3.0.0 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 676babb5..20ca7f00 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '2.1.2' +version '3.0.0' chef_version '>= 16.0' depends 'yum-epel' From a475415b3f263deb95fc82c21cc35eb556827ee0 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Fri, 17 Sep 2021 16:42:51 +0100 Subject: [PATCH 207/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59098e1a..6d74b9bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.0.0 - *2021-09-17* - Chef 17 updates: enable `unified_mode` on all resources From 097dc060324e0af181c8ce120534567a226824b3 Mon Sep 17 00:00:00 2001 From: Robert Detjens Date: Mon, 4 Oct 2021 13:54:08 -0700 Subject: [PATCH 208/300] Use dnf_module from yum cookbook instead of manually disabling (#453) Signed-off-by: Robert Detjens --- CHANGELOG.md | 2 ++ kitchen.dokken.yml | 4 ++-- metadata.rb | 1 + recipes/package_repo.rb | 4 ++-- spec/package_repo_spec.rb | 8 ++++---- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d74b9bb..250abc9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- Use `dnf_module` resource from `yum` cookbook instead of manually disabling module + ## 3.0.0 - *2021-09-17* - Chef 17 updates: enable `unified_mode` on all resources diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index fab60aa8..4d7c8657 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -3,14 +3,14 @@ driver: name: dokken # because Docker and SystemD/Upstart privileged: true - chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> - env: [CHEF_LICENSE=accept] transport: name: dokken provisioner: name: dokken + chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> + chef_license: accept-no-persist platforms: - name: debian-9 diff --git a/metadata.rb b/metadata.rb index 20ca7f00..75f162a9 100644 --- a/metadata.rb +++ b/metadata.rb @@ -8,6 +8,7 @@ version '3.0.0' chef_version '>= 16.0' +depends 'yum' depends 'yum-epel' depends 'line' diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index 2ec7bba7..7b83eb08 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -33,9 +33,9 @@ end when 'rhel' - execute 'dnf -y module disable mysql' do + dnf_module 'mysql' do + action :disable only_if { node['platform_version'].to_i >= 8 } - not_if 'dnf module list mysql | grep -q "^mysql.*\[x\]"' end yum_repository 'percona' do diff --git a/spec/package_repo_spec.rb b/spec/package_repo_spec.rb index 9a691878..ac68c2b8 100644 --- a/spec/package_repo_spec.rb +++ b/spec/package_repo_spec.rb @@ -1,10 +1,6 @@ require 'spec_helper' describe 'percona::package_repo' do - before do - stub_command('dnf module list mysql | grep -q "^mysql.*\\[x\\]"') - end - context 'ubuntu' do platform 'ubuntu' @@ -46,6 +42,10 @@ context 'centos' do platform 'centos' + it do + expect(chef_run).to disable_dnf_module('mysql') + end + it do expect(chef_run).to create_yum_repository('percona').with( description: 'Percona Packages', From 7ca008d3710da3c028a8b77e88e9c5c36ddfe2f7 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 4 Oct 2021 21:54:10 +0100 Subject: [PATCH 209/300] Update changelog for 3.1.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 250abc9d..2dcf2a94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.1.0 - *2021-10-04* - Use `dnf_module` resource from `yum` cookbook instead of manually disabling module From d079c6e297d9d8b67f95f7ba9ad5f23b31a454b8 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 4 Oct 2021 21:54:11 +0100 Subject: [PATCH 210/300] Update metadata for 3.1.0 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 75f162a9..c85f3a10 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.0.0' +version '3.1.0' chef_version '>= 16.0' depends 'yum' From 378b3577c8d84f35a7c70ff1f0bd5d4c612b003d Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 4 Oct 2021 21:54:12 +0100 Subject: [PATCH 211/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dcf2a94..3126922f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.1.0 - *2021-10-04* - Use `dnf_module` resource from `yum` cookbook instead of manually disabling module From fe4e365a1be90f378fdf52f0e3ec5bf997be1c27 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 4 Jan 2022 01:23:00 +0200 Subject: [PATCH 212/300] change root pw for version >= 5.7 (#455) * change root pw for version >= 5.7 * Add changelog Signed-off-by: Lance Albertson Co-authored-by: tdv_wz Co-authored-by: Lance Albertson --- CHANGELOG.md | 2 ++ recipes/configure_server.rb | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3126922f..266fa30c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- Fix root password setting for version >= 5.7 + ## 3.1.0 - *2021-10-04* - Use `dnf_module` resource from `yum` cookbook instead of manually disabling module diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 829d37c4..0e797516 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -170,7 +170,11 @@ root_pw = passwords.root_password execute 'Update MySQL root password' do - command "mysqladmin --user=root --password='' password '#{root_pw}'" + if node['percona']['version'].to_f < 5.7 + command "mysqladmin --user=root --password='' password '#{root_pw}'" + else + command "mysql --user=root --password='' -e \"ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '#{root_pw}';\"" + end only_if "mysqladmin --user=root --password='' version" sensitive true end From 50eca1cf03e851074558e94ad478c4d0f00ab825 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:23:03 -0800 Subject: [PATCH 213/300] Update changelog for 3.1.1 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 266fa30c..6a2efcb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.1.1 - *2022-01-03* - Fix root password setting for version >= 5.7 From 09ecf33fdad68c7e438d2cc5475191c997889ff4 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:23:03 -0800 Subject: [PATCH 214/300] Update metadata for 3.1.1 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index c85f3a10..8c21e56f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.1.0' +version '3.1.1' chef_version '>= 16.0' depends 'yum' From a208468e2484a947f52af3f4567c911b847a81db Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:23:05 -0800 Subject: [PATCH 215/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a2efcb0..a1026497 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.1.1 - *2022-01-03* - Fix root password setting for version >= 5.7 From 6b702b640dba631a1776e18989e71482dc478ffe Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 8 Feb 2022 17:13:24 +0000 Subject: [PATCH 216/300] Standardise files with files in sous-chefs/repo-management (#457) Signed-off-by: Dan Webb --- .delivery/project.toml | 9 --------- CHANGELOG.md | 2 ++ 2 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 .delivery/project.toml diff --git a/.delivery/project.toml b/.delivery/project.toml deleted file mode 100644 index 0d6f0ae9..00000000 --- a/.delivery/project.toml +++ /dev/null @@ -1,9 +0,0 @@ -[local_phases] -unit = "rspec spec/" -lint = 'cookstyle --display-cop-names --extra-details' -syntax = "echo skipping" -provision = "echo skipping" -deploy = "echo skipping" -smoke = "echo skipping" -functional = "echo skipping" -cleanup = "echo skipping" diff --git a/CHANGELOG.md b/CHANGELOG.md index a1026497..bf6f6c38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- Remove delivery folder + ## 3.1.1 - *2022-01-03* - Fix root password setting for version >= 5.7 From a368de6b0e82e763f949b09acc5c4cbfc0014e4a Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 8 Feb 2022 09:13:27 -0800 Subject: [PATCH 217/300] Update changelog for 3.1.2 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf6f6c38..26d5185f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.1.2 - *2022-02-08* - Remove delivery folder From dba74b04ed501fcd63b41a3bfbd8949f2d3e696b Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 8 Feb 2022 09:13:27 -0800 Subject: [PATCH 218/300] Update metadata for 3.1.2 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 8c21e56f..a774cb7e 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.1.1' +version '3.1.2' chef_version '>= 16.0' depends 'yum' From 0e46aac83dcd656c9261569f65ae7d357f5c20ec Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 8 Feb 2022 09:13:29 -0800 Subject: [PATCH 219/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26d5185f..59993640 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.1.2 - *2022-02-08* - Remove delivery folder From 9554c1c421ed902b7259b381d9e3b140dc1171d4 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 17 Feb 2022 02:32:51 -0800 Subject: [PATCH 220/300] Standardise files with files in sous-chefs/repo-management (#456) Signed-off-by: kitchen-porter Co-authored-by: Dan Webb --- .overcommit.yml | 4 ---- CHANGELOG.md | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.overcommit.yml b/.overcommit.yml index 1d27ed8d..cd8682a0 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -11,10 +11,6 @@ PreCommit: enabled: true required_executable: 'cookstyle' command: ["cookstyle"] - Delivery: - enabled: true - required_executable: 'delivery' - flags: ['local', 'all'] CommitMsg: HardTabs: enabled: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 59993640..1fd3ab9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- Standardise files with files in sous-chefs/repo-management + ## 3.1.2 - *2022-02-08* - Remove delivery folder From 9bbf9f6e2ed563b94bf1a9b119102c9799862e69 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 17 Feb 2022 02:32:54 -0800 Subject: [PATCH 221/300] Update changelog for 3.1.3 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fd3ab9d..231fb933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.1.3 - *2022-02-17* - Standardise files with files in sous-chefs/repo-management From 7ef38de01816deda446752d6825f138c120e1ee9 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 17 Feb 2022 02:32:54 -0800 Subject: [PATCH 222/300] Update metadata for 3.1.3 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index a774cb7e..c7c32e03 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.1.2' +version '3.1.3' chef_version '>= 16.0' depends 'yum' From 765d4d2968105670c042602a7920172142fcf1bf Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 17 Feb 2022 02:32:56 -0800 Subject: [PATCH 223/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 231fb933..30c86a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.1.3 - *2022-02-17* - Standardise files with files in sous-chefs/repo-management From a272f5ff741634b9fd3645fa4d2a71e3cf6e1b61 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Thu, 18 Aug 2022 07:51:53 -0700 Subject: [PATCH 224/300] Remove myisam_repair_threads for < 5.7 as it's been deprecated (#458) - https://docs.percona.com/percona-server/5.7/release-notes/Percona-Server-5.7.39-42.html#deprecation-and-removal - https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_myisam_repair_threads In addition: - Remove delivery and move to calling RSpec directly via a reusable workflow - Update tested platforms - Add support to Alma Linux & Rocky Linux - Update default encoding when using 8.0 to `utf8mb3` to fix idempotency issues - Fix management of server `my.cnf` - Set `manage_symlink_source` to `false` and set `force_unlink` to `true` to fix idempotency on Debian based systems - Fix issue when testing on Debian dokken images by removing mailutils (and thus mysql-common) Signed-off-by: Lance Albertson Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 133 ++++++++++-------- CHANGELOG.md | 9 ++ README.md | 2 +- kitchen.dokken.yml | 34 ++--- kitchen.yml | 42 ++++-- libraries/helpers.rb | 12 +- recipes/configure_server.rb | 3 +- resources/mysql_database.rb | 2 +- spec/configure_server_spec.rb | 11 +- templates/my.cnf.cluster.erb | 2 +- templates/my.cnf.main.erb | 2 +- .../test/recipes/_remove_mysql_common.rb | 11 ++ .../cookbooks/test/recipes/cluster.rb | 1 + .../fixtures/cookbooks/test/recipes/server.rb | 1 + .../cookbooks/test/recipes/user_database.rb | 1 + 15 files changed, 172 insertions(+), 94 deletions(-) create mode 100644 test/fixtures/cookbooks/test/recipes/_remove_mysql_common.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e367b615..4f60139d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,75 +8,72 @@ name: ci - main jobs: - delivery: - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - name: Run Chef Delivery - uses: actionshub/chef-delivery@main - env: - CHEF_LICENSE: accept-no-persist - - yamllint: - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - name: Run yaml Lint - uses: actionshub/yamllint@main - - mdl: - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - name: Run Markdown Lint - uses: actionshub/markdownlint@main + lint-unit: + uses: sous-chefs/.github/.github/workflows/lint-unit.yml@0.0.3 + permissions: + actions: write + checks: write + pull-requests: write + statuses: write + issues: write integration: - needs: [mdl, yamllint, delivery] + needs: lint-unit runs-on: ubuntu-latest strategy: matrix: os: - - 'debian-9' - - 'debian-10' - - 'centos-7' - - 'centos-8' - - 'ubuntu-1804' - - 'ubuntu-2004' + - almalinux-8 + - centos-7 + - centos-stream-8 + - debian-10 + - debian-11 + - rockylinux-8 + - ubuntu-1804 + - ubuntu-2004 suite: - - 'client-56' - - 'client-57' - - 'client-80' - - 'devel-56' - - 'devel-57' - - 'devel-80' - - 'server-56' - - 'server-57' - - 'server-80' - - 'source-56' - - 'source-57' - - 'source-80' - - 'replication-56' - - 'replication-57' - - 'replication-80' - - 'resources-56' - - 'resources-57' - - 'resources-80' + - client-56 + - client-57 + - client-80 + - devel-56 + - devel-57 + - devel-80 + - server-56 + - server-57 + - server-80 + - source-56 + - source-57 + - source-80 + - replication-56 + - replication-57 + - replication-80 + - resources-56 + - resources-57 + - resources-80 exclude: - - os: centos-8 + - os: almalinux-8 + suite: client-56 + - os: almalinux-8 + suite: devel-56 + - os: almalinux-8 + suite: server-56 + - os: almalinux-8 + suite: source-56 + - os: almalinux-8 + suite: replication-56 + - os: almalinux-8 + suite: resources-56 + - os: centos-stream-8 suite: client-56 - - os: centos-8 + - os: centos-stream-8 suite: devel-56 - - os: centos-8 + - os: centos-stream-8 suite: server-56 - - os: centos-8 + - os: centos-stream-8 suite: source-56 - - os: centos-8 + - os: centos-stream-8 suite: replication-56 - - os: centos-8 + - os: centos-stream-8 suite: resources-56 - os: debian-10 suite: client-56 @@ -90,6 +87,30 @@ jobs: suite: replication-56 - os: debian-10 suite: resources-56 + - os: debian-11 + suite: client-56 + - os: debian-11 + suite: devel-56 + - os: debian-11 + suite: server-56 + - os: debian-11 + suite: source-56 + - os: debian-11 + suite: replication-56 + - os: debian-11 + suite: resources-56 + - os: rockylinux-8 + suite: client-56 + - os: rockylinux-8 + suite: devel-56 + - os: rockylinux-8 + suite: server-56 + - os: rockylinux-8 + suite: source-56 + - os: rockylinux-8 + suite: replication-56 + - os: rockylinux-8 + suite: resources-56 - os: ubuntu-2004 suite: client-56 - os: ubuntu-2004 diff --git a/CHANGELOG.md b/CHANGELOG.md index 30c86a7b..7ef1989e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- Remove `myisam_repair_threads` for < 5.7 as it's been deprecated +- Remove delivery and move to calling RSpec directly via a reusable workflow +- Update tested platforms +- Add support to Alma Linux & Rocky Linux +- Update default encoding when using 8.0 to `utf8mb3` to fix idempotency issues +- Fix management of server `my.cnf` + - Set `manage_symlink_source` to `false` and set `force_unlink` to `true` to fix idempotency on Debian based systems +- Fix issue when testing on Debian dokken images by removing mailutils (and thus mysql-common) + ## 3.1.3 - *2022-02-17* - Standardise files with files in sous-chefs/repo-management diff --git a/README.md b/README.md index ffc3761a..e198f4ba 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of We provide an expanding set of tests against the following 64-bit platforms which match what upstream supports: - CentOS 7+ -- Debian 9+ +- Debian 10+ - Ubuntu 18.04+ LTS ### Cookbooks diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 4d7c8657..d1ea94e8 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -13,40 +13,42 @@ provisioner: chef_license: accept-no-persist platforms: - - name: debian-9 + - name: almalinux-8 driver: - image: dokken/debian-9 - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update + image: dokken/almalinux-8 + pid_one_command: /usr/lib/systemd/systemd + + - name: centos-7 + driver: + image: dokken/centos-7 + pid_one_command: /usr/lib/systemd/systemd + + - name: centos-stream-8 + driver: + image: dokken/centos-stream-8 + pid_one_command: /usr/lib/systemd/systemd - name: debian-10 driver: image: dokken/debian-10 pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - - name: centos-7 + - name: debian-11 driver: - image: dokken/centos-7 - pid_one_command: /usr/lib/systemd/systemd + image: dokken/debian-11 + pid_one_command: /bin/systemd - - name: centos-8 + - name: rockylinux-8 driver: - image: dokken/centos-8 + image: dokken/rockylinux-8 pid_one_command: /usr/lib/systemd/systemd - name: ubuntu-18.04 driver: image: dokken/ubuntu-18.04 pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update - name: ubuntu-20.04 driver: image: dokken/ubuntu-20.04 pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update diff --git a/kitchen.yml b/kitchen.yml index 120d7993..c3fe8600 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -4,7 +4,6 @@ driver: provisioner: name: chef_solo - product_name: chef enforce_idempotency: true multiple_converge: 2 deprecations_as_errors: true @@ -16,10 +15,12 @@ verifier: - path: test/integration/inspec platforms: + - name: almalinux-8 - name: centos-7 - - name: centos-8 - - name: debian-9 + - name: centos-stream-8 - name: debian-10 + - name: debian-11 + - name: rockylinux-8 - name: ubuntu-18.04 - name: ubuntu-20.04 @@ -37,8 +38,11 @@ suites: inputs: version: '5.6' excludes: - - centos-8 + - almalinux-8 + - centos-stream-8 - debian-10 + - debian-11 + - rockylinux-8 - ubuntu-20.04 - name: client-57 @@ -83,8 +87,11 @@ suites: version: '5.6' devel: true excludes: - - centos-8 + - almalinux-8 + - centos-stream-8 - debian-10 + - debian-11 + - rockylinux-8 - ubuntu-20.04 - name: devel-57 @@ -126,8 +133,11 @@ suites: percona: version: '5.6' excludes: - - centos-8 + - almalinux-8 + - centos-stream-8 - debian-10 + - debian-11 + - rockylinux-8 - ubuntu-20.04 verifier: controls: @@ -169,8 +179,11 @@ suites: percona: version: '5.6' excludes: - - centos-8 + - almalinux-8 + - centos-stream-8 - debian-10 + - debian-11 + - rockylinux-8 - ubuntu-20.04 verifier: controls: @@ -215,8 +228,11 @@ suites: percona: version: '5.6' excludes: - - centos-8 + - almalinux-8 + - centos-stream-8 - debian-10 + - debian-11 + - rockylinux-8 - ubuntu-20.04 verifier: controls: @@ -261,8 +277,11 @@ suites: percona: version: '5.6' excludes: - - centos-8 + - almalinux-8 + - centos-stream-8 - debian-10 + - debian-11 + - rockylinux-8 - ubuntu-20.04 verifier: controls: @@ -307,8 +326,11 @@ suites: percona: version: '5.6' excludes: - - centos-8 + - almalinux-8 + - centos-stream-8 - debian-10 + - debian-11 + - rockylinux-8 - ubuntu-20.04 verifier: controls: diff --git a/libraries/helpers.rb b/libraries/helpers.rb index d95fa17b..7e80b9b5 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -103,7 +103,7 @@ def percona_jemalloc_package node['platform_version'].to_i >= 10 ? 'libjemalloc2' : 'libjemalloc1' when 'ubuntu' node['platform_version'].to_f >= 20.04 ? 'libjemalloc2' : 'libjemalloc1' - when 'centos', 'redhat' + when 'centos', 'redhat', 'almalinux', 'rocky' 'jemalloc' end end @@ -114,11 +114,19 @@ def percona_jemalloc_lib node['platform_version'].to_i >= 10 ? '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' : '/usr/lib/x86_64-linux-gnu/libjemalloc.so.1' when 'ubuntu' node['platform_version'].to_f >= 20.04 ? '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' : '/usr/lib/x86_64-linux-gnu/libjemalloc.so.1' - when 'centos', 'redhat' + when 'centos', 'redhat', 'almalinux', 'rocky' node['platform_version'].to_i >= 8 ? '/usr/lib64/libjemalloc.so.2' : '/usr/lib64/libjemalloc.so.1' end end + def percona_default_encoding + if node['percona']['version'].to_i >= 8 + 'utf8mb3' + else + 'utf8' + end + end + include Chef::Mixin::ShellOut require 'securerandom' ####### diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index 0e797516..bc3b4fb9 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -154,7 +154,8 @@ group 'root' mode '0644' sensitive true - manage_symlink_source true + manage_symlink_source false + force_unlink true variables( jemalloc_lib: percona_jemalloc_lib, wsrep_sst_auth: wsrep_sst_auth diff --git a/resources/mysql_database.rb b/resources/mysql_database.rb index d958ce2f..7800ba8d 100644 --- a/resources/mysql_database.rb +++ b/resources/mysql_database.rb @@ -26,7 +26,7 @@ property :user, [String, nil], default: 'root', desired_state: false property :socket, [String, nil], desired_state: false property :password, [String, nil], sensitive: true, desired_state: false -property :encoding, String, default: 'utf8' +property :encoding, String, default: lazy { percona_default_encoding } property :collation, String, default: 'utf8_general_ci' property :sql, String diff --git a/spec/configure_server_spec.rb b/spec/configure_server_spec.rb index e693ae33..c6f919bf 100644 --- a/spec/configure_server_spec.rb +++ b/spec/configure_server_spec.rb @@ -34,7 +34,8 @@ mode: '0644', cookbook: 'percona', source: 'my.cnf.main.erb', - manage_symlink_source: true + manage_symlink_source: false, + force_unlink: true ) expect(chef_run).to render_file('/etc/mysql/my.cnf').with_content( @@ -255,16 +256,16 @@ ) end end - context 'Debian 9' do - platform 'debian', '9' + context 'Debian 11' do + platform 'debian', '11' it do - expect(chef_run).to install_package 'libjemalloc1' + expect(chef_run).to install_package 'libjemalloc2' end it 'sets the correct malloc-lib path' do expect(chef_run).to render_file('/etc/mysql/my.cnf').with_content( - %r{^malloc-lib.*= /usr/lib/x86_64-linux-gnu/libjemalloc.so.1} + %r{^malloc-lib.*= /usr/lib/x86_64-linux-gnu/libjemalloc.so.2} ) end end diff --git a/templates/my.cnf.cluster.erb b/templates/my.cnf.cluster.erb index 3fd5bd9d..0863409b 100644 --- a/templates/my.cnf.cluster.erb +++ b/templates/my.cnf.cluster.erb @@ -450,13 +450,13 @@ myisam_sort_buffer_size = <%= node["percona"]["server"]["myisam_sort_buffer_size # If the file-size would be bigger than this, the index will be created # through the key cache (which is slower). myisam_max_sort_file_size = <%= node["percona"]["server"]["myisam_max_sort_file_size"] %> +<%- if node["percona"]["version"].to_f < 5.7 %> # If a table has more than one index, MyISAM can use more than one # thread to repair them by sorting in parallel. This makes sense if you # have multiple CPUs and plenty of memory. myisam_repair_threads = <%= node["percona"]["server"]["myisam_repair_threads"] %> -<%- if node["percona"]["version"].to_f < 5.7 %> # Automatically check and repair not properly closed MyISAM tables. <% if node["percona"]["server"]["myisam_recover_options"] %> myisam_recover diff --git a/templates/my.cnf.main.erb b/templates/my.cnf.main.erb index 50a626ed..06a07cb1 100644 --- a/templates/my.cnf.main.erb +++ b/templates/my.cnf.main.erb @@ -471,13 +471,13 @@ read_buffer_size = <%= node["percona"]["server"]["read_buffer_size"] %> # If the file-size would be bigger than this, the index will be created # through the key cache (which is slower). myisam_max_sort_file_size = <%= node["percona"]["server"]["myisam_max_sort_file_size"] %> +<%- if node["percona"]["version"].to_f < 5.7 %> # If a table has more than one index, MyISAM can use more than one # thread to repair them by sorting in parallel. This makes sense if you # have multiple CPUs and plenty of memory. myisam_repair_threads = <%= node["percona"]["server"]["myisam_repair_threads"] %> -<%- if node["percona"]["version"].to_f < 5.7 %> # Automatically check and repair not properly closed MyISAM tables. <% if node["percona"]["server"]["myisam_recover_options"] %> myisam_recover diff --git a/test/fixtures/cookbooks/test/recipes/_remove_mysql_common.rb b/test/fixtures/cookbooks/test/recipes/_remove_mysql_common.rb new file mode 100644 index 00000000..f21b61b3 --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/_remove_mysql_common.rb @@ -0,0 +1,11 @@ +# mailutils pulls in mysql-common which breaks initial installation on dokken based images. This doesn't seem to happen +# in a non-container system so let's have this here for now +if platform_family?('debian') + execute 'remove mysql-common' do + command <<~EOF + apt-get -y remove mailutils mailutils-common + apt-get -y autoremove + EOF + only_if { ::File.exist?('/usr/share/doc/mailutils-common/copyright') } + end +end diff --git a/test/fixtures/cookbooks/test/recipes/cluster.rb b/test/fixtures/cookbooks/test/recipes/cluster.rb index fd2d2d16..8ec87a13 100644 --- a/test/fixtures/cookbooks/test/recipes/cluster.rb +++ b/test/fixtures/cookbooks/test/recipes/cluster.rb @@ -7,4 +7,5 @@ # Install postfix on RHEL to ensure we don't properly break mysql-libs compatibility package 'postfix' if platform_family?('rhel') +include_recipe 'test::_remove_mysql_common' include_recipe 'percona::cluster' diff --git a/test/fixtures/cookbooks/test/recipes/server.rb b/test/fixtures/cookbooks/test/recipes/server.rb index 94a14e8b..19339218 100644 --- a/test/fixtures/cookbooks/test/recipes/server.rb +++ b/test/fixtures/cookbooks/test/recipes/server.rb @@ -7,5 +7,6 @@ # Install postfix on RHEL to ensure we don't properly break mysql-libs compatibility package 'postfix' if platform_family?('rhel') +include_recipe 'test::_remove_mysql_common' include_recipe 'percona::server' include_recipe 'percona::backup' diff --git a/test/fixtures/cookbooks/test/recipes/user_database.rb b/test/fixtures/cookbooks/test/recipes/user_database.rb index 5936823f..c6cc81d0 100644 --- a/test/fixtures/cookbooks/test/recipes/user_database.rb +++ b/test/fixtures/cookbooks/test/recipes/user_database.rb @@ -3,6 +3,7 @@ node.default['percona']['skip_passwords'] = true node.default['percona']['server']['debian_username'] = 'root' node.default['percona']['server']['debian_password'] = '' +include_recipe 'test::_remove_mysql_common' include_recipe 'percona::server' # Create a schema to test mysql_database :drop against From d1eb9dfd3d6b671428b5a9280129965ba0cc614d Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 18 Aug 2022 07:51:56 -0700 Subject: [PATCH 225/300] Update changelog for 3.2.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ef1989e..eb8f4ab7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.0 - *2022-08-18* - Remove `myisam_repair_threads` for < 5.7 as it's been deprecated - Remove delivery and move to calling RSpec directly via a reusable workflow From d57c9dbcc0d8b2fc744bf2cccce543123d6aeb13 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 18 Aug 2022 07:51:56 -0700 Subject: [PATCH 226/300] Update metadata for 3.2.0 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index c7c32e03..e211cb07 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.1.3' +version '3.2.0' chef_version '>= 16.0' depends 'yum' From 13056e800fb9cb263cbd552cabe809fcde8064eb Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 18 Aug 2022 07:51:59 -0700 Subject: [PATCH 227/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb8f4ab7..f3414ccc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.0 - *2022-08-18* - Remove `myisam_repair_threads` for < 5.7 as it's been deprecated From 35cb4c65022caed8affca11163b1802fef8423ef Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:07:59 -0800 Subject: [PATCH 228/300] Automated PR: Standardising Files (#459) * Standardise files with files in sous-chefs/repo-management Signed-off-by: kitchen-porter * Standardise files with files in sous-chefs/repo-management Signed-off-by: kitchen-porter Signed-off-by: kitchen-porter Co-authored-by: Jason Field --- .github/workflows/md-links.yml | 2 +- CHANGELOG.md | 2 ++ chefignore | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/md-links.yml b/.github/workflows/md-links.yml index ba887a16..13a60f3a 100644 --- a/.github/workflows/md-links.yml +++ b/.github/workflows/md-links.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: markdown-link-check uses: gaurav-nelson/github-action-markdown-link-check@v1 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index f3414ccc..ed6bcde5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +Standardise files with files in sous-chefs/repo-management + ## 3.2.0 - *2022-08-18* - Remove `myisam_repair_threads` for < 5.7 as it's been deprecated diff --git a/chefignore b/chefignore index cc170ea7..a27b0b25 100644 --- a/chefignore +++ b/chefignore @@ -61,7 +61,7 @@ Dangerfile examples/* features/* Guardfile -kitchen.yml* +kitchen*.yml mlc_config.json Procfile Rakefile From d379412edd92f03c2a1094156caa769562852773 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:08:02 -0800 Subject: [PATCH 229/300] Update changelog for 3.2.1 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed6bcde5..b931b4c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.1 - *2022-12-08* Standardise files with files in sous-chefs/repo-management From 238d5ea34a1c466d833bf967d422aaa1efae14f7 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:08:03 -0800 Subject: [PATCH 230/300] Update metadata for 3.2.1 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index e211cb07..f50ffbe9 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.2.0' +version '3.2.1' chef_version '>= 16.0' depends 'yum' From 3b72cb507b40b02de1c049284598461a8074e3b4 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:08:05 -0800 Subject: [PATCH 231/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b931b4c1..f782f30b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.1 - *2022-12-08* Standardise files with files in sous-chefs/repo-management From 9c529290beae08c154793a7a584c79b83538ac45 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 14 Feb 2023 09:26:33 +0000 Subject: [PATCH 232/300] Remove CircleCI (#461) --- .circleci/config.yml | 10 ---------- .github/workflows/ci.yml | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 21 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 8af810ef..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -version: 2.1 -orbs: - kitchen: sous-chefs/kitchen@2 -workflows: - danger: - jobs: - - kitchen/danger: - name: danger - context: Danger-Minimal diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f60139d..b9ecf2b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -129,16 +129,16 @@ jobs: - name: Check out code uses: actions/checkout@v2 - name: Install Chef - uses: actionshub/chef-install@main + uses: actionshub/chef-install@2.0.4 # https://github.com/actions/virtual-environments/issues/181#issuecomment-610874237 - name: Disable apparmor for mysqld run: | - set -x - sudo apt-get -y remove mysql-server --purge - sudo apt-get -y install apparmor-profiles - sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld + set -x + sudo apt-get -y remove mysql-server --purge + sudo apt-get -y install apparmor-profiles + sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld - name: Dokken - uses: actionshub/test-kitchen@main + uses: actionshub/test-kitchen@2.1.0 env: CHEF_LICENSE: accept-no-persist KITCHEN_LOCAL_YAML: kitchen.dokken.yml @@ -148,8 +148,8 @@ jobs: - name: Print debug output on failure if: failure() run: | - set -x - sudo journalctl -l --since today - sudo docker version - sudo docker info - KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "journalctl -l" + set -x + sudo journalctl -l --since today + sudo docker version + sudo docker info + KITCHEN_LOCAL_YAML=kitchen.dokken.yml /usr/bin/kitchen exec ${{ matrix.suite }}-${{ matrix.os }} -c "journalctl -l" From 7d0f03fd4c1e9c57050e799cd7f682c926be1cb8 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 14 Feb 2023 07:59:03 -0800 Subject: [PATCH 233/300] Standardise files with files in sous-chefs/repo-management (#462) Signed-off-by: kitchen-porter --- CHANGELOG.md | 2 ++ renovate.json | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 renovate.json diff --git a/CHANGELOG.md b/CHANGELOG.md index f782f30b..f7575975 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +Standardise files with files in sous-chefs/repo-management + ## 3.2.1 - *2022-12-08* Standardise files with files in sous-chefs/repo-management diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..7e7a8bad --- /dev/null +++ b/renovate.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:base"], + "packageRules": [{ + "groupName": "Actions", + "matchUpdateTypes": ["patch", "pin", "digest"], + "automerge": true, + "addLabels": ["Release: Patch", "Skip: Announcements"] + }, + { + "groupName": "Actions", + "matchUpdateTypes": ["major"], + "automerge": false, + "addLabels": ["Release: Patch", "Skip: Announcements"] + } + ] +} From f22cd0be53cb87e4300dc62a00cf69932454952c Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 14 Feb 2023 07:59:08 -0800 Subject: [PATCH 234/300] Update changelog for 3.2.2 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7575975..a4256056 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.2 - *2023-02-14* Standardise files with files in sous-chefs/repo-management From 1ade7375a09c195d2ba8691acde54e25e782c238 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 14 Feb 2023 07:59:09 -0800 Subject: [PATCH 235/300] Update metadata for 3.2.2 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index f50ffbe9..a7157733 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.2.1' +version '3.2.2' chef_version '>= 16.0' depends 'yum' From c360ca7bcad821ef0807450ff88ac4e54e11f134 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 14 Feb 2023 07:59:11 -0800 Subject: [PATCH 236/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4256056..d5df08f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.2 - *2023-02-14* Standardise files with files in sous-chefs/repo-management From cc3ab2d980b269296da43fee1b47dfab4477e078 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 14 Feb 2023 16:00:10 +0000 Subject: [PATCH 237/300] Update Actions (#463) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- .github/workflows/stale.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9ecf2b0..240a4c20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,7 +127,7 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install Chef uses: actionshub/chef-install@2.0.4 # https://github.com/actions/virtual-environments/issues/181#issuecomment-610874237 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 9e2ff38e..19d86dbe 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -8,7 +8,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v3 + - uses: actions/stale@v7 with: repo-token: ${{ secrets.GITHUB_TOKEN }} close-issue-message: > From 50196d289c23e8af29fe0b8e3060e0cc11d8003d Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 14 Feb 2023 08:00:16 -0800 Subject: [PATCH 238/300] Update changelog for 3.2.3 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5df08f5..8d9f0463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.3 - *2023-02-14* ## 3.2.2 - *2023-02-14* From 5e48f4b28e3e136c75b5372718240f4cb1f8a066 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 14 Feb 2023 08:00:17 -0800 Subject: [PATCH 239/300] Update metadata for 3.2.3 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index a7157733..2ca4e4ae 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.2.2' +version '3.2.3' chef_version '>= 16.0' depends 'yum' From a3f072913388a4a6c58525925b027543b479bcb5 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 14 Feb 2023 08:00:24 -0800 Subject: [PATCH 240/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d9f0463..1b8670a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.3 - *2023-02-14* ## 3.2.2 - *2023-02-14* From c21a746630669da44209ada18a6455996765584b Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 23 Feb 2023 15:56:05 +0000 Subject: [PATCH 241/300] Automated PR: Standardising Files (#465) * Standardise files with files in sous-chefs/repo-management Signed-off-by: kitchen-porter * Standardise files with files in sous-chefs/repo-management Signed-off-by: kitchen-porter --------- Signed-off-by: kitchen-porter --- .github/workflows/md-links.yml | 2 +- CHANGELOG.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/md-links.yml b/.github/workflows/md-links.yml index 13a60f3a..208cb1a2 100644 --- a/.github/workflows/md-links.yml +++ b/.github/workflows/md-links.yml @@ -13,7 +13,7 @@ jobs: - name: Check out code uses: actions/checkout@v3 - name: markdown-link-check - uses: gaurav-nelson/github-action-markdown-link-check@v1 + uses: gaurav-nelson/github-action-markdown-link-check@1.0.13 with: use-verbose-mode: "yes" folder-path: "documentation" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b8670a1..bc8af71e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +Standardise files with files in sous-chefs/repo-management + +Standardise files with files in sous-chefs/repo-management + ## 3.2.3 - *2023-02-14* ## 3.2.2 - *2023-02-14* From 670d38e5580b63387a77994921f7f9184b5c7a58 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 23 Feb 2023 15:56:09 +0000 Subject: [PATCH 242/300] Update changelog for 3.2.4 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc8af71e..f0d4bf23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.4 - *2023-02-23* Standardise files with files in sous-chefs/repo-management From 5fdac73c031886140b7f78741940c2256ece0b0b Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 23 Feb 2023 15:56:10 +0000 Subject: [PATCH 243/300] Update metadata for 3.2.4 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 2ca4e4ae..f2a3d432 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.2.3' +version '3.2.4' chef_version '>= 16.0' depends 'yum' From 44b73c3f3ec66383a8a4251119ed14067bd7feff Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 23 Feb 2023 15:56:13 +0000 Subject: [PATCH 244/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0d4bf23..368715b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.4 - *2023-02-23* Standardise files with files in sous-chefs/repo-management From 95ccec9272520696a853b477197695c8797003fa Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 15 Mar 2023 17:04:44 +0000 Subject: [PATCH 245/300] Automated PR: Standardising Files This PR will standardise the files we have with out agreed spec in sous-chefs/repo-management. This repo has been identified by topic(s) of chef-cookbook --- .markdownlint-cli2.yaml | 5 +++++ .vscode/extensions.json | 7 ++++--- .yamllint | 2 ++ CHANGELOG.md | 4 ++++ 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .markdownlint-cli2.yaml diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml new file mode 100644 index 00000000..ce8cafbf --- /dev/null +++ b/.markdownlint-cli2.yaml @@ -0,0 +1,5 @@ +config: + ul-indent: false # MD007 + line-length: false # MD013 + no-duplicate-heading/no-duplicate-header: false # MD024 + diff --git a/.vscode/extensions.json b/.vscode/extensions.json index cd777250..51d0ae7a 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,8 @@ { "recommendations": [ - "chef-software.chef", - "rebornix.ruby", - "editorconfig.editorconfig" + "chef-software.chef", + "rebornix.ruby", + "editorconfig.editorconfig", + "DavidAnson.vscode-markdownlint" ] } diff --git a/.yamllint b/.yamllint index 1b5cea09..0046b237 100644 --- a/.yamllint +++ b/.yamllint @@ -11,3 +11,5 @@ rules: max-spaces-inside: 1 min-spaces-inside-empty: -1 max-spaces-inside-empty: -1 + comments: + min-spaces-from-content: 1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 368715b6..cab9e9cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +Standardise files with files in sous-chefs/repo-management + +Standardise files with files in sous-chefs/repo-management + ## 3.2.4 - *2023-02-23* Standardise files with files in sous-chefs/repo-management From a28a01b78e359169037fe899a03b2eb0be2787fd Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 15 Mar 2023 17:04:48 +0000 Subject: [PATCH 246/300] Update changelog for 3.2.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cab9e9cb..01ea3bc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.5 - *2023-03-15* Standardise files with files in sous-chefs/repo-management From b563df5a5864f2b96ee01aeb27f72345efa797ff Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 15 Mar 2023 17:04:49 +0000 Subject: [PATCH 247/300] Update metadata for 3.2.5 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index f2a3d432..d17247ee 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.2.4' +version '3.2.5' chef_version '>= 16.0' depends 'yum' From 4cee35401d6cc9b1791b5871c578231b39c84f32 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 15 Mar 2023 17:04:51 +0000 Subject: [PATCH 248/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01ea3bc0..9ddcd386 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.5 - *2023-03-15* Standardise files with files in sous-chefs/repo-management From 63d39cf29ef20d92816422bf72acc9256c89d515 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 20 Mar 2023 12:11:11 +0000 Subject: [PATCH 249/300] Automated PR: Standardising Files [skip ci] This PR will standardise the files we have with out agreed spec in sous-chefs/repo-management. This repo has been identified by topic(s) of chef-cookbook --- .markdownlint-cli2.yaml | 3 +-- CHANGELOG.md | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml index ce8cafbf..0cb05b41 100644 --- a/.markdownlint-cli2.yaml +++ b/.markdownlint-cli2.yaml @@ -1,5 +1,4 @@ config: ul-indent: false # MD007 line-length: false # MD013 - no-duplicate-heading/no-duplicate-header: false # MD024 - + no-duplicate-heading: false # MD024 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ddcd386..ae8657ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +Standardise files with files in sous-chefs/repo-management + ## 3.2.5 - *2023-03-15* Standardise files with files in sous-chefs/repo-management From d2c37e39075e13ba4a8e14f6853c2df5cf4b8567 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 20 Mar 2023 12:11:14 +0000 Subject: [PATCH 250/300] Update changelog for 3.2.6 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae8657ac..931dd25d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.6 - *2023-03-20* Standardise files with files in sous-chefs/repo-management From 74cb903e38ad7fc2cfbe90e8aaa6b383d703d8fa Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 20 Mar 2023 12:11:15 +0000 Subject: [PATCH 251/300] Update metadata for 3.2.6 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index d17247ee..73817278 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.2.5' +version '3.2.6' chef_version '>= 16.0' depends 'yum' From b8b810543d7a91f86bcf03bcee3242d57a911059 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 20 Mar 2023 12:11:18 +0000 Subject: [PATCH 252/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 931dd25d..c6ae3bef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.6 - *2023-03-20* Standardise files with files in sous-chefs/repo-management From cc39da56991b5c9d6f51a677c428e424d230ee77 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Sat, 1 Apr 2023 08:17:29 +0100 Subject: [PATCH 253/300] Automated PR: Standardising Files [skip ci] This PR will standardise the files we have with out agreed spec in sous-chefs/repo-management. This repo has been identified by topic(s) of chef-cookbook --- .markdownlint-cli2.yaml | 1 + CHANGELOG.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml index 0cb05b41..6fa8e776 100644 --- a/.markdownlint-cli2.yaml +++ b/.markdownlint-cli2.yaml @@ -2,3 +2,4 @@ config: ul-indent: false # MD007 line-length: false # MD013 no-duplicate-heading: false # MD024 + reference-links-images: false # MD052 diff --git a/CHANGELOG.md b/CHANGELOG.md index c6ae3bef..94b35561 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +Standardise files with files in sous-chefs/repo-management + ## 3.2.6 - *2023-03-20* Standardise files with files in sous-chefs/repo-management From ace1bd2b126c1b554745730cab9d81086078e467 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Sat, 1 Apr 2023 08:17:32 +0100 Subject: [PATCH 254/300] Update changelog for 3.2.7 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94b35561..9bbf1397 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.7 - *2023-04-01* Standardise files with files in sous-chefs/repo-management From e2496938466ed778ac582f35dd1a698c65d3685a Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Sat, 1 Apr 2023 08:17:33 +0100 Subject: [PATCH 255/300] Update metadata for 3.2.7 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 73817278..bbb42a5f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.2.6' +version '3.2.7' chef_version '>= 16.0' depends 'yum' From 7d4876bc697edca399c16e6749f59d4a013c7bbb Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Sat, 1 Apr 2023 08:17:35 +0100 Subject: [PATCH 256/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bbf1397..73ffee2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.7 - *2023-04-01* Standardise files with files in sous-chefs/repo-management From b4706fe73279cb5ccd2eb7be7701225761ef5c25 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 1 Apr 2023 20:43:19 +0800 Subject: [PATCH 257/300] Update actions/stale action to v8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [skip ci] [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [actions/stale](https://togithub.com/actions/stale) | action | major | `v7` -> `v8` | --- ### Release Notes
actions/stale ### [`v8`](https://togithub.com/actions/stale/compare/v7...v8) [Compare Source](https://togithub.com/actions/stale/compare/v7...v8)
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/sous-chefs/percona). --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 19d86dbe..4bb59c62 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -8,7 +8,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v7 + - uses: actions/stale@v8 with: repo-token: ${{ secrets.GITHUB_TOKEN }} close-issue-message: > From 50c57ba8f903b6de65b9f7bb8fcc950ae8ce8610 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Sat, 1 Apr 2023 13:43:23 +0100 Subject: [PATCH 258/300] Update changelog for 3.2.8 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73ffee2a..4cc46cd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.8 - *2023-04-01* ## 3.2.7 - *2023-04-01* From d4cae7120a8fb2378a686fd4185e5575cf976b34 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Sat, 1 Apr 2023 13:43:23 +0100 Subject: [PATCH 259/300] Update metadata for 3.2.8 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index bbb42a5f..509c8a27 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.2.7' +version '3.2.8' chef_version '>= 16.0' depends 'yum' From 0a27ccef9f8fa503a248e8920d508b01143fe02a Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Sat, 1 Apr 2023 13:43:26 +0100 Subject: [PATCH 260/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cc46cd0..fead6a3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.8 - *2023-04-01* ## 3.2.7 - *2023-04-01* From 28033e1c3f9024ea741432452e4fd647c0ae0bf9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 1 Apr 2023 20:50:59 +0800 Subject: [PATCH 261/300] Update gaurav-nelson/github-action-markdown-link-check action to v1.0.15 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [skip ci] [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [gaurav-nelson/github-action-markdown-link-check](https://togithub.com/gaurav-nelson/github-action-markdown-link-check) | action | patch | `1.0.13` -> `1.0.15` | --- ### Release Notes
gaurav-nelson/github-action-markdown-link-check ### [`v1.0.15`](https://togithub.com/gaurav-nelson/github-action-markdown-link-check/releases/tag/1.0.15) [Compare Source](https://togithub.com/gaurav-nelson/github-action-markdown-link-check/compare/1.0.14...1.0.15) ##### Changes - [https://github.com/gaurav-nelson/github-action-markdown-link-check/pull/168](https://togithub.com/gaurav-nelson/github-action-markdown-link-check/pull/168) - Respect folder-path when check-modified-files-only == yes: Thank you [@​exoego](https://togithub.com/exoego) Thank you [@​mgrojo](https://togithub.com/mgrojo) [@​qaristote](https://togithub.com/qaristote) [@​RezaRahemtola](https://togithub.com/RezaRahemtola) for minor typo fixes. ### [`v1.0.14`](https://togithub.com/gaurav-nelson/github-action-markdown-link-check/releases/tag/1.0.14) [Compare Source](https://togithub.com/gaurav-nelson/github-action-markdown-link-check/compare/1.0.13...1.0.14) ### Important ‼️ This version is in beta. Use `1.0.13` or `v1` which are the stable versions. *** ##### Changes - [https://github.com/gaurav-nelson/github-action-markdown-link-check/pull/116](https://togithub.com/gaurav-nelson/github-action-markdown-link-check/pull/116) - Changed the base image to more stage Node image `node:lts-alpine` - [https://github.com/gaurav-nelson/github-action-markdown-link-check/pull/126](https://togithub.com/gaurav-nelson/github-action-markdown-link-check/pull/126) - Use markdown-link-check version 3.9.3 - [https://github.com/gaurav-nelson/github-action-markdown-link-check/pull/148](https://togithub.com/gaurav-nelson/github-action-markdown-link-check/pull/148) - Fully disable the Git ownership check - [https://github.com/gaurav-nelson/github-action-markdown-link-check/pull/144](https://togithub.com/gaurav-nelson/github-action-markdown-link-check/pull/144) - Update markdown-lint-check to v3.10.2 Thank you [@​thanethomson](https://togithub.com/thanethomson) [@​edumco](https://togithub.com/edumco) [@​Pandapip1](https://togithub.com/Pandapip1) [@​creachadair](https://togithub.com/creachadair) [@​bogdandrutu](https://togithub.com/bogdandrutu)
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/sous-chefs/percona). --- .github/workflows/md-links.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/md-links.yml b/.github/workflows/md-links.yml index 208cb1a2..e5c1e7a2 100644 --- a/.github/workflows/md-links.yml +++ b/.github/workflows/md-links.yml @@ -13,7 +13,7 @@ jobs: - name: Check out code uses: actions/checkout@v3 - name: markdown-link-check - uses: gaurav-nelson/github-action-markdown-link-check@1.0.13 + uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 with: use-verbose-mode: "yes" folder-path: "documentation" From 2de53081fb031276c6edddf54e3127a7d3a593f4 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Sat, 1 Apr 2023 13:51:02 +0100 Subject: [PATCH 262/300] Update changelog for 3.2.9 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fead6a3f..422cfda8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.9 - *2023-04-01* ## 3.2.8 - *2023-04-01* From a59402b73173ecfcac8137c1362dd9b45f2df823 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Sat, 1 Apr 2023 13:51:02 +0100 Subject: [PATCH 263/300] Update metadata for 3.2.9 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 509c8a27..1c46b16b 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.2.8' +version '3.2.9' chef_version '>= 16.0' depends 'yum' From 3e495eeb73d6d37a3a0eaa211081c127edbd1c98 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Sat, 1 Apr 2023 13:51:05 +0100 Subject: [PATCH 264/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 422cfda8..9c0418b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.9 - *2023-04-01* ## 3.2.8 - *2023-04-01* From f072b3f5862db2c665efd4c23a9e0c9806815c93 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Fri, 7 Apr 2023 05:59:52 +0100 Subject: [PATCH 265/300] Automated PR: Standardising Files [skip ci] This PR will standardise the files we have with out agreed spec in sous-chefs/repo-management. This repo has been identified by topic(s) of chef-cookbook --- .overcommit.yml | 14 +++++++-- CHANGELOG.md | 2 ++ kitchen.dokken.yml | 77 ++++++++++++++++++++++++++++++++++++++++------ kitchen.exec.yml | 7 +++++ kitchen.global.yml | 38 +++++++++++++++++++++++ 5 files changed, 126 insertions(+), 12 deletions(-) create mode 100644 kitchen.exec.yml create mode 100644 kitchen.global.yml diff --git a/.overcommit.yml b/.overcommit.yml index cd8682a0..0e89a3c1 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -4,13 +4,21 @@ PreCommit: enabled: true YamlLint: enabled: true - Rspec: + required_executable: "yamllint" + ChefSpec: enabled: true - required_executable: 'rspec' + required_executable: "chef" + command: ["chef", "exec", "rspec"] Cookstyle: enabled: true - required_executable: 'cookstyle' + required_executable: "cookstyle" command: ["cookstyle"] + MarkdownLint: + enabled: false + required_executable: "npx" + command: ["npx", "markdownlint-cli2", "'**/*.md'"] + include: ["**/*.md"] + CommitMsg: HardTabs: enabled: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c0418b9..48d40114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +Standardise files with files in sous-chefs/repo-management + ## 3.2.9 - *2023-04-01* ## 3.2.8 - *2023-04-01* diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index d1ea94e8..47eff95d 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -1,16 +1,10 @@ ---- driver: name: dokken - # because Docker and SystemD/Upstart privileged: true - -transport: - name: dokken - -provisioner: - name: dokken chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> - chef_license: accept-no-persist + +transport: { name: dokken } +provisioner: { name: dokken } platforms: - name: almalinux-8 @@ -18,6 +12,16 @@ platforms: image: dokken/almalinux-8 pid_one_command: /usr/lib/systemd/systemd + - name: almalinux-9 + driver: + image: dokken/almalinux-9 + pid_one_command: /usr/lib/systemd/systemd + + - name: amazonlinux-2023 + driver: + image: dokken/amazonlinux-2023 + pid_one_command: /usr/lib/systemd/systemd + - name: centos-7 driver: image: dokken/centos-7 @@ -28,6 +32,16 @@ platforms: image: dokken/centos-stream-8 pid_one_command: /usr/lib/systemd/systemd + - name: centos-stream-9 + driver: + image: dokken/centos-stream-9 + pid_one_command: /usr/lib/systemd/systemd + + - name: debian-9 + driver: + image: dokken/debian-9 + pid_one_command: /bin/systemd + - name: debian-10 driver: image: dokken/debian-10 @@ -38,11 +52,46 @@ platforms: image: dokken/debian-11 pid_one_command: /bin/systemd + - name: debian-12 + driver: + image: dokken/debian-12 + pid_one_command: /bin/systemd + + - name: fedora-latest + driver: + image: dokken/fedora-latest + pid_one_command: /usr/lib/systemd/systemd + + - name: opensuse-leap-15 + driver: + image: dokken/opensuse-leap-15 + pid_one_command: /usr/lib/systemd/systemd + + - name: oraclelinux-7 + driver: + image: dokken/oraclelinux-7 + pid_one_command: /usr/lib/systemd/systemd + + - name: oraclelinux-8 + driver: + image: dokken/oraclelinux-8 + pid_one_command: /usr/lib/systemd/systemd + + - name: oraclelinux-9 + driver: + image: dokken/oraclelinux-9 + pid_one_command: /usr/lib/systemd/systemd + - name: rockylinux-8 driver: image: dokken/rockylinux-8 pid_one_command: /usr/lib/systemd/systemd + - name: rockylinux-9 + driver: + image: dokken/rockylinux-9 + pid_one_command: /usr/lib/systemd/systemd + - name: ubuntu-18.04 driver: image: dokken/ubuntu-18.04 @@ -52,3 +101,13 @@ platforms: driver: image: dokken/ubuntu-20.04 pid_one_command: /bin/systemd + + - name: ubuntu-22.04 + driver: + image: dokken/ubuntu-22.04 + pid_one_command: /bin/systemd + + - name: ubuntu-23.04 + driver: + image: dokken/ubuntu-23.04 + pid_one_command: /bin/systemd diff --git a/kitchen.exec.yml b/kitchen.exec.yml new file mode 100644 index 00000000..ba7b2a96 --- /dev/null +++ b/kitchen.exec.yml @@ -0,0 +1,7 @@ +--- +driver: { name: exec } +transport: { name: exec } + +platforms: + - name: macos-latest + - name: windows-latest diff --git a/kitchen.global.yml b/kitchen.global.yml new file mode 100644 index 00000000..a382fcd0 --- /dev/null +++ b/kitchen.global.yml @@ -0,0 +1,38 @@ +--- +provisioner: + name: chef_infra + product_name: chef + product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> + channel: stable + install_strategy: once + chef_license: accept + enforce_idempotency: <%= ENV['ENFORCE_IDEMPOTENCY'] || true %> + multiple_converge: <%= ENV['MULTIPLE_CONVERGE'] || 2 %> + deprecations_as_errors: true + log_level: <%= ENV['CHEF_LOG_LEVEL'] || 'auto' %> + +verifier: + name: inspec + +platforms: + - name: almalinux-8 + - name: almalinux-9 + - name: amazonlinux-2023 + - name: centos-7 + - name: centos-stream-8 + - name: centos-stream-9 + - name: debian-9 + - name: debian-10 + - name: debian-11 + - name: debian-12 + - name: fedora-latest + - name: opensuse-leap-15 + - name: oraclelinux-7 + - name: oraclelinux-8 + - name: oraclelinux-9 + - name: rockylinux-8 + - name: rockylinux-9 + - name: ubuntu-18.04 + - name: ubuntu-20.04 + - name: ubuntu-22.04 + - name: ubuntu-23.04 From 79d9adc4fc271b0730ffe2af5c12b6ab7a32868c Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Fri, 7 Apr 2023 05:59:56 +0100 Subject: [PATCH 266/300] Update changelog for 3.2.10 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48d40114..43fd470d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.10 - *2023-04-07* Standardise files with files in sous-chefs/repo-management From a0210270f07d67d1350b409b6e942b2dc4a318be Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Fri, 7 Apr 2023 05:59:56 +0100 Subject: [PATCH 267/300] Update metadata for 3.2.10 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 1c46b16b..01bff246 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/chef-percona' issues_url 'https://github.com/sous-chefs/chef-percona/issues' -version '3.2.9' +version '3.2.10' chef_version '>= 16.0' depends 'yum' From a8a47f96a252e1c09ebf8757028504964e5e62eb Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Fri, 7 Apr 2023 05:59:59 +0100 Subject: [PATCH 268/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43fd470d..f32d00ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.10 - *2023-04-07* Standardise files with files in sous-chefs/repo-management From 14e81d5dc8cc6d889c52bf3611f2e99689a9d11e Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 25 Apr 2023 14:07:16 +0100 Subject: [PATCH 269/300] Update workflow to 2.0.2 (#475) Signed-off-by: Dan Webb --- .github/workflows/ci.yml | 2 +- .github/workflows/md-links.yml | 19 ---------------- CHANGELOG.md | 28 +++++++++--------------- metadata.rb | 4 ++-- test/fixtures/cookbooks/test/metadata.rb | 1 - 5 files changed, 13 insertions(+), 41 deletions(-) delete mode 100644 .github/workflows/md-links.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 240a4c20..c67954e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ name: ci jobs: lint-unit: - uses: sous-chefs/.github/.github/workflows/lint-unit.yml@0.0.3 + uses: sous-chefs/.github/.github/workflows/lint-unit.yml@2.0.2 permissions: actions: write checks: write diff --git a/.github/workflows/md-links.yml b/.github/workflows/md-links.yml deleted file mode 100644 index e5c1e7a2..00000000 --- a/.github/workflows/md-links.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -name: md-links - -"on": - pull_request: - push: - branches: [main] - -jobs: - md-links: - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v3 - - name: markdown-link-check - uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 - with: - use-verbose-mode: "yes" - folder-path: "documentation" diff --git a/CHANGELOG.md b/CHANGELOG.md index f32d00ba..ae3e8bb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,14 +4,20 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +Standardise files with files in sous-chefs/repo-management + ## 3.2.10 - *2023-04-07* Standardise files with files in sous-chefs/repo-management ## 3.2.9 - *2023-04-01* +Standardise files with files in sous-chefs/repo-management + ## 3.2.8 - *2023-04-01* +Standardise files with files in sous-chefs/repo-management + ## 3.2.7 - *2023-04-01* Standardise files with files in sous-chefs/repo-management @@ -24,16 +30,14 @@ Standardise files with files in sous-chefs/repo-management Standardise files with files in sous-chefs/repo-management -Standardise files with files in sous-chefs/repo-management - ## 3.2.4 - *2023-02-23* Standardise files with files in sous-chefs/repo-management -Standardise files with files in sous-chefs/repo-management - ## 3.2.3 - *2023-02-14* +Standardise files with files in sous-chefs/repo-management + ## 3.2.2 - *2023-02-14* Standardise files with files in sous-chefs/repo-management @@ -96,13 +100,9 @@ Standardise files with files in sous-chefs/repo-management ## 2.0.0 - 2020-10-23 -### Added - - Add `percona_mysql_database` resource for creating, querying and removing databases - Add `percona_mysql_user` resource for creating, modifying and removing database users -### Removed - - Remove `mysql_chef_gem` and `mysql2_chef_gem` providers in favor of the `percona_mysql_database` and `percona_mysql_user` resources ## 1.1.1 - 2020-09-16 @@ -115,8 +115,6 @@ Standardise files with files in sous-chefs/repo-management ## 1.0.0 - 2020-08-14 -### Added - - Add support for Debian 10 for 5.7 only - Add support for Ubuntu 20.04 for 5.7 only - Add support for CentOS 8 @@ -126,8 +124,7 @@ Standardise files with files in sous-chefs/repo-management - Add ssl suite and tests for ssl recipe - Add master suite and tests for testing the replication recipe - Suite to test compatibility with Chef 13 - -### Fixed +@2.0.1 - Update apt gpg key - Fixes for supporting 5.7 @@ -139,15 +136,11 @@ Standardise files with files in sous-chefs/repo-management - Use correct cert path for master/slave - Fix issue when trying to set node['percona']['version'] in a recipe -### Changed - - Convert to InSpec tests and refactor test cookbook recipes - Don't install abi_version packages on Debian/Ubuntu - Standardise files with files in sous-chefs/repo-management - Move client package installation for cluster to cluster recipe -### Removed - - Remove support for Amazon Linux - Remove support for OpenSUSE - Remove support for Debian 8 (EOL) @@ -162,7 +155,7 @@ Standardise files with files in sous-chefs/repo-management ## 0.17.2 - 2020-08-06 -### Fixed +@2.0.1 - Fix debian_password as a string for testing - Fix idempotency issues with find_password method @@ -198,5 +191,4 @@ Standardise files with files in sous-chefs/repo-management - Many changes -[2.0.1 - *2020-12-15*]: https://github.com/sous-chefs/percona/compare/v0.16.1...HEAD [0.16.1]: https://github.com/sous-chefs/percona/compare/v0.16.0...v0.16.1 diff --git a/metadata.rb b/metadata.rb index 01bff246..6652b9ae 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,8 +3,8 @@ maintainer_email 'help@sous-chefs.org' license 'Apache-2.0' description 'Installs Percona MySQL client and server' -source_url 'https://github.com/sous-chefs/chef-percona' -issues_url 'https://github.com/sous-chefs/chef-percona/issues' +source_url 'https://github.com/sous-chefs/percona' +issues_url 'https://github.com/sous-chefs/percona/issues' version '3.2.10' chef_version '>= 16.0' diff --git a/test/fixtures/cookbooks/test/metadata.rb b/test/fixtures/cookbooks/test/metadata.rb index a8664df1..61911d19 100644 --- a/test/fixtures/cookbooks/test/metadata.rb +++ b/test/fixtures/cookbooks/test/metadata.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true name 'test' maintainer 'Sous Chefs' maintainer_email 'help@sous-chefs.org' From 4fc07f0dcbb17e85a37dac5412d81142920a5a85 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:07:20 +0100 Subject: [PATCH 270/300] Update changelog for 3.2.11 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae3e8bb4..c570efcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.2.11 - *2023-04-25* Standardise files with files in sous-chefs/repo-management From 2fee8b4b9c4a839393cc0da3fbcd430732659dba Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:07:20 +0100 Subject: [PATCH 271/300] Update metadata for 3.2.11 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 6652b9ae..5a4dad74 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/percona' issues_url 'https://github.com/sous-chefs/percona/issues' -version '3.2.10' +version '3.2.11' chef_version '>= 16.0' depends 'yum' From d79b233aac48075c786404cd4bc0a052544a45b1 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:07:23 +0100 Subject: [PATCH 272/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c570efcb..929fe1e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.2.11 - *2023-04-25* Standardise files with files in sous-chefs/repo-management From 96d175bddc2a2c33792c34e6eaf887b5e33b8ff4 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 25 Apr 2023 20:55:50 +0100 Subject: [PATCH 273/300] Fix CTRL Hash (#476) - Update logic on how to validate if a user can login - Wrap password string in single quotes for shell_out - Fix filename for not_if - Fix rpm dependency conflict with 8.0 client on centos 7 - Remove percona_8_on_centos_7 method and moved package remove the test cookbook - Move package remove to new test fixture recipe Signed-off-by: Dan Webb Co-authored-by: jcookfastrobot --- .github/workflows/ci.yml | 83 +------------------ CHANGELOG.md | 10 ++- README.md | 1 - libraries/helpers.rb | 12 +-- recipes/package_repo.rb | 2 +- resources/mysql_database.rb | 4 +- resources/mysql_user.rb | 9 +- .../test/recipes/_remove_mariadb_libs.rb | 6 ++ .../fixtures/cookbooks/test/recipes/client.rb | 1 + .../cookbooks/test/recipes/cluster.rb | 7 +- .../fixtures/cookbooks/test/recipes/server.rb | 13 ++- .../cookbooks/test/recipes/user_database.rb | 51 ++++++++++++ .../inspec/controls/resources_spec.rb | 4 + 13 files changed, 103 insertions(+), 100 deletions(-) create mode 100644 test/fixtures/cookbooks/test/recipes/_remove_mariadb_libs.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c67954e5..690e2c0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,105 +24,28 @@ jobs: matrix: os: - almalinux-8 + - almalinux-9 - centos-7 - centos-stream-8 + - centos-stream-9 - debian-10 - debian-11 - - rockylinux-8 - ubuntu-1804 - ubuntu-2004 + - ubuntu-2204 suite: - - client-56 - client-57 - client-80 - - devel-56 - devel-57 - devel-80 - - server-56 - server-57 - server-80 - - source-56 - source-57 - source-80 - - replication-56 - replication-57 - replication-80 - - resources-56 - resources-57 - resources-80 - exclude: - - os: almalinux-8 - suite: client-56 - - os: almalinux-8 - suite: devel-56 - - os: almalinux-8 - suite: server-56 - - os: almalinux-8 - suite: source-56 - - os: almalinux-8 - suite: replication-56 - - os: almalinux-8 - suite: resources-56 - - os: centos-stream-8 - suite: client-56 - - os: centos-stream-8 - suite: devel-56 - - os: centos-stream-8 - suite: server-56 - - os: centos-stream-8 - suite: source-56 - - os: centos-stream-8 - suite: replication-56 - - os: centos-stream-8 - suite: resources-56 - - os: debian-10 - suite: client-56 - - os: debian-10 - suite: devel-56 - - os: debian-10 - suite: server-56 - - os: debian-10 - suite: source-56 - - os: debian-10 - suite: replication-56 - - os: debian-10 - suite: resources-56 - - os: debian-11 - suite: client-56 - - os: debian-11 - suite: devel-56 - - os: debian-11 - suite: server-56 - - os: debian-11 - suite: source-56 - - os: debian-11 - suite: replication-56 - - os: debian-11 - suite: resources-56 - - os: rockylinux-8 - suite: client-56 - - os: rockylinux-8 - suite: devel-56 - - os: rockylinux-8 - suite: server-56 - - os: rockylinux-8 - suite: source-56 - - os: rockylinux-8 - suite: replication-56 - - os: rockylinux-8 - suite: resources-56 - - os: ubuntu-2004 - suite: client-56 - - os: ubuntu-2004 - suite: devel-56 - - os: ubuntu-2004 - suite: server-56 - - os: ubuntu-2004 - suite: source-56 - - os: ubuntu-2004 - suite: replication-56 - - os: ubuntu-2004 - suite: resources-56 fail-fast: false steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 929fe1e8..5292925a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- Fixed the user key in the ctrl_hash for the run_query method in the mysql_user custom resource +- Updated ctrl_hash (now user_hash) parameters to validate if a user can login using username@host instead of username@ctrl_host +- Wrapped password substring in single quotes to protect from special characters in sql_command_string helper method +- Updated default encoding and collate in 8.0 to `utf8mb4` and `utf8mb4_0900_ai_ci` respectively +- Fixed 8.0 client rpm dependency conflict on centos 7 +- Stop running tests for Server and Client 5.6 +- Change test behaviour to not enable jemalloc on RHEL 9. + ## 3.2.11 - *2023-04-25* Standardise files with files in sous-chefs/repo-management @@ -56,7 +64,7 @@ Standardise files with files in sous-chefs/repo-management - Add support to Alma Linux & Rocky Linux - Update default encoding when using 8.0 to `utf8mb3` to fix idempotency issues - Fix management of server `my.cnf` - - Set `manage_symlink_source` to `false` and set `force_unlink` to `true` to fix idempotency on Debian based systems +- Set `manage_symlink_source` to `false` and set `force_unlink` to `true` to fix idempotency on Debian based systems - Fix issue when testing on Debian dokken images by removing mailutils (and thus mysql-common) ## 3.1.3 - *2022-02-17* diff --git a/README.md b/README.md index e198f4ba..30d43ece 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Percona Cookbook [![Cookbook Version](https://img.shields.io/cookbook/v/percona.svg)](https://supermarket.chef.io/cookbooks/percona) -[![Build Status](https://img.shields.io/circleci/project/github/sous-chefs/percona/master.svg)](https://circleci.com/gh/sous-chefs/percona) [![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors) [![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0) diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 7e80b9b5..befea141 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -120,11 +120,11 @@ def percona_jemalloc_lib end def percona_default_encoding - if node['percona']['version'].to_i >= 8 - 'utf8mb3' - else - 'utf8' - end + node['percona']['version'].to_i >= 8 ? 'utf8mb4' : 'utf8' + end + + def percona_default_collate + node['percona']['version'].to_i >= 8 ? 'utf8mb4_0900_ai_ci' : 'utf8_general_ci' end include Chef::Mixin::ShellOut @@ -147,7 +147,7 @@ def sql_command_string(query, database, ctrl, grep_for = nil) Chef::Log.debug("Control Hash: [#{ctrl.to_json}]\n") cmd = "/usr/bin/mysql -B -e \"#{raw_query}\"" cmd << " --user=#{ctrl[:user]}" if ctrl && ctrl.key?(:user) && !ctrl[:user].nil? - cmd << " -p#{ctrl[:password]}" if ctrl && ctrl.key?(:password) && !ctrl[:password].nil? + cmd << " -p'#{ctrl[:password]}'" if ctrl && ctrl.key?(:password) && !ctrl[:password].nil? cmd << " -h #{ctrl[:host]}" if ctrl && ctrl.key?(:host) && !ctrl[:host].nil? && ctrl[:host] != 'localhost' cmd << " -P #{ctrl[:port]}" if ctrl && ctrl.key?(:port) && !ctrl[:port].nil? && ctrl[:host] != 'localhost' cmd << " -S #{default_socket}" if ctrl && ctrl.key?(:host) && !ctrl[:host].nil? && ctrl[:host] == 'localhost' diff --git a/recipes/package_repo.rb b/recipes/package_repo.rb index 7b83eb08..a27d4e56 100644 --- a/recipes/package_repo.rb +++ b/recipes/package_repo.rb @@ -35,7 +35,7 @@ when 'rhel' dnf_module 'mysql' do action :disable - only_if { node['platform_version'].to_i >= 8 } + only_if { node['platform_version'].to_i == 8 } end yum_repository 'percona' do diff --git a/resources/mysql_database.rb b/resources/mysql_database.rb index 7800ba8d..d47d0d4f 100644 --- a/resources/mysql_database.rb +++ b/resources/mysql_database.rb @@ -27,7 +27,7 @@ property :socket, [String, nil], desired_state: false property :password, [String, nil], sensitive: true, desired_state: false property :encoding, String, default: lazy { percona_default_encoding } -property :collation, String, default: 'utf8_general_ci' +property :collation, String, default: lazy { percona_default_collate } property :sql, String action :create do @@ -60,7 +60,7 @@ end load_current_value do - lsocket = (socket && host == 'localhost') ? socket : nil + lsocket = (host == 'localhost') ? default_socket : nil ctrl = { user: user, password: password }.merge!(lsocket.nil? ? { host: host, port: port } : { socket: lsocket }) query = "SHOW DATABASES LIKE '#{database_name}'" diff --git a/resources/mysql_user.rb b/resources/mysql_user.rb index 936fcbeb..13c7d0fd 100644 --- a/resources/mysql_user.rb +++ b/resources/mysql_user.rb @@ -67,7 +67,7 @@ def run_query(query) socket = new_resource.ctrl_host == 'localhost' ? default_socket : nil - ctrl_hash = { host: new_resource.ctrl_host, port: new_resource.ctrl_port, username: new_resource.ctrl_user, password: new_resource.ctrl_password, socket: socket } + ctrl_hash = { user: new_resource.ctrl_user, password: new_resource.ctrl_password }.merge!(socket.nil? ? { host: new_resource.ctrl_host, port: new_resource.ctrl_port } : { socket: socket }) Chef::Log.debug("#{@new_resource}: Performing query [#{query}]") execute_sql(query, nil, ctrl_hash) end @@ -101,11 +101,12 @@ def test_user_password run_query(test_sql).split("\n").count > 1 else # Works for any authentication method as long as the host is localhost test_sql = "SELECT 'user can login'" - socket = new_resource.ctrl_host == 'localhost' ? default_socket : nil - ctrl_hash = { host: new_resource.ctrl_host, port: new_resource.ctrl_port, user: new_resource.username, password: new_resource.password, socket: socket } + socket = new_resource.host == 'localhost' ? default_socket : nil + # Passing host instead of ctrl_host to validate the user@scope login instead of user@ctrl_host + user_hash = { user: new_resource.username, password: new_resource.password }.merge!(socket.nil? ? { host: new_resource.host, port: new_resource.ctrl_port } : { socket: socket }) Chef::Log.debug("#{@new_resource}: Performing query [#{test_sql}]") - if execute_sql_exitstatus(test_sql, ctrl_hash) == 0 + if execute_sql_exitstatus(test_sql, user_hash) == 0 true else # handles mysql_native_password authentication method test_sql = 'SELECT User,Host,authentication_string FROM mysql.user ' \ diff --git a/test/fixtures/cookbooks/test/recipes/_remove_mariadb_libs.rb b/test/fixtures/cookbooks/test/recipes/_remove_mariadb_libs.rb new file mode 100644 index 00000000..643ce357 --- /dev/null +++ b/test/fixtures/cookbooks/test/recipes/_remove_mariadb_libs.rb @@ -0,0 +1,6 @@ +# If we are installing 8.0 on a Centos 7 instance we need to remove the existing +# mariadb-libs rpm to avoid a dependency conflict. +package 'mariadb-libs' do + action :remove + only_if { platform_family?('rhel') && node['platform_version'].to_i == 7 && node['percona']['version'].to_i >= 8 } +end diff --git a/test/fixtures/cookbooks/test/recipes/client.rb b/test/fixtures/cookbooks/test/recipes/client.rb index a7962f9f..0ad9ef54 100644 --- a/test/fixtures/cookbooks/test/recipes/client.rb +++ b/test/fixtures/cookbooks/test/recipes/client.rb @@ -1,2 +1,3 @@ +include_recipe 'test::_remove_mariadb_libs' include_recipe 'percona::client' include_recipe 'percona::toolkit' diff --git a/test/fixtures/cookbooks/test/recipes/cluster.rb b/test/fixtures/cookbooks/test/recipes/cluster.rb index 8ec87a13..5b6f7043 100644 --- a/test/fixtures/cookbooks/test/recipes/cluster.rb +++ b/test/fixtures/cookbooks/test/recipes/cluster.rb @@ -1,9 +1,14 @@ node.default['percona']['server']['datadir'] = '/tmp/mysql' node.default['percona']['server']['debian_password'] = '0kb)F?Zj' -node.default['percona']['server']['jemalloc'] = true node.default['percona']['server']['root_password'] = '7tCk(V5I' node.default['percona']['backup']['password'] = 'I}=sJ2bS' +node.default['percona']['server']['jemalloc'] = if platform_family?('rhel') && node['platform_version'] >= '9' + false + else + true + end + # Install postfix on RHEL to ensure we don't properly break mysql-libs compatibility package 'postfix' if platform_family?('rhel') diff --git a/test/fixtures/cookbooks/test/recipes/server.rb b/test/fixtures/cookbooks/test/recipes/server.rb index 19339218..3bd49adb 100644 --- a/test/fixtures/cookbooks/test/recipes/server.rb +++ b/test/fixtures/cookbooks/test/recipes/server.rb @@ -1,12 +1,17 @@ node.default['percona']['server']['datadir'] = '/tmp/mysql' node.default['percona']['server']['debian_password'] = '0kb)F?Zj' -node.default['percona']['server']['jemalloc'] = true node.default['percona']['server']['root_password'] = '7tCk(V5I' node.default['percona']['backup']['password'] = 'I}=sJ2bS' +node.default['percona']['server']['jemalloc'] = if platform_family?('rhel') && node['platform_version'] >= '9' + false + else + true + end -# Install postfix on RHEL to ensure we don't properly break mysql-libs compatibility -package 'postfix' if platform_family?('rhel') - +include_recipe 'test::_remove_mariadb_libs' include_recipe 'test::_remove_mysql_common' include_recipe 'percona::server' include_recipe 'percona::backup' + +# Install postfix on RHEL to ensure we don't properly break mysql-libs compatibility +package 'postfix' if platform_family?('rhel') diff --git a/test/fixtures/cookbooks/test/recipes/user_database.rb b/test/fixtures/cookbooks/test/recipes/user_database.rb index c6cc81d0..2effa520 100644 --- a/test/fixtures/cookbooks/test/recipes/user_database.rb +++ b/test/fixtures/cookbooks/test/recipes/user_database.rb @@ -66,6 +66,36 @@ action :run end +# Create a user to test ctrl_user, ctrl_password, and ctrl_host +bash 'create beauregard' do + code <<-EOF + echo "CREATE USER 'beauregard'@'localhost' IDENTIFIED BY '>mupp3ts'; GRANT ALL PRIVILEGES ON *.* TO 'beauregard'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES;" | /usr/bin/mysql -u root; + touch /tmp/beauregardmarker + EOF + not_if { ::File.exist?('/tmp/beauregardmarker') } + action :run +end + +# Create a user to test mysql_database_user password update via :create and non-root user +bash 'create waldorf@localhost' do + code <<-EOF + echo "CREATE USER 'waldorf'@'localhost' IDENTIFIED BY 'balcony';" | /usr/bin/mysql -u root; + touch /tmp/waldorf_localhostmarker + EOF + not_if { ::File.exist?('/tmp/waldorf_localhostmarker') } + action :run +end + +# Create a user to test mysql_database_user password update via :create and non-root user +bash 'create waldorf' do + code <<-EOF + echo "CREATE USER 'waldorf'@'127.0.0.1' IDENTIFIED BY 'boxseat';" | /usr/bin/mysql -u root; + touch /tmp/waldorf_127marker + EOF + not_if { ::File.exist?('/tmp/waldorf_127marker') } + action :run +end + ## Resources we're testing percona_mysql_database 'databass' do action :create @@ -170,6 +200,27 @@ action :create end +# Create new user with a ctrl_user as non-root to test ctrl_hash and validate ctrl_password with special character +percona_mysql_user 'bunsen' do + database_name 'datasalmon' + password 'honeydont' + ctrl_user 'beauregard' + ctrl_password '>mupp3ts' + ctrl_host '127.0.0.1' + host 'localhost' + privileges [:select] + action [:create, :grant] +end + +percona_mysql_user 'waldorf' do + password 'balcony' + ctrl_user 'beauregard' + ctrl_password '>mupp3ts' + ctrl_host '127.0.0.1' + host '127.0.0.1' + action :create +end + percona_mysql_database 'flush privileges' do database_name 'databass' password '' diff --git a/test/integration/inspec/controls/resources_spec.rb b/test/integration/inspec/controls/resources_spec.rb index a57cb13a..b38f625b 100644 --- a/test/integration/inspec/controls/resources_spec.rb +++ b/test/integration/inspec/controls/resources_spec.rb @@ -53,4 +53,8 @@ describe sql.query("SELECT #{password_column} FROM mysql.user WHERE user='rizzo' AND host='127.0.0.1'") do its(:stdout) { should include '*125EA03B506F7C876D9321E9055F37601461E970' } end + + describe sql.query('select User,Host from mysql.user') do + its(:stdout) { should match(/bunsen/) } + end end From 55e96c26fdc1a5cc2e7d3077f0b74c96c06e4b80 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 25 Apr 2023 20:55:54 +0100 Subject: [PATCH 274/300] Update changelog for 3.3.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5292925a..b92efe30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.3.0 - *2023-04-25* - Fixed the user key in the ctrl_hash for the run_query method in the mysql_user custom resource - Updated ctrl_hash (now user_hash) parameters to validate if a user can login using username@host instead of username@ctrl_host From 1decaa706e3da519b6421f26c54b5ef5b18abfa0 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 25 Apr 2023 20:55:55 +0100 Subject: [PATCH 275/300] Update metadata for 3.3.0 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 5a4dad74..6ed43638 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/percona' issues_url 'https://github.com/sous-chefs/percona/issues' -version '3.2.11' +version '3.3.0' chef_version '>= 16.0' depends 'yum' From d3d0e50d644aecb9552e7a39629e92f7d6ed9dc7 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Tue, 25 Apr 2023 20:55:58 +0100 Subject: [PATCH 276/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b92efe30..8f8b1b5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.3.0 - *2023-04-25* - Fixed the user key in the ctrl_hash for the run_query method in the mysql_user custom resource From 1ed37ca62692090991cbded04ff7f9e2911eccda Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 May 2023 12:19:37 +0100 Subject: [PATCH 277/300] Update sous-chefs/.github action to v2.0.4 (#477) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 690e2c0f..903b114d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ name: ci jobs: lint-unit: - uses: sous-chefs/.github/.github/workflows/lint-unit.yml@2.0.2 + uses: sous-chefs/.github/.github/workflows/lint-unit.yml@2.0.4 permissions: actions: write checks: write From ce81f992cd99544997aa1339a9c97cb04d66ac62 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 17 May 2023 12:19:40 +0100 Subject: [PATCH 278/300] Update changelog for 3.3.1 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f8b1b5f..826bc658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.3.1 - *2023-05-17* ## 3.3.0 - *2023-04-25* From 229f61ff893649b7aa05a23443336478a83969ca Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 17 May 2023 12:19:41 +0100 Subject: [PATCH 279/300] Update metadata for 3.3.1 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 6ed43638..b2b640e8 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/percona' issues_url 'https://github.com/sous-chefs/percona/issues' -version '3.3.0' +version '3.3.1' chef_version '>= 16.0' depends 'yum' From 36c5a66b440c9ae693099d991fc283c2275d39fa Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 17 May 2023 12:19:44 +0100 Subject: [PATCH 280/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 826bc658..1b32afe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.3.1 - *2023-05-17* ## 3.3.0 - *2023-04-25* From cb95ba61469f94edca950e32c2509c84f3a96236 Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Wed, 7 Jun 2023 01:54:21 -0700 Subject: [PATCH 281/300] Various Percona Configuration Improvements (#478) * Avoid creating tmp dir if /tmp * Remove duplicate table_definition_cache line from template * Move mysqld configuration to the existing section * Remove open file limit from systemd unit We manage the open files in the configure_server recipe my.cnf template so there is no need to have a (rather restrictive) limit in place from systemd --- CHANGELOG.md | 5 +++++ recipes/configure_server.rb | 1 + recipes/server.rb | 6 ++++++ spec/configure_server_spec.rb | 8 ++------ spec/server_spec.rb | 12 ++++++++++++ templates/my.cnf.main.erb | 9 +++++++-- test/integration/inspec/controls/server_spec.rb | 6 ------ 7 files changed, 33 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b32afe8..35a5923a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- Avoid changing the perms on /tmp +- Remove duplicate configuration line +- Avoid duplicating mysqld configuration section in my.cnf +- Remove the open file limit from the systemd unit since it is already set in my.cnf anyway + ## 3.3.1 - *2023-05-17* ## 3.3.0 - *2023-04-25* diff --git a/recipes/configure_server.rb b/recipes/configure_server.rb index bc3b4fb9..72e10285 100644 --- a/recipes/configure_server.rb +++ b/recipes/configure_server.rb @@ -92,6 +92,7 @@ owner user group user recursive true + not_if { tmpdir == '/tmp' } end # setup the configuration include directory diff --git a/recipes/server.rb b/recipes/server.rb index b97d0a75..786be33b 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -25,6 +25,12 @@ pattern /^PIDFile=.*/ notifies :run, 'execute[systemctl daemon-reload]', :immediately end + + delete_lines 'remove LimitNOFILE from systemd.service' do + path '/usr/lib/systemd/system/mysqld.service' + pattern /^LimitNOFILE =.*/ + notifies :run, 'execute[systemctl daemon-reload]', :immediately + end end end diff --git a/spec/configure_server_spec.rb b/spec/configure_server_spec.rb index c6f919bf..dce8b322 100644 --- a/spec/configure_server_spec.rb +++ b/spec/configure_server_spec.rb @@ -84,12 +84,8 @@ ) end - it 'creates the temporary directory' do - expect(chef_run).to create_directory('/tmp').with( - owner: 'mysql', - group: 'mysql', - recursive: true - ) + it 'does not create temporary directory since it is /tmp' do + expect(chef_run).to_not create_directory('/tmp') end it 'creates the configuration include directory' do diff --git a/spec/server_spec.rb b/spec/server_spec.rb index da06fc5f..dc46040c 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -55,6 +55,18 @@ notify('execute[systemctl daemon-reload]').to(:run).immediately end + it do + expect(chef_run).to edit_delete_lines('remove LimitNOFILE from systemd.service').with( + path: '/usr/lib/systemd/system/mysqld.service' + # pattern: /^LimitNOFILE =.*/ TODO: this errors out with + ) + end + + it do + expect(chef_run.delete_lines('remove LimitNOFILE from systemd.service')).to \ + notify('execute[systemctl daemon-reload]').to(:run).immediately + end + context 'version 5.7' do override_attributes['percona']['version'] = '5.7' it do diff --git a/templates/my.cnf.main.erb b/templates/my.cnf.main.erb index 06a07cb1..23a19d5a 100644 --- a/templates/my.cnf.main.erb +++ b/templates/my.cnf.main.erb @@ -229,8 +229,6 @@ table_definition_cache = <%= node["percona"]["server"]["table_definition_cache" <%- end %> <%- end %> -table_definition_cache = <%= node["percona"]["server"]["table_definition_cache"] %> - #thread_concurrency = 10 <%- if node["percona"]["version"].to_i < 8 %> # @@ -648,6 +646,11 @@ innodb_numa_interleave=<%= node["percona"]["server"]["innodb_numa_interleave"] % ssl-key=/etc/mysql/ssl/server-key.pem <% end %> +<% unless node["percona"]["conf"].nil? or node["percona"]["conf"]["mysqld"].nil? %> +<% node["percona"]["conf"]["mysqld"].keys.each do |key| %> + <%= "#{key} = #{node["percona"]["conf"]["mysqld"][key]}" %> +<% end %> +<% end %> [mysqldump] quick @@ -663,6 +666,7 @@ key_buffer_size = <%= node["percona"]["server"]["key_buffer_size"] %> ##### custom configurations go here <% unless node["percona"]["conf"].nil? or node["percona"]["conf"].empty? %> <% node["percona"]["conf"].keys.each do |category| %> +<% unless category == 'mysqld' %> <%= "[#{category}]" %> <% node["percona"]["conf"][category].keys.each do |key| %> @@ -671,6 +675,7 @@ key_buffer_size = <%= node["percona"]["server"]["key_buffer_size"] %> <% end %> <% end %> +<% end %> # # * IMPORTANT: Additional settings that can override those from this file! diff --git a/test/integration/inspec/controls/server_spec.rb b/test/integration/inspec/controls/server_spec.rb index c7d56bbf..3b34a721 100644 --- a/test/integration/inspec/controls/server_spec.rb +++ b/test/integration/inspec/controls/server_spec.rb @@ -153,12 +153,6 @@ end describe file '/var/log/mysql' do - it { should be_a_directory } - its('owner') { should cmp 'mysql' } - its('group') { should cmp 'mysql' } - end - - describe file '/tmp' do it { should be_a_directory } its('owner') { should cmp 'mysql' } its('group') { should cmp 'mysql' } From 9d3d27e861a6258e0b2d496a38099f317584cb1c Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 7 Jun 2023 09:54:25 +0100 Subject: [PATCH 282/300] Update changelog for 3.4.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35a5923a..fef8d34e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.4.0 - *2023-06-07* - Avoid changing the perms on /tmp - Remove duplicate configuration line From 93b36ce9c6f88a5c835d3a5cafe1c0812d25f046 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 7 Jun 2023 09:54:25 +0100 Subject: [PATCH 283/300] Update metadata for 3.4.0 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index b2b640e8..3dab7a53 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/percona' issues_url 'https://github.com/sous-chefs/percona/issues' -version '3.3.1' +version '3.4.0' chef_version '>= 16.0' depends 'yum' From d3ecefe8079d4e0973dcd2798651c4b122f8825a Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Wed, 7 Jun 2023 09:54:28 +0100 Subject: [PATCH 284/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fef8d34e..4593e0ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.4.0 - *2023-06-07* - Avoid changing the perms on /tmp From deee1ee73c9186d40782422bde2109441a13a134 Mon Sep 17 00:00:00 2001 From: Ethan Hampton Date: Wed, 14 Jun 2023 16:04:24 -0700 Subject: [PATCH 285/300] Fix systemd open files limit configuration (#479) * Fix systemd open files limit configuration * Fix mysqladmin server tests * Match default table_cache value to runtime value Since by default open_files_limit is set to 16384, table_open_cache is set according to that limit. This matches the values so they aren't changed at runtime * Fix debian open files tests Don't test for number of open files on debian based systems, since they are inconsistent in applying the restrictions and RHEL derivatives are the target of the logic anyway --- CHANGELOG.md | 2 ++ attributes/default.rb | 2 +- recipes/server.rb | 3 ++- spec/server_spec.rb | 7 ++++--- test/integration/inspec/controls/server_spec.rb | 7 +++++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4593e0ee..4f655b6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the percona cookbook. ## Unreleased +- Fix adjustment of open files limit within systemd unit + ## 3.4.0 - *2023-06-07* - Avoid changing the perms on /tmp diff --git a/attributes/default.rb b/attributes/default.rb index fff8dd77..906956c5 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -100,7 +100,7 @@ default['percona']['server']['max_connections'] = 30 default['percona']['server']['max_connect_errors'] = 9_999_999 default['percona']['server']['sql_modes'] = [] -default['percona']['server']['table_cache'] = 8192 +default['percona']['server']['table_cache'] = 8172 default['percona']['server']['table_definition_cache'] = '-1' # <5.6, use 4096 default['percona']['server']['group_concat_max_len'] = 4096 default['percona']['server']['expand_fast_index_creation'] = false diff --git a/recipes/server.rb b/recipes/server.rb index 786be33b..9dca37e6 100644 --- a/recipes/server.rb +++ b/recipes/server.rb @@ -26,9 +26,10 @@ notifies :run, 'execute[systemctl daemon-reload]', :immediately end - delete_lines 'remove LimitNOFILE from systemd.service' do + replace_or_add 'configure LimitNOFILE in systemd.service' do path '/usr/lib/systemd/system/mysqld.service' pattern /^LimitNOFILE =.*/ + line "LimitNOFILE = #{node['percona']['server']['open_files_limit']}" notifies :run, 'execute[systemctl daemon-reload]', :immediately end end diff --git a/spec/server_spec.rb b/spec/server_spec.rb index dc46040c..492b43ee 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -56,14 +56,15 @@ end it do - expect(chef_run).to edit_delete_lines('remove LimitNOFILE from systemd.service').with( - path: '/usr/lib/systemd/system/mysqld.service' + expect(chef_run).to edit_replace_or_add('configure LimitNOFILE in systemd.service').with( + path: '/usr/lib/systemd/system/mysqld.service', + line: 'LimitNOFILE = 16384' # pattern: /^LimitNOFILE =.*/ TODO: this errors out with ) end it do - expect(chef_run.delete_lines('remove LimitNOFILE from systemd.service')).to \ + expect(chef_run.replace_or_add('configure LimitNOFILE in systemd.service')).to \ notify('execute[systemctl daemon-reload]').to(:run).immediately end diff --git a/test/integration/inspec/controls/server_spec.rb b/test/integration/inspec/controls/server_spec.rb index 3b34a721..fd267814 100644 --- a/test/integration/inspec/controls/server_spec.rb +++ b/test/integration/inspec/controls/server_spec.rb @@ -243,8 +243,11 @@ end describe command "mysqladmin --user='root' --password='7tCk(V5I' variables" do - its('stdout') { should match %r{datadir\s+| /tmp/mysql/} } - its('stdout') { should match %r{general_log_file\s+| /tmp/mysql/} } + its('stdout') { should match %r{datadir\s+\| /tmp/mysql/} } + its('stdout') { should match %r{general_log_file\s+\| /tmp/mysql/} } + its('stdout') { should match /max_connections\s+\| 30/ } + its('stdout') { should match /table_open_cache\s+\| 8172/ } unless os.family == 'debian' # (open_files_limit - 10 - max_connections) / 2 + its('stdout') { should match /open_files_limit\s+\| 16384/ } unless os.family == 'debian' its('exit_status') { should eq 0 } end end From a20d2baa0010ee81062a0b26c1a7aff3f1a42262 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 15 Jun 2023 00:04:27 +0100 Subject: [PATCH 286/300] Update changelog for 3.4.1 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f655b6b..cda3d407 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.4.1 - *2023-06-14* - Fix adjustment of open files limit within systemd unit From 9a5af6e09f8318b0ee04abaf6ee50c7df8995742 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 15 Jun 2023 00:04:28 +0100 Subject: [PATCH 287/300] Update metadata for 3.4.1 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 3dab7a53..ee69cff3 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/percona' issues_url 'https://github.com/sous-chefs/percona/issues' -version '3.4.0' +version '3.4.1' chef_version '>= 16.0' depends 'yum' From 58e1049dd6a1eebd95ae8a682745fb6967abeeab Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 15 Jun 2023 00:04:30 +0100 Subject: [PATCH 288/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cda3d407..09b09601 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.4.1 - *2023-06-14* - Fix adjustment of open files limit within systemd unit From 7986fb7bef6c6c0f593336a283ff735398126686 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:09:00 +0100 Subject: [PATCH 289/300] Update sous-chefs/.github action to v2.0.5 (#480) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 903b114d..12ca204d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ name: ci jobs: lint-unit: - uses: sous-chefs/.github/.github/workflows/lint-unit.yml@2.0.4 + uses: sous-chefs/.github/.github/workflows/lint-unit.yml@2.0.5 permissions: actions: write checks: write From 8380e105abd40bac79f612edc135483c8b3ab78e Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:09:04 +0100 Subject: [PATCH 290/300] Update changelog for 3.4.2 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09b09601..7b8148d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.4.2 - *2023-07-10* ## 3.4.1 - *2023-06-14* From 150ac2cbc008b4f9b5655d4095920e0febcde5f9 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:09:05 +0100 Subject: [PATCH 291/300] Update metadata for 3.4.2 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index ee69cff3..cbb26bc8 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/percona' issues_url 'https://github.com/sous-chefs/percona/issues' -version '3.4.1' +version '3.4.2' chef_version '>= 16.0' depends 'yum' From 26205bce9a50bace02c09a522a436083a13dc2f1 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:09:07 +0100 Subject: [PATCH 292/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b8148d3..5b5013b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.4.2 - *2023-07-10* ## 3.4.1 - *2023-06-14* From 32122f2f462c8b22906b8bc1fa59cdde769261c7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 15:55:59 +0100 Subject: [PATCH 293/300] Update actions/checkout action to v4 (#481) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12ca204d..eebf0be6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Chef uses: actionshub/chef-install@2.0.4 # https://github.com/actions/virtual-environments/issues/181#issuecomment-610874237 From aca76558e81ed8b5def2fc8cac2f1091b78973b1 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 4 Sep 2023 15:56:02 +0100 Subject: [PATCH 294/300] Update changelog for 3.4.3 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b5013b6..945b01ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.4.3 - *2023-09-04* ## 3.4.2 - *2023-07-10* From bbf075a5d916687f59f7e21717f847828d1d866a Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 4 Sep 2023 15:56:02 +0100 Subject: [PATCH 295/300] Update metadata for 3.4.3 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index cbb26bc8..36ede0b8 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/percona' issues_url 'https://github.com/sous-chefs/percona/issues' -version '3.4.2' +version '3.4.3' chef_version '>= 16.0' depends 'yum' From 4434c07f64de6e8476a16a7013d2ab843952da22 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Mon, 4 Sep 2023 15:56:05 +0100 Subject: [PATCH 296/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 945b01ef..35b621a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.4.3 - *2023-09-04* ## 3.4.2 - *2023-07-10* From 96449b82eb9e8751d4ce6fdb97a3ec1ca8ecb3b8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:39:56 +0800 Subject: [PATCH 297/300] Update sous-chefs/.github action to v2.0.6 (#482) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eebf0be6..570fe5c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ name: ci jobs: lint-unit: - uses: sous-chefs/.github/.github/workflows/lint-unit.yml@2.0.5 + uses: sous-chefs/.github/.github/workflows/lint-unit.yml@2.0.6 permissions: actions: write checks: write From 4885bd984c1673c60d28404c0ecc36fdb4cd6571 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 28 Sep 2023 02:39:59 +0100 Subject: [PATCH 298/300] Update changelog for 3.4.4 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35b621a0..acce2ec6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file is used to list changes made in each version of the percona cookbook. -## Unreleased +## 3.4.4 - *2023-09-28* ## 3.4.3 - *2023-09-04* From 7ea0d8680c0e2534761fdece1aae6f53e2d021de Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 28 Sep 2023 02:39:59 +0100 Subject: [PATCH 299/300] Update metadata for 3.4.4 --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 36ede0b8..da13cdc7 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Installs Percona MySQL client and server' source_url 'https://github.com/sous-chefs/percona' issues_url 'https://github.com/sous-chefs/percona/issues' -version '3.4.3' +version '3.4.4' chef_version '>= 16.0' depends 'yum' From 7a9149058f95eae10b36c4fedbf7c06ffa544fc5 Mon Sep 17 00:00:00 2001 From: Sous Chefs Bot <33356041+kitchen-porter@users.noreply.github.com> Date: Thu, 28 Sep 2023 02:40:02 +0100 Subject: [PATCH 300/300] Set Changelog to ## Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index acce2ec6..08d39dfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This file is used to list changes made in each version of the percona cookbook. +## Unreleased + ## 3.4.4 - *2023-09-28* ## 3.4.3 - *2023-09-04*