-
Notifications
You must be signed in to change notification settings - Fork 82
Update mysql cookbook #170
base: master
Are you sure you want to change the base?
Changes from 3 commits
e36a112
fdc469b
f000df9
94ae008
162df92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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" }) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
depends "nginx" | ||
depends "bluepill" | ||
depends "logrotate" | ||
depends "mysql", "~> 6.0" |
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'] | ||
|
||
database_name = database_info['database'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'] | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing whitespace detected. |
||
username: "root", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.