Skip to content

Commit

Permalink
use mysql ~> 6.0 cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
avsh committed Mar 25, 2015
1 parent 0756e6f commit bd4eba9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
4 changes: 3 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
default['owncloud']['admin']['pass'] = nil

default['owncloud']['config']['dbtype'] = 'mysql'
default['owncloud']['config']['dbversion'] = nil
default['owncloud']['config']['dbname'] = 'owncloud'
default['owncloud']['config']['dbuser'] = 'owncloud'
default['owncloud']['config']['dbpassword'] = nil
default['owncloud']['config']['dbhost'] = 'localhost'
default['owncloud']['config']['dbrootpassword'] = 'my_root_password'
default['owncloud']['config']['dbhost'] = '127.0.0.1'
default['owncloud']['config']['dbtableprefix'] = ''

default['owncloud']['config']['mail_smtpmode'] = 'sendmail'
Expand Down
7 changes: 4 additions & 3 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@

depends 'apache2', '~> 3.0'
depends 'apt', '~> 2.0'
depends 'database', '= 2.3.1'
depends 'mysql', '~> 5.0'
depends 'database', '~> 4.0'
depends 'mysql', '~> 6.0'
depends "mysql2_chef_gem", "~> 1.0.1"
depends 'nginx', '~> 2.7'
depends 'openssl', '~> 2.0'
depends 'php', '~> 1.4'
Expand Down Expand Up @@ -428,4 +429,4 @@
:description => 'Whether to skip settings the permissions of the ownCloud directory. Set this to true when using NFS synced folders.',
:choice => [ 'true', 'false' ],
:type => 'string',
:required => 'optional'
:required => 'optional'
26 changes: 22 additions & 4 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,22 @@
when 'mysql'
if %w{ localhost 127.0.0.1 }.include?(node['owncloud']['config']['dbhost'])
# Install MySQL
include_recipe 'mysql::server'
include_recipe 'database::mysql'
mysql2_chef_gem 'default' do
action :install
end
mysql_service 'default' do
version node['owncloud']['config']['dbversion']
bind_address '127.0.0.1'
port '3306'
initial_root_password node['owncloud']['config']['dbrootpassword']
action [:create, :start]
end


mysql_connection_info = {
:host => 'localhost',
:host => '127.0.0.1',
:username => 'root',
:password => node['mysql']['server_root_password']
:password => node['owncloud']['config']['dbrootpassword']
}

mysql_database node['owncloud']['config']['dbname'] do
Expand All @@ -143,6 +152,15 @@
when 'pgsql'
if %w{ localhost 127.0.0.1 }.include?(node['owncloud']['config']['dbhost'])
# Install PostgreSQL
if ::Chef::Config[:solo]
attr = node['postgresql'] && node['postgresql']['password'] && node['postgresql']['password']['postgres']
unless attr
node['postgresql']['password']['postgress'] = node['owncloud']['config']['dbrootpassword']
end
else
node.set_unless['postgresql']['password']['postgres'] = node['owncloud']['config']['dbrootpassword']
end

include_recipe 'postgresql::server'
include_recipe 'database::postgresql'

Expand Down
2 changes: 1 addition & 1 deletion test/integration/mysql/bats/default.bats
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bats

@test "database should be created" {
echo "show databases" | mysql -uroot -pvagrant_root | grep -q "^owncloud$"
echo "show databases" | mysql -uroot -h 127.0.0.1 -pvagrant_root | grep -q "^owncloud$"
}

@test "owncloud should be installed" {
Expand Down
5 changes: 1 addition & 4 deletions test/kitchen/cookbooks/owncloud_test/recipes/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
# limitations under the License.
#

node.default['mysql']['server_root_password'] = 'vagrant_root'
node.default['mysql']['server_debian_password'] = 'vagrant_debian'
node.default['mysql']['server_repl_password'] = 'vagrant_repl'

node.default['owncloud']['config']['dbrootpassword'] = 'vagrant_root'
node.default['owncloud']['config']['dbpassword'] = 'database_pass'

include_recipe 'owncloud_test::common'
4 changes: 1 addition & 3 deletions test/kitchen/cookbooks/owncloud_test/recipes/nginx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@

node.default['owncloud']['web_server'] = 'nginx'

node.default['mysql']['server_root_password'] = 'vagrant_root'
node.default['mysql']['server_debian_password'] = 'vagrant_debian'
node.default['mysql']['server_repl_password'] = 'vagrant_repl'
node.default['owncloud']['config']['dbrootpassword'] = 'vagrant_root'

node.default['owncloud']['config']['dbpassword'] = 'database_pass'

Expand Down

0 comments on commit bd4eba9

Please sign in to comment.