├── .gitignore ├── encrypted_data_bag_secret ├── cookbooks ├── playground │ ├── CHANGELOG.md │ ├── recipes │ │ └── default.rb │ ├── metadata.rb │ └── README.md ├── playground-mysql │ ├── CHANGELOG.md │ ├── attributes │ │ └── default.rb │ ├── recipes │ │ └── default.rb │ ├── metadata.rb │ └── README.md └── mysql │ ├── libraries │ ├── provider_mysql_client.rb │ ├── provider_mysql_service.rb │ ├── resource_mysql_client.rb │ ├── matchers.rb │ ├── provider_mysql_client_smartos.rb │ ├── provider_mysql_client_debian.rb │ ├── provider_mysql_client_ubuntu.rb │ ├── provider_mysql_client_fedora.rb │ ├── provider_mysql_client_omnios.rb │ ├── provider_mysql_client_rhel.rb │ ├── resource_mysql_service.rb │ ├── provider_mysql_service_fedora.rb │ ├── provider_mysql_service_debian.rb │ ├── helpers.rb │ ├── provider_mysql_service_ubuntu.rb │ ├── provider_mysql_service_smartos.rb │ ├── provider_mysql_service_omnios.rb │ └── provider_mysql_service_rhel.rb │ ├── templates │ └── default │ │ ├── debian │ │ ├── debian.cnf.erb │ │ └── mysql-server.seed.erb │ │ ├── smartos │ │ ├── svc.method.mysqld.erb │ │ └── mysql.xml.erb │ │ ├── omnios │ │ ├── svc.method.mysqld.erb │ │ └── mysql.xml.erb │ │ ├── 5.0 │ │ └── my.cnf.erb │ │ ├── 5.1 │ │ └── my.cnf.erb │ │ ├── 5.5 │ │ └── my.cnf.erb │ │ ├── apparmor │ │ └── usr.sbin.mysqld.erb │ │ ├── 5.6 │ │ └── my.cnf.erb │ │ ├── grants │ │ └── grants.sql.erb │ │ └── deprecated │ │ └── my.cnf.erb │ ├── metadata.rb │ ├── attributes │ └── default.rb │ ├── recipes │ ├── client.rb │ ├── server.rb │ └── server_deprecated.rb │ ├── metadata.json │ ├── README.md │ └── CHANGELOG.md ├── environments ├── vagrant.rb └── test.rb ├── data_bags └── mysql │ └── passwords.json ├── Vagrantfile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant -------------------------------------------------------------------------------- /encrypted_data_bag_secret: -------------------------------------------------------------------------------- 1 | topsecret 2 | -------------------------------------------------------------------------------- /cookbooks/playground/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | playground CHANGELOG 2 | ==================== 3 | 4 | 0.1.0 5 | ----- 6 | - Initial release of playground 7 | -------------------------------------------------------------------------------- /cookbooks/playground-mysql/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | playground-mysql CHANGELOG 2 | ========================== 3 | 4 | 0.1.0 5 | ----- 6 | - Initial release of playground-mysql 7 | -------------------------------------------------------------------------------- /cookbooks/playground-mysql/attributes/default.rb: -------------------------------------------------------------------------------- 1 | mysql_creds = Chef::EncryptedDataBagItem.load "mysql", "passwords", "topsecret" 2 | default["mysql"]["server_root_password"] = mysql_creds[node.chef_environment]['server_root_password'] 3 | -------------------------------------------------------------------------------- /environments/vagrant.rb: -------------------------------------------------------------------------------- 1 | name "vagrant" 2 | description "Used for development." 3 | #default_attributes "mysql" => { "server_root_password" => "pieceofshit" } 4 | #override_attributes "mysql" => { "server_root_password" => "pieceofshit" } 5 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_client.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlClient < Chef::Provider::LWRPBase 6 | def action_create 7 | end 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_service.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlService < Chef::Provider::LWRPBase 6 | def action_create 7 | end 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /cookbooks/playground-mysql/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: playground-mysql 3 | # Recipe:: default 4 | # 5 | # Copyright 2014, viasto GmbH 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | 10 | include_recipe "mysql::server" -------------------------------------------------------------------------------- /environments/test.rb: -------------------------------------------------------------------------------- 1 | name "test" 2 | description "Used for testing." 3 | cookbook_versions "mysql" => "= 5.1.2" 4 | #default_attributes "mysql" => { "server_root_password" => "pieceoffuckingshit" } 5 | #override_attributes "mysql" => { "server_root_password" => "pieceofshit" } -------------------------------------------------------------------------------- /cookbooks/playground/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: playground 3 | # Recipe:: default 4 | # 5 | # Copyright 2014, viasto GmbH 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | 10 | execute "apt-get update" do 11 | ignore_failure true 12 | end 13 | 14 | include_recipe "playground-mysql" 15 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/resource_mysql_client.rb: -------------------------------------------------------------------------------- 1 | require 'chef/resource/lwrp_base' 2 | 3 | class Chef 4 | class Resource 5 | class MysqlClient < Chef::Resource::LWRPBase 6 | self.resource_name = :mysql_client 7 | actions :create, :delete 8 | default_action :create 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /cookbooks/playground-mysql/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'playground-mysql' 2 | maintainer 'viasto GmbH' 3 | maintainer_email 'max.ludwig@viasto.com' 4 | license 'All rights reserved' 5 | description 'Installs/Configures playground-mysql' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.0' 8 | 9 | supports "ubuntu" 10 | 11 | depends "mysql" -------------------------------------------------------------------------------- /cookbooks/playground/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'playground' 2 | maintainer 'viasto GmbH' 3 | maintainer_email 'max.ludwig@viasto.com' 4 | license 'All rights reserved' 5 | description 'Installs/Configures playground' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.0' 8 | 9 | supports "ubuntu" 10 | 11 | depends "playground-mysql" 12 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/debian/debian.cnf.erb: -------------------------------------------------------------------------------- 1 | [client] 2 | host = localhost 3 | user = debian-sys-maint 4 | password = <%= node['mysql']['server_debian_password'] %> 5 | socket = /var/run/mysqld/mysqld.sock 6 | 7 | [mysql_upgrade] 8 | host = localhost 9 | user = debian-sys-maint 10 | password = <%= node['mysql']['server_debian_password'] %> 11 | socket = /var/run/mysqld/mysqld.sock 12 | basedir = /usr 13 | -------------------------------------------------------------------------------- /cookbooks/mysql/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'mysql' 2 | maintainer 'Chef Software, Inc.' 3 | maintainer_email 'cookbooks@getchef.com' 4 | license 'Apache 2.0' 5 | description 'Provides mysql_service and mysql_client resources' 6 | 7 | version '5.1.2' 8 | 9 | supports 'amazon' 10 | supports 'redhat' 11 | supports 'centos' 12 | supports 'scientific' 13 | supports 'fedora' 14 | supports 'debian' 15 | supports 'ubuntu' 16 | supports 'smartos' 17 | supports 'omnios' 18 | -------------------------------------------------------------------------------- /data_bags/mysql/passwords.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "passwords", 3 | "vagrant": { 4 | "encrypted_data": "0S9QUdzDUZg+32flqWrs7nXQWXYGsWeOik/KatvRpVbP1WpXQHmqDTjtzXm8\ncimixcYEvBhMdd1MU72XSOQJcQ==\n", 5 | "iv": "rn6/mJe8oaDGXdnQc31LIA==\n", 6 | "version": 1, 7 | "cipher": "aes-256-cbc" 8 | }, 9 | "test": { 10 | "encrypted_data": "3Xmh7VxzltRnN2PzQxGe04yOklPA4MFClqStJLFAaiM2beI3mj8tFkls8Uw+\nQSH3cOa+g/IC4EROglw843UqXg==\n", 11 | "iv": "F20MStbK/1Y7XcPlr/xXWQ==\n", 12 | "version": 1, 13 | "cipher": "aes-256-cbc" 14 | } 15 | } -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | def create_mysql_client(resource_name) 3 | ChefSpec::Matchers::ResourceMatcher.new(:mysql_client, :create, resource_name) 4 | end 5 | 6 | def delete_mysql_client(resource_name) 7 | ChefSpec::Matchers::ResourceMatcher.new(:mysql_client, :delete, resource_name) 8 | end 9 | 10 | def create_mysql_service(resource_name) 11 | ChefSpec::Matchers::ResourceMatcher.new(:mysql_service, :create, resource_name) 12 | end 13 | 14 | def enable_mysql_service(resource_name) 15 | ChefSpec::Matchers::ResourceMatcher.new(:mysql_service, :enable, resource_name) 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /cookbooks/mysql/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | default['mysql']['service_name'] = 'default' 3 | 4 | # passwords 5 | default['mysql']['server_root_password'] = 'ilikerandompasswords' 6 | default['mysql']['server_debian_password'] = 'postinstallscriptsarestupid' 7 | 8 | case node['platform'] 9 | when 'smartos' 10 | default['mysql']['data_dir'] = '/opt/local/lib/mysql' 11 | else 12 | default['mysql']['data_dir'] = '/var/lib/mysql' 13 | end 14 | 15 | # port 16 | default['mysql']['port'] = '3306' 17 | 18 | # used in grants.sql 19 | default['mysql']['allow_remote_root'] = false 20 | default['mysql']['remove_anonymous_users'] = true 21 | default['mysql']['root_network_acl'] = nil 22 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/smartos/svc.method.mysqld.erb: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | # 3 | # Generated by Chef 4 | # 5 | 6 | . /lib/svc/share/smf_include.sh 7 | 8 | PIDFILE="/var/mysql/mysql.pid" 9 | 10 | ulimit -n 10240 11 | 12 | case "$1" in 13 | start) 14 | /opt/local/sbin/mysqld --user=mysql \ 15 | --basedir=/opt/local \ 16 | --datadir=<%= @data_dir %> \ 17 | --pid-file=${PIDFILE} \ 18 | --log-error=/var/log/mysql/error.log & 19 | ;; 20 | stop) 21 | [ -f ${PIDFILE} ] && kill `/usr/bin/head -1 ${PIDFILE}` 22 | ;; 23 | *) 24 | echo "Usage: $0 {start|stop}" >&2 25 | exit 1 26 | ;; 27 | esac 28 | 29 | exit $SMF_EXIT_OK 30 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/omnios/svc.method.mysqld.erb: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | # 3 | # Generated by Chef 4 | # 5 | 6 | . /lib/svc/share/smf_include.sh 7 | 8 | PIDFILE=<%= @pid_file %> 9 | 10 | ulimit -n 10240 11 | 12 | case "$1" in 13 | start) 14 | <%= @base_dir %>/bin/mysqld --user=mysql \ 15 | --basedir=<%= @base_dir %> \ 16 | --datadir=<%= @data_dir %> \ 17 | --pid-file=${PIDFILE} \ 18 | --log-error=/var/log/mysql/error.log & 19 | ;; 20 | stop) 21 | [ -f ${PIDFILE} ] && kill `/usr/bin/head -1 ${PIDFILE}` 22 | ;; 23 | *) 24 | echo "Usage: $0 {start|stop}" >&2 25 | exit 1 26 | ;; 27 | esac 28 | 29 | exit $SMF_EXIT_OK 30 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | VAGRANTFILE_API_VERSION = "2" 5 | 6 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 7 | 8 | config.vm.hostname = "vagrant" 9 | config.vm.box = "deshene/precise64-2.0.0-11.10.4" 10 | 11 | config.vm.provider "virtualbox" do |vb| 12 | #vb.gui = true 13 | vb.customize ["modifyvm", :id, "--memory", "1024"] 14 | end 15 | 16 | config.vm.provision "chef_solo" do |chef| 17 | chef.environments_path = "environments" 18 | chef.roles_path = "roles" 19 | chef.data_bags_path = "data_bags" 20 | chef.encrypted_data_bag_secret_key_path = "." 21 | chef.environment = "vagrant" 22 | chef.add_role "database" 23 | chef.add_recipe "playground" 24 | chef.add_recipe "mysql::server" 25 | end 26 | 27 | end 28 | -------------------------------------------------------------------------------- /cookbooks/mysql/recipes/client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Recipe:: client 4 | # 5 | # Copyright 2008-2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | mysql_client 'default' do 21 | action :create 22 | end 23 | -------------------------------------------------------------------------------- /cookbooks/mysql/recipes/server.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: mysql 3 | # Recipe:: server 4 | # 5 | # Copyright 2008-2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | mysql_service node['mysql']['service_name'] do 21 | port node['mysql']['port'] 22 | data_dir node['mysql']['data_dir'] 23 | end 24 | -------------------------------------------------------------------------------- /cookbooks/mysql/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mysql", 3 | "version": "5.1.2", 4 | "description": "Provides mysql_service and mysql_client resources", 5 | "long_description": "", 6 | "maintainer": "Chef Software, Inc.", 7 | "maintainer_email": "cookbooks@getchef.com", 8 | "license": "Apache 2.0", 9 | "platforms": { 10 | "amazon": ">= 0.0.0", 11 | "redhat": ">= 0.0.0", 12 | "centos": ">= 0.0.0", 13 | "scientific": ">= 0.0.0", 14 | "fedora": ">= 0.0.0", 15 | "debian": ">= 0.0.0", 16 | "ubuntu": ">= 0.0.0", 17 | "smartos": ">= 0.0.0", 18 | "omnios": ">= 0.0.0" 19 | }, 20 | "dependencies": { 21 | }, 22 | "recommendations": { 23 | }, 24 | "suggestions": { 25 | }, 26 | "conflicting": { 27 | }, 28 | "providing": { 29 | }, 30 | "replacing": { 31 | }, 32 | "attributes": { 33 | }, 34 | "groupings": { 35 | }, 36 | "recipes": { 37 | } 38 | } -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/debian/mysql-server.seed.erb: -------------------------------------------------------------------------------- 1 | mysql-server-5.5 mysql-server/root_password_again select <%= node['mysql']['server_root_password'] %> 2 | mysql-server-5.5 mysql-server/root_password select <%= node['mysql']['server_root_password'] %> 3 | mysql-server-5.5 mysql-server-5.5/really_downgrade boolean false 4 | mysql-server-5.5 mysql-server-5.5/need_sarge_compat boolean false 5 | mysql-server-5.5 mysql-server-5.5/start_on_boot boolean false 6 | mysql-server-5.5 mysql-server/error_setting_password boolean false 7 | mysql-server-5.5 mysql-server-5.5/nis_warning note 8 | mysql-server-5.5 mysql-server-5.5/postrm_remove_databases boolean false 9 | mysql-server-5.5 mysql-server/password_mismatch boolean false 10 | mysql-server-5.5 mysql-server-5.5/need_sarge_compat_done boolean true 11 | -------------------------------------------------------------------------------- /cookbooks/mysql/recipes/server_deprecated.rb: -------------------------------------------------------------------------------- 1 | # Mysql Cookbook 2 | # mysql::server_deprecated 3 | # 4 | # Copyright 2008-2013, Chef Software, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | mysql_service node['mysql']['service_name'] do 20 | port node['mysql']['port'] 21 | data_dir node['mysql']['data_dir'] 22 | template_source 'deprecated/my.cnf.erb' 23 | end 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chef Playground 2 | 3 | This is basically a normal chef repository. I created it mainly for testing and 4 | learning purposes. 5 | 6 | It's intended to be used with chef-solo and vagrant. For encrypted data bags I 7 | installed [knife-solo][1] and [knife-solo\_data\_bag][2]. 8 | 9 | There is already an encrypted data bag and you can show or edit it with these 10 | commands: 11 | 12 | $ knife solo data bag show mysql passwords --secret topsecret 13 | $ knife solo data bag edit mysql passwords --secret topsecret 14 | 15 | I'm passing the secret in directly but there is also a secret file 16 | (`encrypted_data_bag_secret`) with the same secret. To use it you have to use 17 | `--secret-file` instead of `--secret` with the knife command and then load the 18 | secret file whereever you need it (recipes, roles, environments, ...). 19 | 20 | [1]: https://github.com/matschaffer/knife-solo 21 | [2]: https://github.com/thbishop/knife-solo_data_bag -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_client_smartos.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlClient 6 | class Smartos < Chef::Provider::MysqlClient 7 | use_inline_resources if defined?(use_inline_resources) 8 | 9 | def whyrun_supported? 10 | true 11 | end 12 | 13 | action :create do 14 | converge_by 'smartos pattern' do 15 | package 'mysql-client' do 16 | action :install 17 | end 18 | end 19 | end 20 | 21 | action :delete do 22 | converge_by 'smartos pattern' do 23 | package 'mysql-client' do 24 | action :remove 25 | end 26 | end 27 | end 28 | end 29 | end 30 | end 31 | end 32 | 33 | Chef::Platform.set :platform => :smartos, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Smartos 34 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_client_debian.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlClient 6 | class Debian < Chef::Provider::MysqlClient 7 | use_inline_resources if defined?(use_inline_resources) 8 | 9 | def whyrun_supported? 10 | true 11 | end 12 | 13 | action :create do 14 | converge_by 'debian pattern' do 15 | %w(mysql-client libmysqlclient-dev).each do |p| 16 | package p do 17 | action :install 18 | end 19 | end 20 | end 21 | end 22 | 23 | action :delete do 24 | converge_by 'debian pattern' do 25 | %w(mysql-client libmysqlclient-dev).each do |p| 26 | package p do 27 | action :remove 28 | end 29 | end 30 | end 31 | end 32 | end 33 | end 34 | end 35 | end 36 | 37 | Chef::Platform.set :platform => :debian, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Debian 38 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_client_ubuntu.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlClient 6 | class Ubuntu < Chef::Provider::MysqlClient 7 | use_inline_resources if defined?(use_inline_resources) 8 | 9 | def whyrun_supported? 10 | true 11 | end 12 | 13 | action :create do 14 | converge_by 'ubuntu pattern' do 15 | %w(mysql-client libmysqlclient-dev).each do |p| 16 | package p do 17 | action :install 18 | end 19 | end 20 | end 21 | end 22 | 23 | action :delete do 24 | converge_by 'ubuntu pattern' do 25 | %w(mysql-client libmysqlclient-dev).each do |p| 26 | package p do 27 | action :remove 28 | end 29 | end 30 | end 31 | end 32 | end 33 | end 34 | end 35 | end 36 | 37 | Chef::Platform.set :platform => :ubuntu, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Ubuntu 38 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/5.0/my.cnf.erb: -------------------------------------------------------------------------------- 1 | [client] 2 | <% if @port %> 3 | port = <%= @port %> 4 | <% end %> 5 | <% if @socket_file %> 6 | socket = <%= @socket_file %> 7 | <% end %> 8 | 9 | [mysqld_safe] 10 | socket = <%= @socket_file %> 11 | <% if @nice %> 12 | nice = 0 13 | <% end %> 14 | 15 | [mysqld] 16 | user = mysql 17 | pid-file = <%= @pid_file %> 18 | socket = <%= @socket_file %> 19 | <% if @port %> 20 | port = <%= @port %> 21 | <% end %> 22 | <% if @basedir %> 23 | basedir = <%= @base_dir %> 24 | <% end %> 25 | <% if @data_dir %> 26 | datadir = <%= @data_dir %> 27 | <% end %> 28 | <% if @tmpdir %> 29 | tmpdir = /tmp 30 | <% end %> 31 | <% if @lc_messages_dir %> 32 | lc-messages-dir = <%= @lc_messages_dir %> 33 | <% end %> 34 | 35 | [mysql] 36 | <% if @include_dir %> 37 | !includedir <%= @include_dir %> 38 | <% end %> 39 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/5.1/my.cnf.erb: -------------------------------------------------------------------------------- 1 | [client] 2 | <% if @port %> 3 | port = <%= @port %> 4 | <% end %> 5 | <% if @socket_file %> 6 | socket = <%= @socket_file %> 7 | <% end %> 8 | 9 | [mysqld_safe] 10 | socket = <%= @socket_file %> 11 | <% if @nice %> 12 | nice = 0 13 | <% end %> 14 | 15 | [mysqld] 16 | user = mysql 17 | pid-file = <%= @pid_file %> 18 | socket = <%= @socket_file %> 19 | <% if @port %> 20 | port = <%= @port %> 21 | <% end %> 22 | <% if @basedir %> 23 | basedir = <%= @base_dir %> 24 | <% end %> 25 | <% if @data_dir %> 26 | datadir = <%= @data_dir %> 27 | <% end %> 28 | <% if @tmpdir %> 29 | tmpdir = /tmp 30 | <% end %> 31 | <% if @lc_messages_dir %> 32 | lc-messages-dir = <%= @lc_messages_dir %> 33 | <% end %> 34 | 35 | [mysql] 36 | <% if @include_dir %> 37 | !includedir <%= @include_dir %> 38 | <% end %> 39 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/5.5/my.cnf.erb: -------------------------------------------------------------------------------- 1 | [client] 2 | <% if @port %> 3 | port = <%= @port %> 4 | <% end %> 5 | <% if @socket_file %> 6 | socket = <%= @socket_file %> 7 | <% end %> 8 | 9 | [mysqld_safe] 10 | socket = <%= @socket_file %> 11 | <% if @nice %> 12 | nice = 0 13 | <% end %> 14 | 15 | [mysqld] 16 | user = mysql 17 | pid-file = <%= @pid_file %> 18 | socket = <%= @socket_file %> 19 | <% if @port %> 20 | port = <%= @port %> 21 | <% end %> 22 | <% if @basedir %> 23 | basedir = <%= @base_dir %> 24 | <% end %> 25 | <% if @data_dir %> 26 | datadir = <%= @data_dir %> 27 | <% end %> 28 | <% if @tmpdir %> 29 | tmpdir = /tmp 30 | <% end %> 31 | <% if @lc_messages_dir %> 32 | lc-messages-dir = <%= @lc_messages_dir %> 33 | <% end %> 34 | 35 | [mysql] 36 | <% if @include_dir %> 37 | !includedir <%= @include_dir %> 38 | <% end %> 39 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_client_fedora.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlClient 6 | class 7 | Fedora < Chef::Provider::MysqlClient 8 | use_inline_resources if defined?(use_inline_resources) 9 | 10 | def whyrun_supported? 11 | true 12 | end 13 | 14 | action :create do 15 | converge_by 'fedora pattern' do 16 | %w(community-mysql community-mysql-devel).each do |p| 17 | package p do 18 | action :install 19 | end 20 | end 21 | end 22 | end 23 | 24 | action :delete do 25 | converge_by 'fedora pattern' do 26 | %w(community-mysql community-mysql-devel).each do |p| 27 | package p do 28 | action :remove 29 | end 30 | end 31 | end 32 | end 33 | end 34 | end 35 | end 36 | end 37 | 38 | Chef::Platform.set :platform => :fedora, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Fedora 39 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/apparmor/usr.sbin.mysqld.erb: -------------------------------------------------------------------------------- 1 | # vim:syntax=apparmor 2 | # Last Modified: Tue Jun 19 17:37:30 2007 3 | #include 4 | 5 | /usr/sbin/mysqld flags=(complain) { 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | capability dac_override, 13 | capability sys_resource, 14 | capability setgid, 15 | capability setuid, 16 | 17 | network tcp, 18 | 19 | /etc/hosts.allow r, 20 | /etc/hosts.deny r, 21 | 22 | /etc/mysql/*.pem r, 23 | /etc/mysql/conf.d/ r, 24 | /etc/mysql/conf.d/* r, 25 | /etc/mysql/my.cnf r, 26 | /usr/lib/mysql/plugin/ r, 27 | /usr/lib/mysql/plugin/*.so* mr, 28 | /usr/sbin/mysqld mr, 29 | /usr/share/mysql/** r, 30 | /var/log/mysql.log rw, 31 | /var/log/mysql.err rw, 32 | /var/lib/mysql/ r, 33 | <%= node['mysql']['data_dir'] %>/** rwk, 34 | /var/log/mysql/ r, 35 | /var/log/mysql/* rw, 36 | /var/run/mysqld/mysqld.pid w, 37 | /var/run/mysqld/mysqld.sock w, 38 | 39 | /sys/devices/system/cpu/ r, 40 | } -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/5.6/my.cnf.erb: -------------------------------------------------------------------------------- 1 | [client] 2 | <% if @port %> 3 | port = <%= @port %> 4 | <% end %> 5 | <% if @socket %> 6 | socket = <%= @socket_file %> 7 | <% end %> 8 | 9 | [mysqld_safe] 10 | socket = <%= @socket_file %> 11 | <% if @nice %> 12 | nice = 0 13 | <% end %> 14 | 15 | [mysqld] 16 | user = mysql 17 | pid-file = <%= @pid_file %> 18 | socket = <%= @socket_file %> 19 | <% if @port %> 20 | port = <%= @port %> 21 | <% end %> 22 | <% if @basedir %> 23 | basedir = <%= @base_dir %> 24 | <% end %> 25 | <% if @data_dir %> 26 | datadir = <%= @data_dir %> 27 | <% end %> 28 | <% if @tmpdir %> 29 | tmpdir = /tmp 30 | <% end %> 31 | <% if @lc_messages_dir %> 32 | lc-messages-dir = <%= @lc_messages_dir %> 33 | <% end %> 34 | sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 35 | 36 | [mysql] 37 | <% if @include_dir %> 38 | !includedir <%= @include_dir %> 39 | <% end %> 40 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_client_omnios.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlClient 6 | class Omnios < Chef::Provider::MysqlClient 7 | use_inline_resources if defined?(use_inline_resources) 8 | 9 | def whyrun_supported? 10 | true 11 | end 12 | 13 | action :create do 14 | converge_by 'omnios pattern' do 15 | package 'database/mysql-55' do 16 | action :install 17 | end 18 | 19 | package 'database/mysql-55/library' do 20 | action :install 21 | end 22 | end 23 | end 24 | 25 | action :delete do 26 | converge_by 'omnios pattern' do 27 | package 'database/mysql-55' do 28 | action :remove 29 | end 30 | 31 | package 'database/mysql-55/library' do 32 | action :remove 33 | end 34 | end 35 | end 36 | end 37 | end 38 | end 39 | end 40 | 41 | Chef::Platform.set :platform => :omnios, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Omnios 42 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/omnios/mysql.xml.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/smartos/mysql.xml.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_client_rhel.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlClient 6 | class Rhel < Chef::Provider::MysqlClient 7 | use_inline_resources if defined?(use_inline_resources) 8 | 9 | def whyrun_supported? 10 | true 11 | end 12 | 13 | action :create do 14 | converge_by 'rhel pattern' do 15 | %w(mysql mysql-devel).each do |p| 16 | package p do 17 | action :install 18 | end 19 | end 20 | end 21 | end 22 | 23 | action :delete do 24 | converge_by 'rhel pattern' do 25 | %w(mysql mysql-devel).each do |p| 26 | package p do 27 | action :remove 28 | end 29 | end 30 | end 31 | end 32 | end 33 | end 34 | end 35 | end 36 | 37 | Chef::Platform.set :platform => :rhel, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel 38 | Chef::Platform.set :platform => :amazon, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel 39 | Chef::Platform.set :platform => :redhat, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel 40 | Chef::Platform.set :platform => :centos, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel 41 | Chef::Platform.set :platform => :oracle, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel 42 | Chef::Platform.set :platform => :scientific, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel 43 | -------------------------------------------------------------------------------- /cookbooks/playground/README.md: -------------------------------------------------------------------------------- 1 | playground Cookbook 2 | =================== 3 | TODO: Enter the cookbook description here. 4 | 5 | e.g. 6 | This cookbook makes your favorite breakfast sandwich. 7 | 8 | Requirements 9 | ------------ 10 | TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. 11 | 12 | e.g. 13 | #### packages 14 | - `toaster` - playground needs toaster to brown your bagel. 15 | 16 | Attributes 17 | ---------- 18 | TODO: List your cookbook attributes here. 19 | 20 | e.g. 21 | #### playground::default 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
KeyTypeDescriptionDefault
['playground']['bacon']Booleanwhether to include bacontrue
36 | 37 | Usage 38 | ----- 39 | #### playground::default 40 | TODO: Write usage instructions for each cookbook. 41 | 42 | e.g. 43 | Just include `playground` in your node's `run_list`: 44 | 45 | ```json 46 | { 47 | "name":"my_node", 48 | "run_list": [ 49 | "recipe[playground]" 50 | ] 51 | } 52 | ``` 53 | 54 | Contributing 55 | ------------ 56 | TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. 57 | 58 | e.g. 59 | 1. Fork the repository on Github 60 | 2. Create a named feature branch (like `add_component_x`) 61 | 3. Write your change 62 | 4. Write tests for your change (if applicable) 63 | 5. Run the tests, ensuring they all pass 64 | 6. Submit a Pull Request using Github 65 | 66 | License and Authors 67 | ------------------- 68 | Authors: TODO: List authors 69 | -------------------------------------------------------------------------------- /cookbooks/playground-mysql/README.md: -------------------------------------------------------------------------------- 1 | playground-mysql Cookbook 2 | ========================= 3 | TODO: Enter the cookbook description here. 4 | 5 | e.g. 6 | This cookbook makes your favorite breakfast sandwich. 7 | 8 | Requirements 9 | ------------ 10 | TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. 11 | 12 | e.g. 13 | #### packages 14 | - `toaster` - playground-mysql needs toaster to brown your bagel. 15 | 16 | Attributes 17 | ---------- 18 | TODO: List your cookbook attributes here. 19 | 20 | e.g. 21 | #### playground-mysql::default 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
KeyTypeDescriptionDefault
['playground-mysql']['bacon']Booleanwhether to include bacontrue
36 | 37 | Usage 38 | ----- 39 | #### playground-mysql::default 40 | TODO: Write usage instructions for each cookbook. 41 | 42 | e.g. 43 | Just include `playground-mysql` in your node's `run_list`: 44 | 45 | ```json 46 | { 47 | "name":"my_node", 48 | "run_list": [ 49 | "recipe[playground-mysql]" 50 | ] 51 | } 52 | ``` 53 | 54 | Contributing 55 | ------------ 56 | TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. 57 | 58 | e.g. 59 | 1. Fork the repository on Github 60 | 2. Create a named feature branch (like `add_component_x`) 61 | 3. Write your change 62 | 4. Write tests for your change (if applicable) 63 | 5. Run the tests, ensuring they all pass 64 | 6. Submit a Pull Request using Github 65 | 66 | License and Authors 67 | ------------------- 68 | Authors: TODO: List authors 69 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/grants/grants.sql.erb: -------------------------------------------------------------------------------- 1 | # Generated by Chef for <%= node['hostname'] %>. 2 | # Local modifications will be overwritten. 3 | <% case node['platform_family'] -%> 4 | <% when "debian" -%> 5 | 6 | # Grant privileges for debian-sys-main user 7 | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<%= node['mysql']['server_debian_password'] %>' WITH GRANT OPTION; 8 | 9 | # UPDATE mysql.user SET Password=PASSWORD('<%= node['mysql']['server_debian_password'] %>') WHERE User='debian-sys-maint and Host='localhost'; 10 | <% end %> 11 | 12 | # Grant replication for a slave user. 13 | GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' identified by '<%= node['mysql']['server_repl_password'] %>'; 14 | <% if node['mysql']['allow_remote_root'] -%> 15 | 16 | # Set the server root password. This should be preseeded by the package installation. 17 | GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '<%= node['mysql']['server_root_password'] %>' WITH GRANT OPTION; 18 | <% else %> 19 | 20 | # remove remote access for root user and set password for local root user 21 | DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); 22 | UPDATE mysql.user SET Password=PASSWORD('<%= node['mysql']['server_root_password'] %>') WHERE User='root'; 23 | <% end %> 24 | <% if node['mysql']['remove_anonymous_users'] -%> 25 | 26 | # Remove anonymous users 27 | DELETE FROM mysql.user WHERE User=''; 28 | <% end %> 29 | 30 | # Remove test database and access to it 31 | <% if node['mysql']['remove_test_database'] -%> 32 | DROP DATABASE IF EXISTS test; 33 | DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'; 34 | <% end %> 35 | 36 | # Set the password for root@localhost 37 | SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<%= node['mysql']['server_root_password'] %>'); 38 | SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('<%= node['mysql']['server_root_password'] %>'); 39 | <% if node['mysql']['root_network_acl'] -%> 40 | 41 | # allow root to connect from a remote network if root_network_acl is not nil 42 | GRANT ALL PRIVILEGES ON *.* TO 'root'@'<%= node['mysql']['root_network_acl'] %>' IDENTIFIED BY '<%= node['mysql']['server_root_password'] %>' WITH GRANT OPTION; 43 | <% end -%> 44 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/resource_mysql_service.rb: -------------------------------------------------------------------------------- 1 | require 'chef/resource/lwrp_base' 2 | require_relative 'helpers' 3 | 4 | extend Opscode::Mysql::Helpers 5 | # 6 | class Chef 7 | class Resource 8 | class MysqlService < Chef::Resource 9 | extend Opscode::Mysql::Helpers 10 | # Initialize resource 11 | def initialize(name = nil, run_context = nil) 12 | super 13 | @resource_name = :mysql_service 14 | @service_name = name 15 | 16 | @allowed_actions = [:create, :restart, :reload] 17 | @action = :create 18 | 19 | # set default values 20 | @version = default_version_for( 21 | node['platform'], 22 | node['platform_family'], 23 | node['platform_version'] 24 | ) 25 | 26 | @package_name = package_name_for( 27 | node['platform'], 28 | node['platform_family'], 29 | node['platform_version'], 30 | @version 31 | ) 32 | 33 | @data_dir = default_data_dir_for(node['platform_family']) 34 | 35 | @port = '3306' 36 | @template_source = nil 37 | end 38 | 39 | # attribute :service_name, kind_of: String 40 | def service_name(arg = nil) 41 | set_or_return( 42 | :service_name, 43 | arg, 44 | :kind_of => String 45 | ) 46 | end 47 | 48 | # attribute :template_source, kind_of: String 49 | def template_source(arg = nil) 50 | set_or_return( 51 | :template_source, 52 | arg, 53 | :kind_of => String 54 | ) 55 | end 56 | 57 | # attribute :port, kind_of: String 58 | def port(arg = nil) 59 | set_or_return( 60 | :port, 61 | arg, 62 | :kind_of => String, 63 | :callbacks => { 64 | 'should be a valid non-system port' => lambda do |p| 65 | Chef::Resource::MysqlService.validate_port(p) 66 | end 67 | } 68 | ) 69 | end 70 | 71 | # attribute :version, kind_of: String 72 | def version(arg = nil) 73 | # First, set the package_name to the appropriate value. 74 | package_name package_name_for( 75 | node['platform'], 76 | node['platform_family'], 77 | node['platform_version'], 78 | arg 79 | ) 80 | 81 | # Then, validate and return the version number. 82 | set_or_return( 83 | :version, 84 | arg, 85 | :kind_of => String, 86 | :callbacks => { 87 | "is not supported for #{node['platform']}-#{node['platform_version']}" => lambda do |mysql_version| 88 | true unless package_name_for( 89 | node['platform'], 90 | node['platform_family'], 91 | node['platform_version'], 92 | arg 93 | ).nil? 94 | end 95 | } 96 | ) 97 | end 98 | 99 | # attribute :package_name, kind_of: String 100 | def package_name(arg = nil) 101 | set_or_return( 102 | :package_name, 103 | arg, 104 | :kind_of => String 105 | ) 106 | end 107 | 108 | # attribute :data_dir, kind_of: String 109 | def data_dir(arg = nil) 110 | set_or_return( 111 | :data_dir, 112 | arg, 113 | :kind_of => String 114 | ) 115 | end 116 | 117 | def self.validate_port(port) 118 | port.to_i > 1024 && port.to_i < 65_535 119 | end 120 | end 121 | end 122 | end 123 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_service_fedora.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlService 6 | class Fedora < Chef::Provider::MysqlService 7 | use_inline_resources if defined?(use_inline_resources) 8 | 9 | def whyrun_supported? 10 | true 11 | end 12 | 13 | action :create do 14 | converge_by 'fedora pattern' do 15 | 16 | prefix_dir = '/usr' 17 | include_dir = '/etc/my.cnf.d' 18 | lc_messages_dir = nil 19 | run_dir = '/var/run/mysqld' 20 | pid_file = '/var/run/mysqld/mysqld.pid' 21 | socket_file = '/var/lib/mysql/mysql.sock' 22 | package_name = 'community-mysql-server' 23 | 24 | package package_name do 25 | action :install 26 | end 27 | 28 | directory include_dir do 29 | owner 'mysql' 30 | group 'mysql' 31 | mode '0750' 32 | action :create 33 | recursive true 34 | end 35 | 36 | directory run_dir do 37 | owner 'mysql' 38 | group 'mysql' 39 | mode '0755' 40 | action :create 41 | recursive true 42 | end 43 | 44 | directory new_resource.data_dir do 45 | owner 'mysql' 46 | group 'mysql' 47 | mode '0750' 48 | action :create 49 | recursive true 50 | end 51 | 52 | service 'mysqld' do 53 | supports :restart => true 54 | action [:start, :enable] 55 | end 56 | 57 | execute 'wait for mysql' do 58 | command "until [ -S #{socket_file} ] ; do sleep 1 ; done" 59 | timeout 10 60 | action :run 61 | end 62 | 63 | template '/etc/mysql_grants.sql' do 64 | cookbook 'mysql' 65 | source 'grants/grants.sql.erb' 66 | owner 'root' 67 | group 'root' 68 | mode '0600' 69 | action :create 70 | notifies :run, 'execute[install-grants]' 71 | end 72 | 73 | if node['mysql']['server_root_password'].empty? 74 | pass_string = '' 75 | else 76 | pass_string = "-p#{node['mysql']['server_root_password']}" 77 | end 78 | 79 | execute 'install-grants' do 80 | cmd = "#{prefix_dir}/bin/mysql" 81 | cmd << ' -u root ' 82 | cmd << "#{pass_string} < /etc/mysql_grants.sql" 83 | command cmd 84 | action :nothing 85 | end 86 | 87 | template '/etc/my.cnf' do 88 | if new_resource.template_source.nil? 89 | source "#{new_resource.version}/my.cnf.erb" 90 | cookbook 'mysql' 91 | else 92 | source new_resource.template_source 93 | end 94 | owner 'mysql' 95 | group 'mysql' 96 | mode '0600' 97 | variables( 98 | :data_dir => new_resource.data_dir, 99 | :include_dir => include_dir, 100 | :lc_messages_dir => lc_messages_dir, 101 | :pid_file => pid_file, 102 | :port => new_resource.port, 103 | :prefix_dir => prefix_dir, 104 | :socket_file => socket_file 105 | ) 106 | action :create 107 | notifies :run, 'bash[move mysql data to datadir]' 108 | notifies :restart, 'service[mysqld]' 109 | end 110 | 111 | bash 'move mysql data to datadir' do 112 | user 'root' 113 | code <<-EOH 114 | service mysqld stop \ 115 | && for i in `ls /var/lib/mysql | grep -v mysql.sock` ; do mv /var/lib/mysql/$i #{new_resource.data_dir} ; done 116 | EOH 117 | action :nothing 118 | only_if "[ '/var/lib/mysqld' != #{new_resource.data_dir} ]" 119 | only_if "[ `stat -c %h #{new_resource.data_dir}` -eq 2 ]" 120 | not_if '[ `stat -c %h /var/lib/mysql/` -eq 2 ]' 121 | end 122 | 123 | execute 'assign-root-password' do 124 | cmd = "#{prefix_dir}/bin/mysqladmin" 125 | cmd << ' -u root password ' 126 | cmd << node['mysql']['server_root_password'] 127 | command cmd 128 | action :run 129 | only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'" 130 | end 131 | end 132 | end 133 | 134 | action :restart do 135 | converge_by 'fedora pattern' do 136 | service 'mysqld' do 137 | supports :restart => true 138 | action :restart 139 | end 140 | end 141 | end 142 | 143 | action :reload do 144 | converge_by 'fedora pattern' do 145 | service 'mysqld' do 146 | action :reload 147 | end 148 | end 149 | end 150 | end 151 | end 152 | end 153 | end 154 | 155 | Chef::Platform.set :platform => :fedora, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Fedora 156 | -------------------------------------------------------------------------------- /cookbooks/mysql/README.md: -------------------------------------------------------------------------------- 1 | MySQL cookbook 2 | ===================== 3 | 4 | The MySQL cookbook exposes the `mysql_service` and `mysql_client` 5 | resources. These resources are utilized by the `mysql::client` 6 | and `mysql::server` recipes, or can be consumed in other recipes by 7 | depending on the MySQL cookbook. 8 | 9 | This cookbook does its best to follow platform native idioms at all 10 | times. This means things like logs, pid files, sockets, and service 11 | managers work "as expected" by an administrator familiar with a given 12 | platform. 13 | 14 | Scope 15 | ----- 16 | This cookbook is concerned with the "MySQL Community Server", 17 | particularly those shipped with F/OSS Unix and Linux distributions. It 18 | does not address forks and value-added repackaged MySQL distributions 19 | like Drizzle, MariaDB, or Percona. 20 | 21 | This cookbook does not try to encompass every single configuration 22 | option available for MySQL. Instead, it provides a "just enough" to 23 | get a MySQL server running, then allows the user to specify additional 24 | custom configuration. 25 | 26 | Requirements 27 | ------------ 28 | * Chef 11 or higher 29 | * Ruby 1.9 (preferably from the Chef full-stack installer) 30 | 31 | Resources / Providers 32 | --------------------- 33 | ### mysql_service 34 | 35 | The `mysql_service` resource configures the basic plumbing 36 | needed to run a simple mysql_service with a minimal configuration. 37 | 38 | ### Example 39 | 40 | mysql_service 'default' do 41 | version '5.1' 42 | port '3307' 43 | data_dir '/data' 44 | template_source 'custom.erb' 45 | action :create 46 | end 47 | 48 | The `version` parameter will allow the user to select from the 49 | versions available for the platform, where applicable. When omitted, 50 | it will install the default MySQL version for the target platform. 51 | Available version numbers are `5.0`, `5.1`, `5.5`, and `5.6`, 52 | depending on platform. See PLATFORMS.md for details. 53 | 54 | The `port` parameter determines the listen port for the mysqld 55 | service. When omitted, it will default to '3306'. 56 | 57 | The `data_dir` parameter determines where the actual data files are 58 | kept on the machine. This is useful when mounting external storage. 59 | When omitted, it will default to the platform's native location. 60 | 61 | The `template_source` parameter allows the user to override the 62 | default minimal template used by the `mysql_service` resource. When 63 | omitted, it will select one shipped with the cookbook based on the 64 | MySQL version. 65 | 66 | The mysql_service resource supports :create, :restart, and :reload actions. 67 | 68 | ### mysql_client 69 | 70 | The `mysql_client` resource installs or removes the MySQL client binaries and 71 | development libraries 72 | 73 | Recipes 74 | ------- 75 | ### mysql::server 76 | 77 | This recipe calls a `mysql_service` resource, passing parameters 78 | from node attributes. 79 | 80 | ### mysql::client 81 | 82 | This recipe calls a `mysql_client` resource, with action :create 83 | 84 | Usage 85 | ----- 86 | The `mysql::server` recipe and `mysql_service` resources are designed to 87 | provide a minimal configuration. The default `my.cnf` dropped off has 88 | an `!includedir` directive. Site-specific configuration should be 89 | placed in the platform's native location. 90 | 91 | ### run_list 92 | 93 | Include `'recipe[mysql::server]'` or `'recipe[mysql::client]'` in your run_list. 94 | 95 | ### Wrapper cookbook 96 | 97 | node.set['mysql']['server_root_password'] = 'yolo' 98 | node.set['mysql']['port'] = '3308' 99 | node.set['mysql']['data_dir'] = '/data' 100 | 101 | include_recipe 'mysql::server' 102 | 103 | template '/etc/mysql/conf.d/mysite.cnf' do 104 | owner 'mysql' 105 | owner 'mysql' 106 | source 'mysite.cnf.erb' 107 | notifies :restart, 'mysql_service[default]' 108 | end 109 | 110 | ### Used directly in a recipe 111 | 112 | template '/etc/mysql/conf.d/mysite.cnf' do 113 | owner 'mysql' 114 | owner 'mysql' 115 | source 'mysite.cnf.erb' 116 | notifies :restart, 'mysql_service[default]' 117 | end 118 | 119 | mysql_service 'default' do 120 | version '5.5' 121 | port '3307' 122 | data_dir '/data' 123 | template_source 'custom.erb' 124 | action :create 125 | end 126 | 127 | Attributes 128 | ---------- 129 | 130 | default['mysql']['service_name'] = 'default' 131 | default['mysql']['server_root_password'] = 'ilikerandompasswords' 132 | default['mysql']['server_debian_password'] = 'postinstallscriptsarestupid' 133 | default['mysql']['data_dir'] = '/var/lib/mysql' 134 | default['mysql']['port'] = '3306' 135 | 136 | ### used in grants.sql 137 | default['mysql']['allow_remote_root'] = false 138 | default['mysql']['remove_anonymous_users'] = true 139 | default['mysql']['root_network_acl'] = nil 140 | 141 | License & Authors 142 | ----------------- 143 | - Author:: Joshua Timberman () 144 | - Author:: AJ Christensen () 145 | - Author:: Seth Chisamore () 146 | - Author:: Brian Bianco () 147 | - Author:: Jesse Howarth () 148 | - Author:: Andrew Crump () 149 | - Author:: Christoph Hartmann () 150 | - Author:: Sean OMeara () 151 | 152 | ```text 153 | Copyright:: 2009-2014 Chef Software, Inc 154 | 155 | Licensed under the Apache License, Version 2.0 (the "License"); 156 | you may not use this file except in compliance with the License. 157 | You may obtain a copy of the License at 158 | 159 | http://www.apache.org/licenses/LICENSE-2.0 160 | 161 | Unless required by applicable law or agreed to in writing, software 162 | distributed under the License is distributed on an "AS IS" BASIS, 163 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 164 | See the License for the specific language governing permissions and 165 | limitations under the License. 166 | ``` 167 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_service_debian.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlService 6 | class Debian < Chef::Provider::MysqlService 7 | use_inline_resources if defined?(use_inline_resources) 8 | 9 | def whyrun_supported? 10 | true 11 | end 12 | 13 | action :create do 14 | converge_by 'debian pattern' do 15 | ################## 16 | prefix_dir = '/usr' 17 | run_dir = '/var/run/mysqld' 18 | pid_file = '/var/run/mysqld/mysql.pid' 19 | socket_file = '/var/run/mysqld/mysqld.sock' 20 | include_dir = '/etc/mysql/conf.d' 21 | ################## 22 | 23 | package 'debconf-utils' do 24 | action :install 25 | end 26 | 27 | directory '/var/cache/local/preseeding' do 28 | owner 'root' 29 | group 'root' 30 | mode '0755' 31 | action :create 32 | recursive true 33 | end 34 | 35 | template '/var/cache/local/preseeding/mysql-server.seed' do 36 | cookbook 'mysql' 37 | source 'debian/mysql-server.seed.erb' 38 | owner 'root' 39 | group 'root' 40 | mode '0600' 41 | action :create 42 | notifies :run, 'execute[preseed mysql-server]', :immediately 43 | end 44 | 45 | execute 'preseed mysql-server' do 46 | command '/usr/bin/debconf-set-selections /var/cache/local/preseeding/mysql-server.seed' 47 | action :nothing 48 | end 49 | 50 | # package automatically initializes database and starts service. 51 | # ... because that's totally super convenient. 52 | package 'mysql-server' do 53 | action :install 54 | end 55 | 56 | # service 57 | service 'mysql' do 58 | provider Chef::Provider::Service::Init::Debian 59 | supports :restart => true 60 | action [:start, :enable] 61 | end 62 | 63 | execute 'assign-root-password' do 64 | cmd = "#{prefix_dir}/bin/mysqladmin" 65 | cmd << ' -u root password ' 66 | cmd << node['mysql']['server_root_password'] 67 | command cmd 68 | action :run 69 | only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'" 70 | end 71 | 72 | template '/etc/mysql_grants.sql' do 73 | cookbook 'mysql' 74 | source 'grants/grants.sql.erb' 75 | owner 'root' 76 | group 'root' 77 | mode '0600' 78 | action :create 79 | notifies :run, 'execute[install-grants]' 80 | end 81 | 82 | if node['mysql']['server_root_password'].empty? 83 | pass_string = '' 84 | else 85 | pass_string = "-p#{node['mysql']['server_root_password']}" 86 | end 87 | 88 | execute 'install-grants' do 89 | cmd = "#{prefix_dir}/bin/mysql" 90 | cmd << ' -u root ' 91 | cmd << "#{pass_string} < /etc/mysql_grants.sql" 92 | command cmd 93 | action :nothing 94 | end 95 | 96 | template '/etc/mysql/debian.cnf' do 97 | cookbook 'mysql' 98 | source 'debian/debian.cnf.erb' 99 | owner 'root' 100 | group 'root' 101 | mode '0600' 102 | action :create 103 | end 104 | 105 | # 106 | directory include_dir do 107 | owner 'mysql' 108 | group 'mysql' 109 | mode '0750' 110 | recursive true 111 | action :create 112 | end 113 | 114 | directory run_dir do 115 | owner 'mysql' 116 | group 'mysql' 117 | mode '0755' 118 | action :create 119 | recursive true 120 | end 121 | 122 | directory new_resource.data_dir do 123 | owner 'mysql' 124 | group 'mysql' 125 | mode '0750' 126 | recursive true 127 | action :create 128 | end 129 | 130 | template '/etc/mysql/my.cnf' do 131 | if new_resource.template_source.nil? 132 | source "#{new_resource.version}/my.cnf.erb" 133 | cookbook 'mysql' 134 | else 135 | source new_resource.template_source 136 | end 137 | owner 'mysql' 138 | group 'mysql' 139 | mode '0600' 140 | variables( 141 | :data_dir => new_resource.data_dir, 142 | :pid_file => pid_file, 143 | :socket_file => socket_file, 144 | :port => new_resource.port, 145 | :include_dir => include_dir 146 | ) 147 | action :create 148 | notifies :run, 'bash[move mysql data to datadir]' 149 | notifies :restart, 'service[mysql]' 150 | end 151 | 152 | bash 'move mysql data to datadir' do 153 | user 'root' 154 | code <<-EOH 155 | service mysql stop \ 156 | && mv /var/lib/mysql/* #{new_resource.data_dir} 157 | EOH 158 | action :nothing 159 | only_if "[ '/var/lib/mysql' != #{new_resource.data_dir} ]" 160 | only_if "[ `stat -c %h #{new_resource.data_dir}` -eq 2 ]" 161 | not_if '[ `stat -c %h /var/lib/mysql/` -eq 2 ]' 162 | end 163 | end 164 | end 165 | 166 | action :restart do 167 | converge_by 'debian pattern' do 168 | service 'mysql' do 169 | provider Chef::Provider::Service::Init::Debian 170 | supports :restart => true 171 | action :restart 172 | end 173 | end 174 | end 175 | 176 | action :reload do 177 | converge_by 'debian pattern' do 178 | service 'mysql' do 179 | provider Chef::Provider::Service::Init::Debian 180 | action :reload 181 | end 182 | end 183 | end 184 | end 185 | end 186 | end 187 | end 188 | 189 | Chef::Platform.set :platform => :debian, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Debian 190 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/helpers.rb: -------------------------------------------------------------------------------- 1 | module Opscode 2 | module Mysql 3 | module Helpers 4 | def default_version_for(platform, platform_family, platform_version) 5 | keyname = keyname_for(platform, platform_family, platform_version) 6 | PlatformInfo.mysql_info[platform_family][keyname]['default_version'] 7 | rescue NoMethodError 8 | nil 9 | end 10 | 11 | def package_name_for(platform, platform_family, platform_version, version) 12 | keyname = keyname_for(platform, platform_family, platform_version) 13 | PlatformInfo.mysql_info[platform_family][keyname][version]['package_name'] 14 | rescue NoMethodError 15 | nil 16 | end 17 | 18 | def service_name_for(platform, platform_family, platform_version, version) 19 | keyname = keyname_for(platform, platform_family, platform_version) 20 | PlatformInfo.mysql_info[platform_family][keyname][version]['service_name'] 21 | rescue NoMethodError 22 | nil 23 | end 24 | 25 | def default_data_dir_for(platform_family) 26 | PlatformInfo.mysql_info[platform_family]['default_data_dir'] 27 | rescue NoMethodError 28 | nil 29 | end 30 | 31 | def keyname_for(platform, platform_family, platform_version) 32 | case 33 | when platform_family == 'rhel' 34 | platform == 'amazon' ? platform_version : platform_version.to_i.to_s 35 | when platform_family == 'fedora' 36 | platform_version 37 | when platform_family == 'debian' 38 | platform == 'ubuntu' ? platform_version : platform_version.to_i.to_s 39 | when platform_family == 'smartos' 40 | platform_version 41 | when platform_family == 'omnios' 42 | platform_version 43 | end 44 | rescue NoMethodError 45 | nil 46 | end 47 | end 48 | 49 | class PlatformInfo 50 | def self.mysql_info 51 | @mysql_info ||= { 52 | 'rhel' => { 53 | 'default_data_dir' => '/var/lib/mysql', 54 | '5' => { 55 | 'default_version' => '5.0', 56 | '5.0' => { 57 | 'package_name' => 'mysql-server', 58 | 'service_name' => 'mysqld' 59 | }, 60 | '5.1' => { 61 | 'package_name' => 'mysql51-mysql-server', 62 | 'service_name' => 'mysql51-mysqld' 63 | }, 64 | '5.5' => { 65 | 'package_name' => 'mysql55-mysql-server', 66 | 'service_name' => 'mysql55-mysqld' 67 | } 68 | }, 69 | '6' => { 70 | 'default_version' => '5.1', 71 | '5.1' => { 72 | 'package_name' => 'mysql-server', 73 | 'service_name' => 'mysqld' 74 | } 75 | }, 76 | '7' => { 77 | 'default_version' => '5.5', 78 | '5.1' => { 79 | 'package_name' => 'mysql51-server', 80 | 'service_name' => 'mysqld' 81 | }, 82 | '5.5' => { 83 | 'package_name' => 'mysql55-server', 84 | 'service_name' => 'mysqld' 85 | } 86 | }, 87 | '2013.09' => { 88 | 'default_version' => '5.1', 89 | '5.1' => { 90 | 'package_name' => 'mysql-server', 91 | 'service_name' => 'mysqld' 92 | } 93 | }, 94 | '2014.03' => { 95 | 'default_version' => '5.5', 96 | '5.1' => { 97 | 'package_name' => 'mysql51-server', 98 | 'service_name' => 'mysqld' 99 | }, 100 | '5.5' => { 101 | 'package_name' => 'mysql55-server', 102 | 'service_name' => 'mysqld' 103 | } 104 | } 105 | }, 106 | 'fedora' => { 107 | 'default_data_dir' => '/var/lib/mysql', 108 | '19' => { 109 | 'default_version' => '5.5', 110 | '5.5' => { 111 | 'package_name' => 'community-mysql-server', 112 | 'service_name' => 'mysqld' 113 | } 114 | }, 115 | '20' => { 116 | 'default_version' => '5.5', 117 | '5.5' => { 118 | 'package_name' => 'community-mysql-server', 119 | 'service_name' => 'mysqld' 120 | } 121 | } 122 | }, 123 | 'debian' => { 124 | 'default_data_dir' => '/var/lib/mysql', 125 | '7' => { 126 | 'default_version' => '5.5', 127 | '5.5' => { 128 | 'package_name' => 'mysql-server-5.5', 129 | 'service_name' => 'mysqld' 130 | } 131 | }, 132 | '10.04' => { 133 | 'default_version' => '5.1', 134 | '5.1' => { 135 | 'package_name' => 'mysql-server-5.1', 136 | 'service_name' => 'mysqld' 137 | } 138 | }, 139 | '12.04' => { 140 | 'default_version' => '5.5', 141 | '5.5' => { 142 | 'package_name' => 'mysql-server-5.5', 143 | 'service_name' => 'mysqld' 144 | } 145 | }, 146 | '13.10' => { 147 | 'default_version' => '5.5', 148 | '5.5' => { 149 | 'package_name' => 'mysql-server-5.5', 150 | 'service_name' => 'mysqld' 151 | } 152 | } 153 | }, 154 | 'smartos' => { 155 | 'default_data_dir' => '/opt/local/lib/mysql', 156 | # Do this or now, until Ohai correctly detects a 157 | # smartmachine vs global zone (base64 13.4.0) from /etc/product 158 | '5.11' => { 159 | 'default_version' => '5.5', 160 | '5.5' => { 161 | 'package_name' => 'mysql-server', 162 | 'service_name' => 'mysql' 163 | }, 164 | '5.6' => { 165 | 'package_name' => 'mysql-server', 166 | 'service_name' => 'mysql' 167 | } 168 | } 169 | }, 170 | 'omnios' => { 171 | 'default_data_dir' => '/var/lib/mysql', 172 | '151006' => { 173 | 'default_version' => '5.5', 174 | '5.5' => { 175 | 'package_name' => 'database/mysql-55', 176 | 'service_name' => 'mysql' 177 | }, 178 | '5.6' => { 179 | 'package_name' => 'database/mysql-56', 180 | 'service_name' => 'mysql' 181 | } 182 | } 183 | } 184 | } 185 | end 186 | end 187 | end 188 | end 189 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_service_ubuntu.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlService 6 | class Ubuntu < Chef::Provider::MysqlService 7 | use_inline_resources if defined?(use_inline_resources) 8 | 9 | def whyrun_supported? 10 | true 11 | end 12 | 13 | action :create do 14 | converge_by 'ubuntu pattern' do 15 | ################## 16 | prefix_dir = '/usr' 17 | run_dir = '/var/run/mysqld' 18 | pid_file = '/var/run/mysqld/mysql.pid' 19 | socket_file = '/var/run/mysqld/mysqld.sock' 20 | include_dir = '/etc/mysql/conf.d' 21 | ################## 22 | 23 | package 'debconf-utils' do 24 | action :install 25 | end 26 | 27 | directory '/var/cache/local/preseeding' do 28 | owner 'root' 29 | group 'root' 30 | mode '0755' 31 | action :create 32 | recursive true 33 | end 34 | 35 | template '/var/cache/local/preseeding/mysql-server.seed' do 36 | cookbook 'mysql' 37 | source 'debian/mysql-server.seed.erb' 38 | owner 'root' 39 | group 'root' 40 | mode '0600' 41 | action :create 42 | notifies :run, 'execute[preseed mysql-server]', :immediately 43 | end 44 | 45 | execute 'preseed mysql-server' do 46 | command '/usr/bin/debconf-set-selections /var/cache/local/preseeding/mysql-server.seed' 47 | action :nothing 48 | end 49 | 50 | # package automatically initializes database and starts service. 51 | # ... because that's totally super convenient. 52 | package 'mysql-server' do 53 | action :install 54 | end 55 | 56 | # service 57 | service 'mysql' do 58 | provider Chef::Provider::Service::Upstart 59 | supports :restart => true 60 | action [:start, :enable] 61 | end 62 | 63 | execute 'assign-root-password' do 64 | cmd = "#{prefix_dir}/bin/mysqladmin" 65 | cmd << ' -u root password ' 66 | cmd << node['mysql']['server_root_password'] 67 | command cmd 68 | action :run 69 | only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'" 70 | end 71 | 72 | template '/etc/mysql_grants.sql' do 73 | cookbook 'mysql' 74 | source 'grants/grants.sql.erb' 75 | owner 'root' 76 | group 'root' 77 | mode '0600' 78 | action :create 79 | notifies :run, 'execute[install-grants]' 80 | end 81 | 82 | if node['mysql']['server_root_password'].empty? 83 | pass_string = '' 84 | else 85 | pass_string = "-p#{node['mysql']['server_root_password']}" 86 | end 87 | 88 | execute 'install-grants' do 89 | cmd = "#{prefix_dir}/bin/mysql" 90 | cmd << ' -u root ' 91 | cmd << "#{pass_string} < /etc/mysql_grants.sql" 92 | command cmd 93 | action :nothing 94 | end 95 | 96 | # apparmor 97 | directory '/etc/apparmor.d' do 98 | owner 'root' 99 | group 'root' 100 | mode '0755' 101 | action :create 102 | end 103 | 104 | template '/etc/apparmor.d/usr.sbin.mysqld' do 105 | cookbook 'mysql' 106 | source 'apparmor/usr.sbin.mysqld.erb' 107 | owner 'root' 108 | group 'root' 109 | mode '0644' 110 | action :create 111 | notifies :reload, 'service[apparmor-mysql]', :immediately 112 | end 113 | 114 | service 'apparmor-mysql' do 115 | service_name 'apparmor' 116 | action :nothing 117 | supports :reload => true 118 | end 119 | 120 | # 121 | directory include_dir do 122 | owner 'mysql' 123 | group 'mysql' 124 | mode '0750' 125 | recursive true 126 | action :create 127 | end 128 | 129 | directory run_dir do 130 | owner 'mysql' 131 | group 'mysql' 132 | mode '0755' 133 | action :create 134 | recursive true 135 | end 136 | 137 | directory new_resource.data_dir do 138 | owner 'mysql' 139 | group 'mysql' 140 | mode '0750' 141 | recursive true 142 | action :create 143 | end 144 | 145 | template '/etc/mysql/my.cnf' do 146 | if new_resource.template_source.nil? 147 | source "#{new_resource.version}/my.cnf.erb" 148 | cookbook 'mysql' 149 | else 150 | source new_resource.template_source 151 | end 152 | owner 'mysql' 153 | group 'mysql' 154 | mode '0600' 155 | variables( 156 | :data_dir => new_resource.data_dir, 157 | :pid_file => pid_file, 158 | :socket_file => socket_file, 159 | :port => new_resource.port, 160 | :include_dir => include_dir 161 | ) 162 | action :create 163 | notifies :run, 'bash[move mysql data to datadir]' 164 | notifies :restart, 'service[mysql]' 165 | end 166 | 167 | bash 'move mysql data to datadir' do 168 | user 'root' 169 | code <<-EOH 170 | service mysql stop \ 171 | && mv /var/lib/mysql/* #{new_resource.data_dir} 172 | EOH 173 | action :nothing 174 | only_if "[ '/var/lib/mysql' != #{new_resource.data_dir} ]" 175 | only_if "[ `stat -c %h #{new_resource.data_dir}` -eq 2 ]" 176 | not_if '[ `stat -c %h /var/lib/mysql/` -eq 2 ]' 177 | end 178 | end 179 | end 180 | 181 | action :restart do 182 | converge_by 'ubuntu pattern' do 183 | service 'mysql' do 184 | provider Chef::Provider::Service::Upstart 185 | supports :restart => true 186 | action :restart 187 | end 188 | end 189 | end 190 | 191 | action :reload do 192 | converge_by 'ubuntu pattern' do 193 | service 'mysql' do 194 | provider Chef::Provider::Service::Upstart 195 | supports :reload => true 196 | action :reload 197 | end 198 | end 199 | end 200 | end 201 | end 202 | end 203 | end 204 | 205 | Chef::Platform.set :platform => :ubuntu, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Ubuntu 206 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_service_smartos.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | 3 | class Chef 4 | class Provider 5 | class MysqlService 6 | class Smartos < Chef::Provider::MysqlService 7 | use_inline_resources if defined?(use_inline_resources) 8 | 9 | def whyrun_supported? 10 | true 11 | end 12 | 13 | action :create do 14 | converge_by 'smartos pattern' do 15 | 16 | prefix_dir = '/opt/local' 17 | run_dir = '/var/run/mysql' 18 | pid_file = '/var/mysql/mysql.pid' 19 | socket_file = '/tmp/mysql.sock' 20 | include_dir = "#{prefix_dir}/etc/mysql/conf.d" 21 | 22 | package new_resource.package_name do 23 | version new_resource.version 24 | action :install 25 | end 26 | 27 | directory include_dir do 28 | owner 'mysql' 29 | group 'mysql' 30 | mode '0750' 31 | recursive true 32 | action :create 33 | end 34 | 35 | directory run_dir do 36 | owner 'mysql' 37 | group 'mysql' 38 | mode '0755' 39 | action :create 40 | recursive true 41 | end 42 | 43 | # data_dir 44 | directory new_resource.data_dir do 45 | owner 'mysql' 46 | group 'mysql' 47 | mode '0750' 48 | action :create 49 | recursive true 50 | end 51 | 52 | directory "#{new_resource.data_dir}/data" do 53 | owner 'mysql' 54 | group 'mysql' 55 | mode '0750' 56 | action :create 57 | recursive true 58 | end 59 | 60 | directory "#{new_resource.data_dir}/data/mysql" do 61 | owner 'mysql' 62 | group 'mysql' 63 | mode '0750' 64 | action :create 65 | recursive true 66 | end 67 | 68 | directory "#{new_resource.data_dir}/data/test" do 69 | owner 'mysql' 70 | group 'mysql' 71 | mode '0750' 72 | action :create 73 | recursive true 74 | end 75 | 76 | # FIXME: support user supplied template 77 | template "#{prefix_dir}/etc/my.cnf" do 78 | if new_resource.template_source.nil? 79 | source "#{new_resource.version}/my.cnf.erb" 80 | cookbook 'mysql' 81 | else 82 | source new_resource.template_source 83 | end 84 | owner 'mysql' 85 | group 'mysql' 86 | mode '0600' 87 | variables( 88 | :data_dir => new_resource.data_dir, 89 | :pid_file => pid_file, 90 | :socket_file => socket_file, 91 | :port => new_resource.port, 92 | :include_dir => include_dir 93 | ) 94 | action :create 95 | notifies :run, 'bash[move mysql data to datadir]', :immediately 96 | notifies :restart, 'service[mysql]' 97 | end 98 | 99 | bash 'move mysql data to datadir' do 100 | user 'root' 101 | code <<-EOH 102 | /usr/sbin/svcadm disable mysql \ 103 | && mv /opt/local/lib/mysql/* #{new_resource.data_dir} 104 | EOH 105 | action :nothing 106 | only_if "[ '/opt/local/lib/mysql' != #{new_resource.data_dir} ]" 107 | only_if "[ `stat -c %h #{new_resource.data_dir}` -eq 2 ]" 108 | not_if '[ `stat -c %h /var/lib/mysql/` -eq 2 ]' 109 | end 110 | 111 | execute 'initialize mysql database' do 112 | cwd new_resource.data_dir 113 | command "#{prefix_dir}/bin/mysql_install_db --datadir=#{new_resource.data_dir} --user=mysql" 114 | creates "#{new_resource.data_dir}/mysql/user.frm" 115 | end 116 | 117 | template '/opt/local/lib/svc/method/mysqld' do 118 | cookbook 'mysql' 119 | source 'smartos/svc.method.mysqld.erb' 120 | owner 'root' 121 | group 'root' 122 | mode '0555' 123 | variables( 124 | :data_dir => new_resource.data_dir, 125 | :pid_file => pid_file 126 | ) 127 | action :create 128 | end 129 | 130 | template '/tmp/mysql.xml' do 131 | cookbook 'mysql' 132 | source 'smartos/mysql.xml.erb' 133 | owner 'root' 134 | group 'root' 135 | mode '0644' 136 | variables(:version => new_resource.version) 137 | action :create 138 | notifies :run, 'execute[import mysql manifest]', :immediately 139 | end 140 | 141 | execute 'import mysql manifest' do 142 | command 'svccfg import /tmp/mysql.xml' 143 | action :nothing 144 | end 145 | 146 | service 'mysql' do 147 | supports :reload => true 148 | action [:start, :enable] 149 | end 150 | 151 | execute 'wait for mysql' do 152 | command "until [ -S #{socket_file} ] ; do sleep 1 ; done" 153 | timeout 10 154 | action :run 155 | end 156 | 157 | execute 'assign-root-password' do 158 | cmd = "#{prefix_dir}/bin/mysqladmin" 159 | cmd << ' -u root password ' 160 | cmd << node['mysql']['server_root_password'] 161 | command cmd 162 | action :run 163 | only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'" 164 | end 165 | 166 | template "#{prefix_dir}/etc/mysql_grants.sql" do 167 | cookbook 'mysql' 168 | source 'grants/grants.sql.erb' 169 | owner 'root' 170 | group 'root' 171 | mode '0600' 172 | action :create 173 | notifies :run, 'execute[install-grants]', :immediately 174 | end 175 | 176 | if node['mysql']['server_root_password'].empty? 177 | pass_string = '' 178 | else 179 | pass_string = "-p#{node['mysql']['server_root_password']}" 180 | end 181 | 182 | execute 'install-grants' do 183 | cmd = "#{prefix_dir}/bin/mysql" 184 | cmd << ' -u root ' 185 | cmd << "#{pass_string} < #{prefix_dir}/etc/mysql_grants.sql" 186 | command cmd 187 | action :nothing 188 | end 189 | end 190 | end 191 | 192 | action :restart do 193 | converge_by 'smartos pattern' do 194 | service 'mysql' do 195 | supports :restart => true 196 | action :restart 197 | end 198 | end 199 | end 200 | 201 | action :reload do 202 | converge_by 'smartos pattern' do 203 | service 'mysql' do 204 | supports :reload => true 205 | action :reload 206 | end 207 | end 208 | end 209 | end 210 | end 211 | end 212 | end 213 | 214 | Chef::Platform.set :platform => :smartos, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Smartos 215 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_service_omnios.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | 3 | include Opscode::Mysql::Helpers 4 | 5 | class Chef 6 | class Provider 7 | class MysqlService 8 | class Omnios < Chef::Provider::MysqlService 9 | use_inline_resources if defined?(use_inline_resources) 10 | 11 | def whyrun_supported? 12 | true 13 | end 14 | 15 | action :create do 16 | converge_by 'omnios pattern' do 17 | ########## 18 | pkg_ver_string = new_resource.version.gsub('.', '') 19 | 20 | base_dir = "/opt/mysql#{pkg_ver_string}" 21 | prefix_dir = "/opt/mysql#{pkg_ver_string}" 22 | include_dir = "/opt/mysql#{pkg_ver_string}/etc/mysql/conf.d" 23 | run_dir = '/var/run/mysql' 24 | pid_file = '/var/run/mysql/mysql.pid' 25 | socket_file = '/tmp/mysql.sock' 26 | 27 | case new_resource.version 28 | when '5.5' 29 | my_cnf = "#{base_dir}/etc/my.cnf" 30 | when '5.6' 31 | my_cnf = "#{base_dir}/my.cnf" 32 | end 33 | ########## 34 | 35 | package new_resource.package_name do 36 | action :install 37 | end 38 | 39 | directory include_dir do 40 | owner 'mysql' 41 | group 'mysql' 42 | mode '0750' 43 | recursive true 44 | action :create 45 | end 46 | 47 | directory run_dir do 48 | owner 'mysql' 49 | group 'mysql' 50 | mode '0755' 51 | action :create 52 | recursive true 53 | end 54 | 55 | # data_dir 56 | directory new_resource.data_dir do 57 | owner 'mysql' 58 | group 'mysql' 59 | mode '0750' 60 | action :create 61 | recursive true 62 | end 63 | 64 | directory "#{new_resource.data_dir}/data" do 65 | owner 'mysql' 66 | group 'mysql' 67 | mode '0750' 68 | action :create 69 | recursive true 70 | end 71 | 72 | directory "#{new_resource.data_dir}/data/mysql" do 73 | owner 'mysql' 74 | group 'mysql' 75 | mode '0750' 76 | action :create 77 | recursive true 78 | end 79 | 80 | directory "#{new_resource.data_dir}/data/test" do 81 | owner 'mysql' 82 | group 'mysql' 83 | mode '0750' 84 | action :create 85 | recursive true 86 | end 87 | 88 | template my_cnf do 89 | if new_resource.template_source.nil? 90 | source "#{new_resource.version}/my.cnf.erb" 91 | cookbook 'mysql' 92 | else 93 | source new_resource.template_source 94 | end 95 | owner 'mysql' 96 | group 'mysql' 97 | mode '0600' 98 | variables( 99 | :base_dir => base_dir, 100 | :include_dir => include_dir, 101 | :data_dir => new_resource.data_dir, 102 | :pid_file => pid_file, 103 | :socket_file => socket_file, 104 | :port => new_resource.port, 105 | :lc_messages_dir => "#{base_dir}/share" 106 | ) 107 | action :create 108 | notifies :run, 'bash[move mysql data to datadir]' 109 | notifies :restart, 'service[mysql]' 110 | end 111 | 112 | bash 'move mysql data to datadir' do 113 | user 'root' 114 | code <<-EOH 115 | /usr/sbin/svcadm disable mysql \ 116 | && mv /var/mysql/* #{new_resource.data_dir} 117 | EOH 118 | action :nothing 119 | only_if "[ '/var/lib/mysql' != #{new_resource.data_dir} ]" 120 | only_if "[ `stat -c %h #{new_resource.data_dir}` -eq 2 ]" 121 | not_if '[ `stat -c %h /var/lib/mysql/` -eq 2 ]' 122 | end 123 | 124 | execute 'initialize mysql database' do 125 | cwd new_resource.data_dir 126 | command "#{prefix_dir}/scripts/mysql_install_db --basedir=#{base_dir} --user=mysql" 127 | creates "#{new_resource.data_dir}/mysql/user.frm" 128 | end 129 | 130 | template '/lib/svc/method/mysqld' do 131 | cookbook 'mysql' 132 | source 'omnios/svc.method.mysqld.erb' 133 | cookbook 'mysql' 134 | owner 'root' 135 | group 'root' 136 | mode '0555' 137 | variables( 138 | :base_dir => base_dir, 139 | :data_dir => new_resource.data_dir, 140 | :pid_file => pid_file 141 | ) 142 | action :create 143 | end 144 | 145 | template '/tmp/mysql.xml' do 146 | cookbook 'mysql' 147 | source 'omnios/mysql.xml.erb' 148 | owner 'root' 149 | mode '0644' 150 | variables(:version => new_resource.version) 151 | action :create 152 | notifies :run, 'execute[import mysql manifest]', :immediately 153 | end 154 | 155 | execute 'import mysql manifest' do 156 | command 'svccfg import /tmp/mysql.xml' 157 | action :nothing 158 | end 159 | 160 | service 'mysql' do 161 | supports :restart => true 162 | action [:start, :enable] 163 | end 164 | 165 | execute 'wait for mysql' do 166 | command "until [ -S #{socket_file} ] ; do sleep 1 ; done" 167 | timeout 10 168 | action :run 169 | end 170 | 171 | execute 'assign-root-password' do 172 | cmd = "#{prefix_dir}/bin/mysqladmin" 173 | cmd << ' -u root password ' 174 | cmd << node['mysql']['server_root_password'] 175 | command cmd 176 | action :run 177 | only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'" 178 | end 179 | 180 | template '/etc/mysql_grants.sql' do 181 | cookbook 'mysql' 182 | source 'grants/grants.sql.erb' 183 | owner 'root' 184 | group 'root' 185 | mode '0600' 186 | action :create 187 | notifies :run, 'execute[install-grants]' 188 | end 189 | 190 | if node['mysql']['server_root_password'].empty? 191 | pass_string = '' 192 | else 193 | pass_string = "-p#{node['mysql']['server_root_password']}" 194 | end 195 | 196 | execute 'install-grants' do 197 | cmd = "#{prefix_dir}/bin/mysql" 198 | cmd << ' -u root ' 199 | cmd << "#{pass_string} < /etc/mysql_grants.sql" 200 | command cmd 201 | retries 5 202 | retry_delay 2 203 | action :nothing 204 | end 205 | end 206 | end 207 | 208 | action :restart do 209 | converge_by 'omnios pattern' do 210 | service 'mysql' do 211 | supports :restart => true 212 | action :restart 213 | end 214 | end 215 | end 216 | 217 | action :reload do 218 | converge_by 'omnios pattern' do 219 | service 'mysql' do 220 | supports :reload => true 221 | action :reload 222 | end 223 | end 224 | end 225 | end 226 | end 227 | end 228 | end 229 | 230 | Chef::Platform.set :platform => :omnios, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Omnios 231 | -------------------------------------------------------------------------------- /cookbooks/mysql/libraries/provider_mysql_service_rhel.rb: -------------------------------------------------------------------------------- 1 | require 'chef/provider/lwrp_base' 2 | require_relative 'helpers' 3 | 4 | extend Opscode::Mysql::Helpers 5 | 6 | class Chef 7 | class Provider 8 | class MysqlService 9 | class Rhel < Chef::Provider::MysqlService 10 | use_inline_resources if defined?(use_inline_resources) 11 | 12 | def whyrun_supported? 13 | true 14 | end 15 | 16 | action :create do 17 | case node['platform_version'].to_i.to_s 18 | when '2013' 19 | case new_resource.version 20 | when '5.1' 21 | base_dir = '' 22 | include_dir = "#{base_dir}/etc/mysql/conf.d" 23 | prefix_dir = '/usr' 24 | lc_messages_dir = nil 25 | run_dir = '/var/run/mysqld' 26 | pid_file = '/var/run/mysql/mysql.pid' 27 | socket_file = '/var/lib/mysql/mysql.sock' 28 | package_name = 'mysql-server' 29 | service_name = 'mysqld' 30 | end 31 | when '2014' 32 | case new_resource.version 33 | when '5.1' 34 | base_dir = '' 35 | include_dir = "#{base_dir}/etc/mysql/conf.d" 36 | prefix_dir = '/usr' 37 | lc_messages_dir = nil 38 | run_dir = '/var/run/mysqld' 39 | pid_file = '/var/run/mysql/mysql.pid' 40 | socket_file = '/var/lib/mysql/mysql.sock' 41 | package_name = 'mysql-server' 42 | service_name = 'mysqld' 43 | when '5.5' 44 | base_dir = '' 45 | include_dir = "#{base_dir}/etc/mysql/conf.d" 46 | prefix_dir = '/usr' 47 | lc_messages_dir = nil 48 | run_dir = '/var/run/mysqld' 49 | pid_file = '/var/run/mysql/mysql.pid' 50 | socket_file = '/var/lib/mysql/mysql.sock' 51 | package_name = 'mysql-server' 52 | service_name = 'mysqld' 53 | end 54 | when '6' 55 | case new_resource.version 56 | when '5.1' 57 | base_dir = '' 58 | include_dir = "#{base_dir}/etc/mysql/conf.d" 59 | prefix_dir = '/usr' 60 | lc_messages_dir = nil 61 | run_dir = '/var/run/mysqld' 62 | pid_file = '/var/run/mysql/mysql.pid' 63 | socket_file = '/var/lib/mysql/mysql.sock' 64 | package_name = 'mysql-server' 65 | service_name = 'mysqld' 66 | end 67 | when '5' 68 | case new_resource.version 69 | when '5.0' 70 | base_dir = '' 71 | include_dir = "#{base_dir}/etc/mysql/conf.d" 72 | prefix_dir = '/usr' 73 | lc_messages_dir = nil 74 | run_dir = '/var/run/mysqld' 75 | pid_file = '/var/run/mysql/mysql.pid' 76 | socket_file = '/var/lib/mysql/mysql.sock' 77 | package_name = 'mysql-server' 78 | service_name = 'mysqld' 79 | when '5.1' 80 | base_dir = '/opt/rh/mysql51/root' 81 | include_dir = "#{base_dir}/etc/mysql/conf.d" 82 | prefix_dir = '/opt/rh/mysql51/root/usr' 83 | lc_messages_dir = nil 84 | run_dir = '/opt/rh/mysql51/root/var/run/mysqld/' 85 | pid_file = '/var/run/mysql/mysql.pid' 86 | socket_file = '/var/lib/mysql/mysql.sock' 87 | package_name = 'mysql51-mysql-server' 88 | service_name = 'mysql51-mysqld' 89 | when '5.5' 90 | base_dir = '/opt/rh/mysql55/root' 91 | include_dir = "#{base_dir}/etc/mysql/conf.d" 92 | prefix_dir = '/opt/rh/mysql55/root/usr' 93 | lc_messages_dir = nil 94 | run_dir = '/opt/rh/mysql55/root/var/run/mysqld/' 95 | pid_file = '/var/run/mysql/mysql.pid' 96 | socket_file = '/var/lib/mysql/mysql.sock' 97 | package_name = 'mysql55-mysql-server' 98 | service_name = 'mysql55-mysqld' 99 | end 100 | end 101 | 102 | converge_by 'rhel pattern' do 103 | package package_name do 104 | action :install 105 | end 106 | 107 | directory include_dir do 108 | owner 'mysql' 109 | group 'mysql' 110 | mode '0750' 111 | recursive true 112 | action :create 113 | end 114 | 115 | directory run_dir do 116 | owner 'mysql' 117 | group 'mysql' 118 | mode '0755' 119 | recursive true 120 | action :create 121 | end 122 | 123 | directory new_resource.data_dir do 124 | owner 'mysql' 125 | group 'mysql' 126 | mode '0750' 127 | recursive true 128 | action :create 129 | end 130 | 131 | service service_name do 132 | supports :restart => true 133 | action [:start, :enable] 134 | end 135 | 136 | execute 'wait for mysql' do 137 | command "until [ -S #{socket_file} ] ; do sleep 1 ; done" 138 | timeout 10 139 | action :run 140 | end 141 | 142 | template '/etc/mysql_grants.sql' do 143 | cookbook 'mysql' 144 | source 'grants/grants.sql.erb' 145 | owner 'root' 146 | group 'root' 147 | mode '0600' 148 | action :create 149 | notifies :run, 'execute[install-grants]' 150 | end 151 | 152 | if node['mysql']['server_root_password'].empty? 153 | pass_string = '' 154 | else 155 | pass_string = "-p#{node['mysql']['server_root_password']}" 156 | end 157 | 158 | execute 'install-grants' do 159 | cmd = "#{prefix_dir}/bin/mysql" 160 | cmd << ' -u root ' 161 | cmd << "#{pass_string} < /etc/mysql_grants.sql" 162 | command cmd 163 | action :nothing 164 | end 165 | 166 | template "#{base_dir}/etc/my.cnf" do 167 | if new_resource.template_source.nil? 168 | source "#{new_resource.version}/my.cnf.erb" 169 | cookbook 'mysql' 170 | else 171 | source new_resource.template_source 172 | end 173 | owner 'mysql' 174 | group 'mysql' 175 | mode '0600' 176 | variables( 177 | :base_dir => base_dir, 178 | :data_dir => new_resource.data_dir, 179 | :include_dir => include_dir, 180 | :lc_messages_dir => lc_messages_dir, 181 | :pid_file => pid_file, 182 | :port => new_resource.port, 183 | :socket_file => socket_file 184 | ) 185 | action :create 186 | notifies :run, 'bash[move mysql data to datadir]' 187 | notifies :restart, "service[#{service_name}]" 188 | end 189 | 190 | bash 'move mysql data to datadir' do 191 | user 'root' 192 | code <<-EOH 193 | service #{service_name} stop \ 194 | && for i in `ls #{base_dir}/var/lib/mysql | grep -v mysql.sock` ; do mv #{base_dir}/var/lib/mysql/$i #{new_resource.data_dir} ; done 195 | EOH 196 | action :nothing 197 | only_if "[ '#{base_dir}/var/lib/mysql' != #{new_resource.data_dir} ]" 198 | only_if "[ `stat -c %h #{new_resource.data_dir}` -eq 2 ]" 199 | not_if "[ `stat -c %h #{base_dir}/var/lib/mysql/` -eq 2 ]" 200 | end 201 | 202 | execute 'assign-root-password' do 203 | cmd = "#{prefix_dir}/bin/mysqladmin" 204 | cmd << ' -u root password ' 205 | cmd << node['mysql']['server_root_password'] 206 | command cmd 207 | action :run 208 | only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'" 209 | end 210 | end 211 | end 212 | 213 | action :restart do 214 | service_name = service_name_for( 215 | node['platform'], 216 | node['platform_family'], 217 | node['platform_version'], 218 | new_resource.version 219 | ) 220 | 221 | converge_by 'rhel pattern' do 222 | service service_name do 223 | supports :restart => true 224 | action :restart 225 | end 226 | end 227 | end 228 | 229 | action :reload do 230 | service_name = service_name_for( 231 | node['platform'], 232 | node['platform_family'], 233 | node['platform_version'], 234 | new_resource.version 235 | ) 236 | 237 | converge_by 'rhel pattern' do 238 | service service_name do 239 | action :reload 240 | end 241 | end 242 | end 243 | end 244 | end 245 | end 246 | end 247 | 248 | Chef::Platform.set :platform => :amazon, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel 249 | Chef::Platform.set :platform => :redhat, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel 250 | Chef::Platform.set :platform => :centos, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel 251 | Chef::Platform.set :platform => :oracle, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel 252 | Chef::Platform.set :platform => :scientific, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel 253 | -------------------------------------------------------------------------------- /cookbooks/mysql/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | mysql Cookbook CHANGELOG 2 | ======================== 3 | This file is used to list changes made in each version of the mysql cookbook. 4 | 5 | 6 | v5.1.2 (2014-04-09) 7 | ------------------- 8 | - [COOK-4519] - Fix error in run_dir for Ubuntu 9 | - [COOK-4531] - Fix pid and run_dir for Debian 10 | 11 | 12 | v5.1.0 (2014-04-08) 13 | ------------------- 14 | [COOK-4523] - Allow for both :restart and :reload 15 | 16 | 17 | v5.0.6 (2014-04-07) 18 | ------------------- 19 | - [COOK-4519] - Updating specs to reflect pid file change on Ubuntu 20 | 21 | 22 | v5.0.4 (2014-04-07) 23 | ------------------- 24 | - [COOK-4519] - Fix path to pid file on Ubuntu 25 | 26 | 27 | v5.0.2 (2014-04-01) 28 | ------------------- 29 | - Moving server_deprecated into recipes directory 30 | 31 | 32 | v5.0.0 (2014-03-31) 33 | ------------------- 34 | - Rewriting as a library cookbook 35 | - Exposing mysql_service and mysql_client resources 36 | - User now needs to supply configuration 37 | - Moving attribute driven recipe to server-deprecated 38 | 39 | 40 | v4.1.2 (2014-02-28) 41 | ------------------- 42 | - [COOK-4349] - Fix invalid platform check 43 | - [COOK-4184] - Better handling of Ubuntu upstart service 44 | - [COOK-2100] - Changing innodb_log_file_size tunable results in inability to start MySQL 45 | 46 | 47 | v4.1.1 (2014-02-25) 48 | ------------------- 49 | - **[COOK-2966] - Address foodcritic failures' 50 | - **[COOK-4182] - Template parse failure in /etc/init/mysql.conf (data_dir)' 51 | - **[COOK-4198] - Added missing tunable' 52 | - **[COOK-4206] - create root@127.0.0.1, as well as root@localhost' 53 | 54 | 55 | v4.0.20 (2014-01-18) 56 | -------------------- 57 | * [COOK-3931] - MySQL Server Recipe Regression for Non-LTS Ubuntu Versions 58 | * [COOK-3945] - MySQL cookbook fails on Ubuntu 13.04/13.10 59 | * [COOK-3966] - mysql::server recipe can't find a template with debian 7.x 60 | * [COOK-3985] - Missing /etc/mysql/debian.cnf template on mysql::_server_debian.rb recipe (mysql 4.0.4) 61 | * [COOK-3974] - debian.cnf not updated 62 | * [COOK-4001] - Pull request: Fixes for broken mysql::server on Debian 63 | * [COOK-4071] - Mysql cookbook doesn't work on debian 7.2 64 | 65 | 66 | v4.0.14 67 | ------- 68 | Fixing style cops 69 | 70 | 71 | v4.0.12 72 | ------- 73 | ### Bug 74 | - **[COOK-4068](https://tickets.opscode.com/browse/COOK-4068)** - rework MySQL Windows recipe 75 | 76 | ### Improvement 77 | - **[COOK-3801](https://tickets.opscode.com/browse/COOK-3801)** - Add innodb_adaptive_flushing_method and innodb_adaptive_checkpoint 78 | 79 | 80 | v4.0.10 81 | ------- 82 | fixing metadata version error. locking to 3.0 83 | 84 | 85 | v4.0.8 86 | ------ 87 | Locking yum dependency to '< 3' 88 | 89 | 90 | v4.0.6 91 | ------ 92 | # Bug 93 | - [COOK-3943] Notifying service restart on grants update 94 | 95 | 96 | v4.0.4 97 | ------ 98 | [COOK-3952] - Adding 'recursive true' to directory resources 99 | 100 | 101 | v4.0.2 102 | ------ 103 | ### BUGS 104 | - Adding support for Amazon Linux in attributes/server_rhel.rb 105 | - Fixing bug where unprivileged users cannot connect over a local socket. Adding integration test. 106 | - Fixing bug in mysql_grants_cmd generation 107 | 108 | 109 | v4.0.0 110 | ------ 111 | - [COOK-3928] Heavily refactoring for readability. Moving platform implementation into separate recipes 112 | - Moving integration tests from minitest to serverspec, removing "improper" tests 113 | - Moving many attributes into the ['mysql']['server']['whatever'] namespace 114 | - [COOK-3481] - Merged Lucas Welsh's Windows bits and moved into own recipe 115 | - [COOK-3697] - Adding security hardening attributes 116 | - [COOK-3780] - Fixing data_dir on Debian and Ubuntu 117 | - [COOK-3807] - Don't use execute[assign-root-password] on Debian and Ubuntu 118 | - [COOK-3881] - Fixing /etc being owned by mysql user 119 | 120 | 121 | v3.0.12 122 | ------- 123 | ### Bug 124 | - **[COOK-3752](https://tickets.opscode.com/browse/COOK-3752)** - mysql service fails to start in mysql::server recipe 125 | 126 | 127 | v3.0.10 128 | ------- 129 | - Fix a failed release attempt for v3.0.8 130 | 131 | 132 | v3.0.8 133 | ------ 134 | ### Bug 135 | - **[COOK-3749](https://tickets.opscode.com/browse/COOK-3749)** - Fix a regression with Chef 11-specific features 136 | 137 | 138 | v3.0.6 139 | ------ 140 | ### Bug 141 | - **[COOK-3674](https://tickets.opscode.com/browse/COOK-3674)** - Fix an issue where the MySQL server fails to set the root password correctly when `data_dir` is a non-default value 142 | - **[COOK-3647](https://tickets.opscode.com/browse/COOK-3647)** - Fix README typo (databas => database) 143 | - **[COOK-3477](https://tickets.opscode.com/browse/COOK-3477)** - Fix log-queries-not-using-indexes not working 144 | - **[COOK-3436](https://tickets.opscode.com/browse/COOK-3436)** - Pull percona repo in compilation phase 145 | - **[COOK-3208](https://tickets.opscode.com/browse/COOK-3208)** - Fix README typo (LitenPort => ListenPort) 146 | - **[COOK-3149](https://tickets.opscode.com/browse/COOK-3149)** - Create my.cnf before installing 147 | - **[COOK-2681](https://tickets.opscode.com/browse/COOK-2681)** - Fix log_slow_queries for 5.5+ 148 | - **[COOK-2606](https://tickets.opscode.com/browse/COOK-2606)** - Use proper bind address on cloud providers 149 | 150 | ### Improvement 151 | - **[COOK-3498](https://tickets.opscode.com/browse/COOK-3498)** - Add support for replicate_* variables in my.cnf 152 | 153 | 154 | v3.0.4 155 | ------ 156 | ### Bug 157 | - **[COOK-3310](https://tickets.opscode.com/browse/COOK-3310)** - Fix missing `GRANT` option 158 | - **[COOK-3233](https://tickets.opscode.com/browse/COOK-3233)** - Fix escaping special characters 159 | - **[COOK-3156](https://tickets.opscode.com/browse/COOK-3156)** - Fix GRANTS file when `remote_root_acl` is specified 160 | - **[COOK-3134](https://tickets.opscode.com/browse/COOK-3134)** - Fix Chef 11 support 161 | - **[COOK-2318](https://tickets.opscode.com/browse/COOK-2318)** - Remove redundant `if` block around `node.mysql.tunable.log_bin` 162 | 163 | v3.0.2 164 | ------ 165 | ### Bug 166 | - [COOK-2158]: apt-get update is run twice at compile time 167 | - [COOK-2832]: mysql grants.sql file has errors depending on attrs 168 | - [COOK-2995]: server.rb is missing a platform_family comparison value 169 | 170 | ### Sub-task 171 | - [COOK-2102]: `innodb_flush_log_at_trx_commit` value is incorrectly set based on CPU count 172 | 173 | v3.0.0 174 | ------ 175 | **Note** This is a backwards incompatible version with previous versions of the cookbook. Tickets that introduce incompatibility are COOK-2615 and COOK-2617. 176 | 177 | - [COOK-2478] - Duplicate 'read_only' server attribute in base and tunable 178 | - [COOK-2471] - Add tunable to set slave_compressed_protocol for reduced network traffic 179 | - [COOK-1059] - Update attributes in mysql cookbook to support missing options for my.cnf usable by Percona 180 | - [COOK-2590] - Typo in server recipe to do with conf_dir and confd_dir 181 | - [COOK-2602] - Add `lower_case_table_names` tunable 182 | - [COOK-2430] - Add a tunable to create a network ACL when allowing `remote_root_access` 183 | - [COOK-2619] - mysql: isamchk deprecated 184 | - [COOK-2515] - Better support for SUSE distribution for mysql cookbook 185 | - [COOK-2557] - mysql::percona_repo attributes missing and key server typo 186 | - [COOK-2614] - Duplicate `innodb_file_per_table` 187 | - [COOK-2145] - MySQL cookbook should remove anonymous and password less accounts 188 | - [COOK-2553] - Enable include directory in my.cnf template for any platform 189 | - [COOK-2615] - Rename `key_buffer` to `key_buffer_size` 190 | - [COOK-2626] - Percona repo URL is being constructed incorrectly 191 | - [COOK-2616] - Unneeded attribute thread_cache 192 | - [COOK-2618] - myisam-recover not using attribute value 193 | - [COOK-2617] - open-files is a duplicate of open-files-limit 194 | 195 | v2.1.2 196 | ------ 197 | - [COOK-2172] - Mysql cookbook duplicates `binlog_format` configuration 198 | 199 | v2.1.0 200 | ------ 201 | - [COOK-1669] - Using platform("ubuntu") in default attributes always returns true 202 | - [COOK-1694] - Added additional my.cnf fields and reorganized cookbook to avoid race conditions with mysql startup and sql script execution 203 | - [COOK-1851] - Support server-id and binlog_format settings 204 | - [COOK-1929] - Update msyql server attributes file because setting attributes without specifying a precedence is deprecated 205 | - [COOK-1999] - Add read_only tunable useful for replication slave servers 206 | 207 | v2.0.2 208 | ------ 209 | - [COOK-1967] - mysql: trailing comma in server.rb platform family 210 | 211 | v2.0.0 212 | ------ 213 | **Important note for this release** 214 | 215 | Under Chef Solo, you must set the node attributes for the root, debian and repl passwords or the run will completely fail. See COOK-1737 for background on this. 216 | 217 | - [COOK-1390] - MySQL service cannot start after reboot 218 | - [COOK-1610] - Set root password outside preseed (blocker for drop-in mysql replacements) 219 | - [COOK-1624] - Mysql cookbook fails to even compile on windows 220 | - [COOK-1669] - Using platform("ubuntu") in default attributes always returns true 221 | - [COOK-1686] - Add mysql service start 222 | - [COOK-1687] - duplicate `innodb_buffer_pool_size` attribute 223 | - [COOK-1704] - mysql cookbook fails spec tests when minitest-handler cookbook enabled 224 | - [COOK-1737] - Fail a chef-solo run when `server_root_password`, `server_debian_password`, and/or `server_repl_password` is not set 225 | - [COOK-1769] - link to database recipe in mysql README goes to old opscode/cookbooks repo instead of opscode-cookbook organization 226 | - [COOK-1963] - use `platform_family` 227 | 228 | v1.3.0 229 | ------ 230 | **Important note for this release** 231 | 232 | This version no longer installs Ruby bindings in the client recipe by default. Use the ruby recipe if you'd like the RubyGem. If you'd like packages from your distribution, use them in your application's specific cookbook/recipe, or modify the client packages attribute. This resolves the following tickets: 233 | 234 | - COOK-932 235 | - COOK-1009 236 | - COOK-1384 237 | 238 | Additionally, this cookbook now has tests (COOK-1439) for use under test-kitchen. 239 | 240 | The following issues are also addressed in this release. 241 | 242 | - [COOK-1443] - MySQL (>= 5.1.24) does not support `innodb_flush_method` = fdatasync 243 | - [COOK-1175] - Add Mac OS X support 244 | - [COOK-1289] - handle additional tunable attributes 245 | - [COOK-1305] - add auto-increment-increment and auto-increment-offset attributes 246 | - [COOK-1397] - make the port an attribute 247 | - [COOK-1439] - Add MySQL cookbook tests for test-kitchen support 248 | - [COOK-1236] - Move package names into attributes to allow percona to free-ride 249 | - [COOK-934] - remove deprecated mysql/libraries/database.rb, use the database cookbook instead. 250 | - [COOK-1475] - fix restart on config change 251 | 252 | v1.2.6 253 | ------ 254 | - [COOK-1113] - Use an attribute to determine if upstart is used 255 | - [COOK-1121] - Add support for Windows 256 | - [COOK-1140] - Fix conf.d on Debian 257 | - [COOK-1151] - Fix server_ec2 handling /var/lib/mysql bind mount 258 | - [COOK-1321] - Document setting password attributes for solo 259 | 260 | v1.2.4 261 | ------ 262 | - [COOK-992] - fix FATAL nameerror 263 | - [COOK-827] - `mysql:server_ec2` recipe can't mount `data_dir` 264 | - [COOK-945] - FreeBSD support 265 | 266 | v1.2.2 267 | ------ 268 | - [COOK-826] mysql::server recipe doesn't quote password string 269 | - [COOK-834] Add 'scientific' and 'amazon' platforms to mysql cookbook 270 | 271 | v1.2.1 272 | ------ 273 | - [COOK-644] Mysql client cookbook 'package missing' error message is confusing 274 | - [COOK-645] RHEL6/CentOS6 - mysql cookbook contains 'skip-federated' directive which is unsupported on MySQL 5.1 275 | 276 | v1.2.0 277 | ------ 278 | - [COOK-684] remove mysql_database LWRP 279 | 280 | v1.0.8 281 | ------ 282 | - [COOK-633] ensure "cloud" attribute is available 283 | 284 | v1.0.7 285 | ------ 286 | - [COOK-614] expose all mysql tunable settings in config 287 | - [COOK-617] bind to private IP if available 288 | 289 | v1.0.6 290 | ------ 291 | - [COOK-605] install mysql-client package on ubuntu/debian 292 | 293 | v1.0.5 294 | ------ 295 | - [COOK-465] allow optional remote root connections to mysql 296 | - [COOK-455] improve platform version handling 297 | - externalize conf_dir attribute for easier cross platform support 298 | - change datadir attribute to data_dir for consistency 299 | 300 | v1.0.4 301 | ------ 302 | - fix regressions on debian platform 303 | - [COOK-578] wrap root password in quotes 304 | - [COOK-562] expose all tunables in my.cnf 305 | -------------------------------------------------------------------------------- /cookbooks/mysql/templates/default/deprecated/my.cnf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Generated by Chef for <%= node['hostname'] %> 3 | # 4 | # Local modifications will be overwritten. 5 | # 6 | # The MySQL database server configuration file. 7 | # 8 | # You can copy this to one of: 9 | # - "/etc/mysql/my.cnf" to set global options, 10 | # - "~/.my.cnf" to set user-specific options. 11 | # 12 | # One can use all long options that the program supports. 13 | # Run program with --help to get a list of available options and with 14 | # --print-defaults to see which it would actually understand and use. 15 | # 16 | # For explanations see 17 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 18 | 19 | # This will be passed to all mysql clients 20 | # It has been reported that passwords should be enclosed with ticks/quotes 21 | # escpecially if they contain "#" chars... 22 | # Remember to edit /etc/mysql/debian.cnf when changing the socket location. 23 | [client] 24 | port = <%= node['mysql']['port'] %> 25 | socket = <%= node['mysql']['server']['socket'] %> 26 | 27 | # Here is entries for some specific programs 28 | # The following values assume you have at least 32M ram 29 | 30 | # This was formally known as [safe_mysqld]. Both versions are currently parsed. 31 | [mysqld_safe] 32 | socket = <%= node['mysql']['server']['socket'] %> 33 | nice = <%= node['mysql']['nice'] %> 34 | 35 | [mysqld] 36 | # 37 | # * Basic Settings 38 | # 39 | 40 | # 41 | # * IMPORTANT 42 | # If you make changes to these settings and your system uses apparmor, you may 43 | # also need to also adjust /etc/apparmor.d/usr.sbin.mysqld. 44 | # 45 | 46 | user = mysql 47 | pid-file = <%= node['mysql']['server']['pid_file'] %> 48 | socket = <%= node['mysql']['server']['socket'] %> 49 | port = <%= node['mysql']['port'] %> 50 | basedir = <%= node['mysql']['server']['basedir'] %> 51 | datadir = <%= node['mysql']['data_dir'] %> 52 | tmpdir = <%= node['mysql']['server']['tmpdir'].join(':') %> 53 | skip-external-locking 54 | <%- if node['mysql']['tunable']['skip-name-resolve'] %> 55 | skip-name-resolve 56 | <%- end %> 57 | 58 | # Charset and Collation 59 | character-set-server = <%= node['mysql']['tunable']['character-set-server'] %> 60 | collation-server = <%= node['mysql']['tunable']['collation-server'] %> 61 | <%- if node['mysql']['tunable']['lower_case_table_names'] %> 62 | lower_case_table_names = <%= node['mysql']['tunable']['lower_case_table_names'] %> 63 | <%- end %> 64 | <%- if node['mysql']['tunable']['event_scheduler'] %> 65 | event_scheduler = <%= node['mysql']['tunable']['event_scheduler'] %> 66 | <%- end %> 67 | <%- if node['mysql']['tunable']['skip-character-set-client-handshake'] %> 68 | skip-character-set-client-handshake 69 | <%- end %> 70 | <%- if (node['mysql']['tunable']['lc_messages_dir'] && node['mysql']['tunable']['lc_messages']) %> 71 | lc_messages_dir = <%= node['mysql']['lc_messages_dir'] %> 72 | lc_messages = <%= node['mysql']['lc_messages'] %> 73 | <%- elsif (node['mysql']['tunable']['languages']) %> 74 | languages = <%= node['mysql']['tunable']['languages'] %> 75 | <%- end %> 76 | 77 | # 78 | # Instead of skip-networking the default is now to listen only on 79 | # localhost which is more compatible and is not less secure. 80 | bind-address = <%= node['mysql']['bind_address'] %> 81 | # 82 | # * Fine Tuning 83 | # 84 | key_buffer_size = <%= node['mysql']['tunable']['key_buffer_size'] %> 85 | max_allowed_packet = <%= node['mysql']['tunable']['max_allowed_packet'] %> 86 | thread_stack = <%= node['mysql']['tunable']['thread_stack'] %> 87 | thread_cache_size = <%= node['mysql']['tunable']['thread_cache_size'] %> 88 | sort_buffer_size = <%= node['mysql']['tunable']['sort_buffer_size'] %> 89 | read_buffer_size = <%= node['mysql']['tunable']['read_buffer_size'] %> 90 | read_rnd_buffer_size = <%= node['mysql']['tunable']['read_rnd_buffer_size'] %> 91 | join_buffer_size = <%= node['mysql']['tunable']['join_buffer_size'] %> 92 | 93 | auto-increment-increment = <%= node['mysql']['auto-increment-increment'] %> 94 | auto-increment-offset = <%= node['mysql']['auto-increment-offset'] %> 95 | 96 | # This replaces the startup script and checks MyISAM tables if needed 97 | # the first time they are touched 98 | myisam-recover = <%= node['mysql']['tunable']['myisam-recover'] %> 99 | max_connections = <%= node['mysql']['tunable']['max_connections'] %> 100 | max_connect_errors = <%= node['mysql']['tunable']['max_connect_errors'] %> 101 | concurrent_insert = <%= node['mysql']['tunable']['concurrent_insert'] %> 102 | connect_timeout = <%= node['mysql']['tunable']['connect_timeout'] %> 103 | wait_timeout = <%= node['mysql']['tunable']['wait_timeout'] %> 104 | net_read_timeout = <%= node['mysql']['tunable']['net_read_timeout'] %> 105 | net_write_timeout = <%= node['mysql']['tunable']['net_write_timeout'] %> 106 | back_log = <%= node['mysql']['tunable']['back_log'] %> 107 | <%- if node['mysql']['version'].to_f >= 5.6 %> 108 | table_open_cache = <%= node['mysql']['tunable']['table_open_cache'] %> 109 | <%- else %> 110 | table_cache = <%= node['mysql']['tunable']['table_open_cache'] %> 111 | <%- end %> 112 | 113 | tmp_table_size = <%= node['mysql']['tunable']['tmp_table_size'] %> 114 | max_heap_table_size = <%= node['mysql']['tunable']['max_heap_table_size'] %> 115 | bulk_insert_buffer_size = <%= node['mysql']['tunable']['bulk_insert_buffer_size'] %> 116 | open-files-limit = <%= node['mysql']['tunable']['open-files-limit'] %> 117 | 118 | # Default Table Settings 119 | <%- if node['mysql']['tunable']['sql_mode'] %> 120 | sql_mode = "<%= node['mysql']['tunable']['sql_mode'] %>" 121 | <%- end %> 122 | 123 | # 124 | # * Query Cache Configuration 125 | # 126 | query_cache_limit = <%= node['mysql']['tunable']['query_cache_limit'] %> 127 | query_cache_size = <%= node['mysql']['tunable']['query_cache_size'] %> 128 | # 129 | # * Logging 130 | # 131 | # Both location gets rotated by the cronjob. 132 | # Be aware that this log type is a performance killer. 133 | #log = /var/log/mysql/mysql.log 134 | # 135 | # Error logging goes to syslog. This is a Debian improvement :) 136 | <%- if node['mysql']['tunable']['log_error'] %> 137 | log_error = <%= node['mysql']['tunable']['log_error'] %> 138 | <%- end %> 139 | <%- if node['mysql']['tunable']['log_warnings'] %> 140 | log_warnings 141 | <%- end %> 142 | # 143 | # * Replication 144 | # 145 | 146 | 147 | # 148 | # Here you can see queries with especially long duration 149 | <%- if node['mysql']['server']['slow_query_log'] %> 150 | slow_query_log = 1 151 | slow_query_log_file = <%= node['mysql']['server']['slow_query_log_file'] %> 152 | <%- else %> 153 | log_slow_queries = <%= node['mysql']['server']['log_slow_queries'] %> 154 | <%- end %> 155 | 156 | long_query_time = <%= node['mysql']['tunable']['long_query_time'] %> 157 | <%- if node['mysql']['tunable']['log_queries_not_using_index'] and node['mysql']['tunable']['slow_query_log'] %> 158 | log-queries-not-using-indexes 159 | <%- end %> 160 | # 161 | # The following can be used as easy to replay backup logs or for replication. 162 | # note: if you are setting up a replication slave, see README.Debian about 163 | # other settings you may need to change. 164 | <%- if node['mysql']['tunable']['server_id'] %> 165 | server-id = <%= node['mysql']['tunable']['server_id'] %> 166 | <% end %> 167 | <%- if node['mysql']['tunable']['log_bin'] %> 168 | log_bin = <%= node['mysql']['tunable']['log_bin'] %> 169 | binlog_format = <%= node['mysql']['tunable']['binlog_format'] %> 170 | log_slave_updates = <%= node['mysql']['tunable']['log_slave_updates'] %> 171 | <%- end %> 172 | <%- if node['mysql']['tunable']['log_bin_trust_function_creators'] %> 173 | log_bin_trust_function_creators 174 | <%- end %> 175 | expire_logs_days = <%= node['mysql']['tunable']['expire_logs_days'] %> 176 | max_binlog_size = <%= node['mysql']['tunable']['max_binlog_size'] %> 177 | binlog_cache_size = <%= node['mysql']['tunable']['binlog_cache_size'] %> 178 | #binlog_do_db = include_database_name 179 | #binlog_ignore_db = include_database_name 180 | <%- if node['mysql']['tunable']['relay_log'] %> 181 | relay_log = <%= node['mysql']['tunable']['relay_log'] %> 182 | <%- end %> 183 | <%- if node['mysql']['tunable']['relay_log_index'] %> 184 | relay_log_index = <%= node['mysql']['tunable']['relay_log_index'] %> 185 | <%- end %> 186 | 187 | <%- if node['mysql']['tunable']['replicate_do_db'] %> 188 | replicate_do_db = <%= node['mysql']['tunable']['replicate_do_db'] %> 189 | <%- end %> 190 | <%- if node['mysql']['tunable']['replicate_do_table'] %> 191 | replicate_do_table = <%= node['mysql']['tunable']['replicate_do_table'] %> 192 | <%- end %> 193 | <%- if node['mysql']['tunable']['replicate_ignore_db'] %> 194 | replicate_ignore_db = <%= node['mysql']['tunable']['replicate_ignore_db'] %> 195 | <%- end %> 196 | <%- if node['mysql']['tunable']['replicate_ignore_table'] %> 197 | replicate_ignore_table = <%= node['mysql']['tunable']['replicate_ignore_table'] %> 198 | <%- end %> 199 | <%- if node['mysql']['tunable']['replicate_wild_do_table'] %> 200 | replicate_wild_do_table = <%= node['mysql']['tunable']['replicate_wild_do_table'] %> 201 | <%- end %> 202 | <%- if node['mysql']['tunable']['replicate_wild_ignore_table'] %> 203 | replicate_wild_ignore_table = <%= node['mysql']['tunable']['replicate_wild_ignore_table'] %> 204 | <%- end %> 205 | 206 | 207 | sync_binlog = <%= node['mysql']['tunable']['sync_binlog'] %> 208 | <%- if node['mysql']['tunable']['skip_slave_start'] %> 209 | skip_slave_start 210 | <%- end %> 211 | <%- if node['mysql']['tunable']['read_only'] %> 212 | read_only = 1 213 | <%- end %> 214 | 215 | <%- if node['mysql']['tunable']['transaction-isolation'] %> 216 | transaction-isolation = <%= node['mysql']['tunable']['transaction-isolation'] %> 217 | <%- end %> 218 | 219 | <%- if node['mysql']['tunable']['slave_compressed_protocol'] %> 220 | slave_compressed_protocol = <%= node['mysql']['tunable']['slave_compressed_protocol'] %> 221 | <%- end %> 222 | # 223 | # * InnoDB 224 | # 225 | # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. 226 | # Read the manual for more InnoDB related options. There are many! 227 | # You might want to disable InnoDB to shrink the mysqld process by circa 100MB. 228 | #skip-innodb 229 | 230 | <%- if node["mysql"]["version"].to_f >= 5.5 %> 231 | innodb_write_io_threads = <%= node['mysql']['tunable']['innodb_write_io_threads'] %> 232 | innodb_io_capacity = <%= node['mysql']['tunable']['innodb_io_capacity'] %> 233 | innodb_read_io_threads = <%= node['mysql']['tunable']['innodb_read_io_threads'] %> 234 | innodb_buffer_pool_instances = <%= node['mysql']['tunable']['innodb_buffer_pool_instances'] %> 235 | <%- end %> 236 | 237 | ## InnoDB Plugin Independent Settings 238 | innodb_data_home_dir = <%= node['mysql']['data_dir'] %> 239 | innodb_log_group_home_dir = <%= node['mysql']['server']['directories']['log_dir'] %> 240 | <%- if node['mysql']['log_files_in_group'] %> 241 | innodb_log_files_in_group = <%= node['mysql']['log_files_in_group'] %> 242 | <%- end %> 243 | 244 | <%- if node['mysql']['innodb_status_file'] %> 245 | innodb_status_file 246 | <%- end %> 247 | <%- if node['mysql']['tunable']['innodb_file_per_table'] %> 248 | innodb_file_per_table 249 | <%- end %> 250 | innodb_table_locks = <%= node['mysql']['tunable']['innodb_table_locks'] %> 251 | innodb_lock_wait_timeout = <%= node['mysql']['tunable']['innodb_lock_wait_timeout'] %> 252 | <%- if node['mysql']['tunable']['innodb_rollback_on_timeout'] %> 253 | innodb_rollback_on_timeout 254 | <%- end %> 255 | innodb_thread_concurrency = <%= node['mysql']['tunable']['innodb_thread_concurrency'] %> 256 | innodb_commit_concurrency = <%= node['mysql']['tunable']['innodb_commit_concurrency'] %> 257 | innodb_support_xa = <%= node['mysql']['tunable']['innodb_support_xa'] %> 258 | <%- if node['mysql']['tunable']['skip-innodb-doublewrite'] %> 259 | skip-innodb-doublewrite 260 | <%- end %> 261 | 262 | innodb_buffer_pool_size = <%= node['mysql']['tunable']['innodb_buffer_pool_size'] %> 263 | innodb_log_file_size = <%= node['mysql']['tunable']['innodb_log_file_size'] %> 264 | innodb_additional_mem_pool_size = <%= node['mysql']['tunable']['innodb_additional_mem_pool_size'] %> 265 | innodb_data_file_path = <%= node['mysql']['tunable']['innodb_data_file_path'] %> 266 | innodb_flush_log_at_trx_commit = <%= node['mysql']['tunable']['innodb_flush_log_at_trx_commit'] %> 267 | <%- if node['mysql']['tunable']['innodb_flush_method'] %> 268 | innodb_flush_method = <%= node['mysql']['tunable']['innodb_flush_method'] %> 269 | <%- end %> 270 | innodb_log_buffer_size = <%= node['mysql']['tunable']['innodb_log_buffer_size'] %> 271 | <%- if node['mysql']['tunable']['innodb_adaptive_flushing'] %> 272 | innodb_adaptive_flushing = <%= node['mysql']['tunable']['innodb_adaptive_flushing'] %> 273 | <%- end %> 274 | <%- if node['mysql']['tunable']['innodb_adaptive_flushing_method'] %> 275 | innodb_adaptive_flushing_method = <%= node['mysql']['tunable']['innodb_adaptive_flushing_method'] %> 276 | <%- end %> 277 | <%- if node['mysql']['tunable']['innodb_adaptive_checkpoint'] %> 278 | innodb_adaptive_checkpoint = <%= node['mysql']['tunable']['innodb_adaptive_checkpoint'] %> 279 | <%- end %> 280 | 281 | <% if node['mysql']['server']['skip_federated'] %> 282 | # 283 | # * Federated 284 | # 285 | # The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files 286 | # shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth). 287 | # 288 | skip-federated 289 | <% end %> 290 | # 291 | # * Security Features 292 | # 293 | # Read the manual, too, if you want chroot! 294 | 295 | <% if node['mysql']['security']['chroot'] -%> 296 | chroot = <%= node['mysql']['security']['chroot'] %> 297 | <% end %> 298 | 299 | <% if node['mysql']['security']['safe_user_create'] -%> 300 | safe-user-create = <%= node['mysql']['security']['safe_user_create'] %> 301 | <% end %> 302 | 303 | <% if node['mysql']['security']['secure_auth'] -%> 304 | secure-auth = <%= node['mysql']['security']['secure_auth'] %> 305 | <% end %> 306 | 307 | <% if node['mysql']['security']['skip_symbolic_links'] -%> 308 | skip-symbolic-links = <%= node['mysql']['security']['skip_symbolic_links'] %> 309 | <% end %> 310 | 311 | <% if node['mysql']['security']['secure_file_priv'] -%> 312 | secure-file-priv = <%= node['mysql']['security']['secure_file_priv'] %> 313 | <% end %> 314 | 315 | <% if node['mysql']['security']['local_infile'] -%> 316 | local-infile = <%= node['mysql']['security']['local_infile'] %> 317 | <% end %> 318 | 319 | <% if node['mysql']['security']['skip_show_database'] -%> 320 | skip-show-database 321 | <% end %> 322 | 323 | # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". 324 | # 325 | # ssl-ca=/etc/mysql/cacert.pem 326 | # ssl-cert=/etc/mysql/server-cert.pem 327 | # ssl-key=/etc/mysql/server-key.pem 328 | 329 | [mysqldump] 330 | quick 331 | quote-names 332 | max_allowed_packet = <%= node['mysql']['tunable']['max_allowed_packet'] %> 333 | 334 | [mysql] 335 | #no-auto-rehash # faster start of mysql but no tab completition 336 | 337 | [myisamchk] 338 | key_buffer = <%= node['mysql']['tunable']['max_allowed_packet'] %> 339 | 340 | myisam_sort_buffer_size = <%= node['mysql']['tunable']['myisam_sort_buffer_size'] %> 341 | myisam_max_sort_file_size = <%= node['mysql']['tunable']['myisam_max_sort_file_size'] %> 342 | myisam_repair_threads = <%= node['mysql']['tunable']['myisam_repair_threads'] %> 343 | myisam-recover = <%= node['mysql']['tunable']['myisam-recover'] %> 344 | 345 | # 346 | # * NDB Cluster 347 | # 348 | # See /usr/share/doc/mysql-server-*/README.Debian for more information. 349 | # 350 | # The following configuration is read by the NDB Data Nodes (ndbd processes) 351 | # not from the NDB Management Nodes (ndb_mgmd processes). 352 | # 353 | # [MYSQL_CLUSTER] 354 | # ndb-connectstring=127.0.0.1 355 | 356 | <% case node['platform_family'] -%> 357 | <% when "rhel", "fedora", "suse" -%> 358 | # 359 | # * BerkeleyDB 360 | # 361 | # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12. 362 | skip-bdb 363 | # Default to using old password format for compatibility with mysql 3.x 364 | # clients (those using the mysqlclient10 compatibility package). 365 | old_passwords = <%= node['mysql']['old_passwords'] %> 366 | <% end -%> 367 | 368 | <% if node['mysql']['server']['directories']['confd_dir'] -%> 369 | # 370 | # * IMPORTANT: Additional settings that can override those from this file! 371 | # The files must end with '.cnf', otherwise they'll be ignored. 372 | # 373 | !includedir <%= node['mysql']['server']['directories']['confd_dir'] %>/ 374 | <% end -%> 375 | --------------------------------------------------------------------------------