Skip to content

Commit

Permalink
caclulate db admin password if it is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
avsh committed Apr 2, 2015
1 parent bd4eba9 commit 22a2a4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@
default['owncloud']['admin']['pass'] = nil

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

Expand Down
11 changes: 8 additions & 3 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@
if node['owncloud']['config']['dbpassword'].nil? and node['owncloud']['config']['dbtype'] != 'sqlite'
Chef::Application.fatal!('You must set owncloud\'s database password in chef-solo mode.')
end
if node['owncloud']['config']['dbrootpassword'].nil? and node['owncloud']['config']['dbtype'] != 'sqlite'
Chef::Application.fatal!('You must set the database admin password in chef-solo mode.')
end
if node['owncloud']['admin']['pass'].nil?
Chef::Application.fatal!('You must set owncloud\'s admin password in chef-solo mode.')
end
else
unless node['owncloud']['config']['dbtype'] == 'sqlite'
node.set_unless['owncloud']['config']['dbpassword'] = secure_password
node.set_unless['owncloud']['config']['dbrootpassword'] = secure_password
end
node.set_unless['owncloud']['admin']['pass'] = secure_password
node.save
Expand Down Expand Up @@ -117,18 +121,19 @@
when 'mysql'
if %w{ localhost 127.0.0.1 }.include?(node['owncloud']['config']['dbhost'])
# Install MySQL
mysql2_chef_gem 'default' do
dbinstance = node['owncloud']['config']['dbinstance'] = 'default'

mysql2_chef_gem dbinstance do
action :install
end
mysql_service 'default' do
mysql_service dbinstance 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 => '127.0.0.1',
:username => 'root',
Expand Down

0 comments on commit 22a2a4f

Please sign in to comment.