Skip to content
This repository has been archived by the owner on Apr 23, 2019. It is now read-only.

Update mysql cookbook #170

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cheffile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ site "https://supermarket.getchef.com/api/v1"

# Community cookbooks
cookbook "apt", "~> 2.6.1"
cookbook "mysql", "~> 5.3.6"
cookbook "mysql", "~> 6.0.0"
cookbook "postgresql", "~> 3.4.1"
cookbook "database", "~> 3.0.3"
cookbook "nginx", "~> 2.7.4"
cookbook "postfix", "~> 3.6.2"
cookbook "sudo", "~> 2.7.0"
Expand Down
37 changes: 21 additions & 16 deletions Cheffile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ SITE
remote: https://supermarket.getchef.com/api/v1
specs:
apt (2.6.1)
aws (2.5.0)
bluepill (2.3.1)
rsyslog (>= 0.0.0)
build-essential (2.1.3)
chef-sugar (2.4.1)
chef-sugar (2.5.0)
chef_handler (1.1.6)
database (2.3.1)
aws (>= 0.0.0)
mysql (~> 5.0)
mysql-chef_gem (~> 0.0)
database (3.0.3)
mysql2_chef_gem (~> 1.0)
postgresql (>= 1.0.0)
xfs (>= 0.0.0)
dmg (2.2.2)
git (4.1.0)
build-essential (>= 0.0.0)
Expand All @@ -22,11 +18,17 @@ SITE
windows (>= 0.0.0)
yum (~> 3.0)
yum-epel (>= 0.0.0)
logrotate (1.7.0)
mysql (5.3.6)
logrotate (1.8.0)
mariadb (0.2.11)
apt (>= 0.0.0)
yum (>= 0.0.0)
yum-epel (>= 0.0.0)
mysql (6.0.10)
smf (>= 0.0.0)
yum-mysql-community (>= 0.0.0)
mysql-chef_gem (0.0.5)
mysql2_chef_gem (1.0.1)
build-essential (>= 0.0.0)
mariadb (>= 0.0.0)
mysql (>= 0.0.0)
nginx (2.7.4)
apt (~> 2.2)
Expand All @@ -36,32 +38,34 @@ SITE
runit (~> 1.2)
yum-epel (~> 0.3)
ohai (2.0.1)
openssl (2.0.0)
openssl (2.0.2)
chef-sugar (>= 0.0.0)
postfix (3.6.2)
postgresql (3.4.14)
apt (>= 1.9.0)
build-essential (>= 0.0.0)
openssl (>= 0.0.0)
rbac (1.0.2)
rbenv (1.7.1)
apt (>= 0.0.0)
build-essential (>= 0.0.0)
git (>= 0.0.0)
ohai (>= 1.1)
rsyslog (1.13.0)
ruby_build (0.8.0)
runit (1.5.12)
runit (1.5.14)
build-essential (>= 0.0.0)
yum (~> 3.0)
yum-epel (>= 0.0.0)
smf (2.2.1)
rbac (>= 1.0.1)
sudo (2.7.1)
windows (1.36.1)
chef_handler (>= 0.0.0)
xfs (1.1.0)
yum (3.5.2)
yum-epel (0.5.3)
yum-epel (0.6.0)
yum (~> 3.0)
yum-mysql-community (0.1.11)
yum-mysql-community (0.1.12)
yum (>= 3.0)

PATH
Expand Down Expand Up @@ -97,7 +101,8 @@ PATH
DEPENDENCIES
apt (~> 2.6.1)
backups (>= 0)
mysql (~> 5.3.6)
database (~> 3.0.3)
mysql (~> 6.0.0)
nginx (~> 2.7.4)
packages (>= 0)
postfix (~> 3.6.2)
Expand Down
4 changes: 2 additions & 2 deletions roles/mysql.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name 'mysql'
description 'MySQL server for apps'
run_list "role[base]", "recipe[mysql::server]", "recipe[mysql::client]"
default_attributes("mysql" => { "bind_address" => "127.0.0.1" })
run_list "role[base]"
default_attributes("mysql" => { "bind_address" => "127.0.0.1" })
1 change: 1 addition & 0 deletions vendor/cookbooks/rails/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
depends "nginx"
depends "bluepill"
depends "logrotate"
depends "mysql", "~> 6.0"
34 changes: 23 additions & 11 deletions vendor/cookbooks/rails/recipes/databases.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
include_recipe "database"

if node[:active_applications]
node[:active_applications].each do |app, app_info|
if app_info['database_info']
database_info = app_info['database_info']
database_name = app_info['database_info']['database']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

database_name = database_info['database']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

database_username = database_info['username']
database_password = database_info['password']


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra blank line detected.

if database_info['adapter'] =~ /mysql/
include_recipe 'database::mysql'
mysql_service_name = "default"
host = node["mysql"]["bind_address"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

root_password = node["mysql"]["server_root_password"]

mysql_connection_info = {:host => "localhost", :username => "root", :password => node['mysql']['server_root_password']}
mysql_connection_info = {
host: host,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

username: "root",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

password: root_password,
socket: "/var/run/mysql-#{mysql_service_name}/mysqld.sock"
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

mysql_service mysql_service_name do
initial_root_password root_password
action [:create, :start]
end

mysql_database database_name do
connection(mysql_connection_info)
connection mysql_connection_info
action :create
end

mysql_database_user database_username do
connection(mysql_connection_info)
username database_username
connection mysql_connection_info
password database_password
database_name(database_name)
table "*"
database_name database_name
host "localhost"
action :grant
table "*"
action [:create, :grant]
end
elsif database_info['adapter'] == 'postgresql'
execute "create-database-user" do
Expand Down