From e36a1121ce6fa226e04294ffc6590843820b464f Mon Sep 17 00:00:00 2001 From: Oleksandr Iuzikov Date: Fri, 30 Jan 2015 17:35:21 +0200 Subject: [PATCH 1/5] Updated mysql cookbook to v 6.0 --- Cheffile | 3 +- Cheffile.lock | 37 ++++++++++++--------- roles/mysql.rb | 4 +-- vendor/cookbooks/rails/metadata.rb | 1 + vendor/cookbooks/rails/recipes/databases.rb | 34 +++++++++++++------ 5 files changed, 49 insertions(+), 30 deletions(-) diff --git a/Cheffile b/Cheffile index 56b4d5c7..b7e1cf52 100644 --- a/Cheffile +++ b/Cheffile @@ -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" diff --git a/Cheffile.lock b/Cheffile.lock index 58750d84..3cd81896 100644 --- a/Cheffile.lock +++ b/Cheffile.lock @@ -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) @@ -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) @@ -36,13 +38,14 @@ 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) @@ -50,18 +53,19 @@ SITE 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 @@ -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) diff --git a/roles/mysql.rb b/roles/mysql.rb index 64318fd1..8a4b13a0 100644 --- a/roles/mysql.rb +++ b/roles/mysql.rb @@ -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" }) \ No newline at end of file +run_list "role[base]" #, "recipe[mysql::server]", "recipe[mysql::client]" +default_attributes("mysql" => { "bind_address" => "127.0.0.1" }) diff --git a/vendor/cookbooks/rails/metadata.rb b/vendor/cookbooks/rails/metadata.rb index 62795380..9468a0e8 100644 --- a/vendor/cookbooks/rails/metadata.rb +++ b/vendor/cookbooks/rails/metadata.rb @@ -10,3 +10,4 @@ depends "nginx" depends "bluepill" depends "logrotate" +depends "mysql", "~> 6.0" diff --git a/vendor/cookbooks/rails/recipes/databases.rb b/vendor/cookbooks/rails/recipes/databases.rb index 2ffd6af2..4ddad318 100644 --- a/vendor/cookbooks/rails/recipes/databases.rb +++ b/vendor/cookbooks/rails/recipes/databases.rb @@ -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'] database_username = database_info['username'] database_password = database_info['password'] + if database_info['adapter'] =~ /mysql/ - include_recipe 'database::mysql' + mysql_service_name = "default" + host = "localhost" + 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, + username: "root", + password: root_password, + socket: "/var/run/mysql-#{mysql_service_name}/mysqld.sock" + } + + 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 From fdc469b867564f4d25a158681796f254f59ce78e Mon Sep 17 00:00:00 2001 From: Oleksandr Iuzikov Date: Fri, 30 Jan 2015 17:37:39 +0200 Subject: [PATCH 2/5] Removed commented code --- roles/mysql.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/mysql.rb b/roles/mysql.rb index 8a4b13a0..a6cdb771 100644 --- a/roles/mysql.rb +++ b/roles/mysql.rb @@ -1,4 +1,4 @@ name 'mysql' description 'MySQL server for apps' -run_list "role[base]" #, "recipe[mysql::server]", "recipe[mysql::client]" +run_list "role[base]" default_attributes("mysql" => { "bind_address" => "127.0.0.1" }) From f000df9a3676d0a4e988d1b7a6e5740289c005a8 Mon Sep 17 00:00:00 2001 From: Oleksandr Iuzikov Date: Fri, 30 Jan 2015 17:45:30 +0200 Subject: [PATCH 3/5] Use default config for host settings --- vendor/cookbooks/rails/recipes/databases.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/cookbooks/rails/recipes/databases.rb b/vendor/cookbooks/rails/recipes/databases.rb index 4ddad318..856851b4 100644 --- a/vendor/cookbooks/rails/recipes/databases.rb +++ b/vendor/cookbooks/rails/recipes/databases.rb @@ -10,7 +10,7 @@ if database_info['adapter'] =~ /mysql/ mysql_service_name = "default" - host = "localhost" + host = node["mysql"]["bind_address"] root_password = node["mysql"]["server_root_password"] mysql_connection_info = { From 94ae00829cbbccf8dba57da5826d2e5e86373b3c Mon Sep 17 00:00:00 2001 From: Oleksandr Iuzikov Date: Fri, 30 Jan 2015 17:51:00 +0200 Subject: [PATCH 4/5] HoundCI fixes --- vendor/cookbooks/rails/recipes/databases.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/vendor/cookbooks/rails/recipes/databases.rb b/vendor/cookbooks/rails/recipes/databases.rb index 856851b4..6b1e81d5 100644 --- a/vendor/cookbooks/rails/recipes/databases.rb +++ b/vendor/cookbooks/rails/recipes/databases.rb @@ -1,25 +1,24 @@ 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 = database_info['database'] - database_username = database_info['username'] - database_password = database_info['password'] + database_info = app_info["database_info"] + database_name = database_info["database"] + database_username = database_info["username"] + database_password = database_info["password"] if database_info['adapter'] =~ /mysql/ mysql_service_name = "default" - host = node["mysql"]["bind_address"] + host = node["mysql"]["bind_address"] root_password = node["mysql"]["server_root_password"] mysql_connection_info = { - host: host, - username: "root", + host: host, + username: "root", password: root_password, socket: "/var/run/mysql-#{mysql_service_name}/mysqld.sock" } - + mysql_service mysql_service_name do initial_root_password root_password action [:create, :start] @@ -45,7 +44,7 @@ command psql returns [0,1] end - + execute "create-database" do user 'postgres' command "createdb -U postgres -O #{database_username} #{database_name}" From 162df92c677c48cc36a2744bedf9e0a34ff5379f Mon Sep 17 00:00:00 2001 From: Oleksandr Iuzikov Date: Fri, 30 Jan 2015 21:06:22 +0200 Subject: [PATCH 5/5] Removed unneeded table option from databases recipe --- vendor/cookbooks/rails/recipes/databases.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/vendor/cookbooks/rails/recipes/databases.rb b/vendor/cookbooks/rails/recipes/databases.rb index 6b1e81d5..55e92905 100644 --- a/vendor/cookbooks/rails/recipes/databases.rb +++ b/vendor/cookbooks/rails/recipes/databases.rb @@ -34,7 +34,6 @@ password database_password database_name database_name host "localhost" - table "*" action [:create, :grant] end elsif database_info['adapter'] == 'postgresql'