Skip to content

Commit

Permalink
use database cookbook where it was possible, changed user to create t…
Browse files Browse the repository at this point in the history
…he tables to bareos, because if I use the bareos-dir check there was a problem with the table permissions on postgresql. There fore the sh shell was needed for the bareos user.
  • Loading branch information
Gerhard Sulzberger committed Jul 12, 2015
1 parent 6fcee62 commit 8951628
Showing 1 changed file with 51 additions and 10 deletions.
61 changes: 51 additions & 10 deletions recipes/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# limitations under the License.
#


package 'bareos-database-tools' do
action :install
end
Expand Down Expand Up @@ -54,21 +55,61 @@
end

if database == 'postgresql'
execute 'create_database' do
command 'su postgres -c "/usr/lib/bareos/scripts/create_bareos_database" && touch /usr/lib/bareos/.dbcreated'
creates '/usr/lib/bareos/.dbcreated'
action :run

user 'bareos' do
shell '/bin/sh'
action :modify
end

include_recipe "database::postgresql"

postgresql_connection_info = {
:host => "127.0.0.1",
:port => node['postgresql']['config']['port'],
:username => 'postgres',
:password => node['postgresql']['password']['postgres']
}


postgresql_database_user 'bareos' do
connection postgresql_connection_info
password node['bareos']['dbpassword']
action :create
end

postgresql_database 'bareos' do
connection postgresql_connection_info
template 'template0'
encoding 'SQL_ASCII'
collation 'C'
tablespace 'DEFAULT'
connection_limit '-1'
owner 'bareos'
action :create
end

postgresql_database_user 'bareos' do
connection postgresql_connection_info
database_name 'bareos'
privileges [:all]
action :grant
end

# execute 'create_database' do
# command 'su postgres -c "/usr/lib/bareos/scripts/create_bareos_database" && touch /usr/lib/bareos/.dbcreated'
# creates '/usr/lib/bareos/.dbcreated'
# action :run
# end

execute 'create_tables' do
command 'su postgres -c "/usr/lib/bareos/scripts/make_bareos_tables" && touch /usr/lib/bareos/.dbtablescreated'
command 'su bareos -c "/usr/lib/bareos/scripts/make_bareos_tables" && touch /usr/lib/bareos/.dbtablescreated'
creates '/usr/lib/bareos/.dbtablescreated'
action :run
end

execute 'grant_privileges' do
command 'su postgres -c "/usr/lib/bareos/scripts/grant_bareos_privileges" && touch /usr/lib/bareos/.dbprivgranted'
creates '/usr/lib/bareos/.dbprivgranted'
action :run
end
# execute 'grant_privileges' do
# command 'su postgres -c "/usr/lib/bareos/scripts/grant_bareos_privileges" && touch /usr/lib/bareos/.dbprivgranted'
# creates '/usr/lib/bareos/.dbprivgranted'
# action :run
# end
end

0 comments on commit 8951628

Please sign in to comment.