Skip to content

Commit

Permalink
using mariadb for mysql server/client for rhel7
Browse files Browse the repository at this point in the history
  • Loading branch information
jarv-aws committed Jun 4, 2015
1 parent 53caf83 commit 51b3e5f
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Using mariadb as a binary compatible replacement for mysql for rhel 7 servers
- Updated the monit systemd config to prevent systemd from sending the kill signal to processes monitored by monit.
# v340 2015-05-05
- Reverts a breaking commit that resulted in an invalid deploy destination
Expand Down
15 changes: 13 additions & 2 deletions mysql/attributes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

default[:mysql][:server_root_password] = root_pw

if platform?("redhat") && Chef::VersionConstraint.new("~> 7.0").include?(node["platform_version"])
default[:mysql][:provider] = 'mariadb'
else
default[:mysql][:provider] = 'mysql'
end


debian_pw = String.new
while debian_pw.length < 20
debian_pw << OpenSSL::Random.random_bytes(1).gsub(/\W/, '')
Expand All @@ -37,7 +44,7 @@
case node[:platform]
when 'centos','redhat','fedora','amazon'
default[:mysql][:datadir] = '/var/lib/mysql'
default[:mysql][:logdir] = '/var/log/mysql'
default[:mysql][:logdir] = "/var/log/#{node[:mysql][:provider]}"
default[:mysql][:basedir] = '/usr'
default[:mysql][:user] = 'mysql'
default[:mysql][:group] = 'mysql'
Expand All @@ -48,7 +55,11 @@
set[:mysql][:conf_dir] = '/etc'
set[:mysql][:confd_dir] = '/etc/mysql/conf.d'
set[:mysql][:socket] = '/var/lib/mysql/mysql.sock'
set[:mysql][:pid_file] = '/var/run/mysqld/mysqld.pid'
if node[:mysql][:provider] == "mariadb"
set[:mysql][:pid_file] = "/var/run/mariadb/mysqld.pid"
else
set[:mysql][:pid_file] = "/var/run/mysqld/mysqld.pid"
end
set[:mysql][:grants_path] = '/etc/mysql_grants.sql'
when 'debian','ubuntu'
default[:mysql][:datadir] = '/var/lib/mysql'
Expand Down
25 changes: 13 additions & 12 deletions mysql/recipes/client_install.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package 'mysql-devel' do
package_name value_for_platform(
['centos','redhat','fedora','amazon'] => {'default' => 'mysql-devel'},
'ubuntu' => {'default' => 'libmysqlclient-dev'}
)
action :install
# for backwards compatiblity default provider to mysql
default[:mysql][:provider] = "mysql" unless default[:mysql].key?(:provider)

case node[:platform]
when "redhat", "centos", "fedora", "amazon"
package "#{node[:mysql][:provider]}-devel"
else "ubuntu"
package "libmysqlclient-dev"
end

package 'mysql-client' do
package_name value_for_platform(
['centos','redhat','fedora','amazon'] => {'default' => 'mysql'},
'default' => 'mysql-client'
)
action :install
case node[:platform]
when "redhat", "centos", "fedora", "amazon"
package node[:mysql][:provider]
else "ubuntu"
package "mysql-client"
end
9 changes: 6 additions & 3 deletions mysql/recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
include_recipe 'mysql::client'
include_recipe 'mysql::prepare'

package 'mysql-server'
# for backwards compatiblity default provider to mysql
default[:mysql][:provider] = "mysql" unless default[:mysql].key?(:provider)

package "#{node[:mysql][:provider]}-server"

if platform?('ubuntu') && node[:platform_version].to_f < 10.04
remote_file '/tmp/mysql_init.patch' do
Expand All @@ -26,11 +29,11 @@

include_recipe 'mysql::service'

service 'mysql' do
service node[:mysql][:provider] do
action :enable
end

service 'mysql' do
service node[:mysql][:provider] do
action :stop
end

Expand Down
20 changes: 15 additions & 5 deletions mysql/recipes/service.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
service 'mysql' do
service_name value_for_platform(
['centos','redhat','fedora','amazon'] => {'default' => 'mysqld'},
'default' => 'mysql'
)
# for backwards compatiblity default provider to mysql
default[:mysql][:provider] = "mysql" unless default[:mysql].key?(:provider)

service "mysql" do
case node[:platform]
when "redhat", "centos", "fedora", "amazon"
if node[:mysql][:provider] == "mariadb"
service_name "mariadb"
else
service_name "mysqld"
end
else
service_name "mysql"
end

if platform?('ubuntu') && node[:platform_version].to_f >= 10.04
provider Chef::Provider::Service::Upstart
end
Expand Down
9 changes: 8 additions & 1 deletion opsworks_initial_setup/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,18 @@
default[:opsworks_initial_setup][:ephemeral_mount_point] = "/mnt"
end

if platform?("redhat") && Chef::VersionConstraint.new("~> 7.0").include?(node["platform_version"])
default[:opsworks_initial_setup][:mysql] = 'mariadb'
else
default[:opsworks_initial_setup][:mysql] = 'mysql'
end

default[:opsworks_initial_setup][:bind_mounts][:mounts] = {
'/var/log/mysql' => "#{node[:opsworks_initial_setup][:ephemeral_mount_point]}/var/log/mysql",
"/var/log/#{node[:opsworks_initial_setup][:mysql]}" => "#{node[:opsworks_initial_setup][:ephemeral_mount_point]}/var/log/#{node[:opsworks_initial_setup][:mysql]}",
'/srv/www' => "#{node[:opsworks_initial_setup][:ephemeral_mount_point]}/srv/www",
'/var/www' => "#{node[:opsworks_initial_setup][:ephemeral_mount_point]}/var/www",
}

case node[:platform]
when 'redhat','centos','fedora','amazon'
default[:opsworks_initial_setup][:bind_mounts][:mounts]['/var/log/httpd'] = "#{node[:opsworks_initial_setup][:ephemeral_mount_point]}/var/log/apache2"
Expand Down

0 comments on commit 51b3e5f

Please sign in to comment.