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..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]" -default_attributes("mysql" => { "bind_address" => "127.0.0.1" }) \ No newline at end of file +run_list "role[base]" +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..55e92905 100644 --- a/vendor/cookbooks/rails/recipes/databases.rb +++ b/vendor/cookbooks/rails/recipes/databases.rb @@ -1,30 +1,40 @@ -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_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/ - include_recipe 'database::mysql' + mysql_service_name = "default" + host = node["mysql"]["bind_address"] + 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 + action [:create, :grant] end elsif database_info['adapter'] == 'postgresql' execute "create-database-user" do @@ -33,7 +43,7 @@ command psql returns [0,1] end - + execute "create-database" do user 'postgres' command "createdb -U postgres -O #{database_username} #{database_name}"