Permalink
Browse files

Create the "db_maker" user as required by Crowbar

  • Loading branch information...
1 parent b964b9d commit df4b23d8bd7a8ffa0ad92fc1aae737b10e5644a2 @rhafer rhafer committed Mar 29, 2012
Showing with 19 additions and 0 deletions.
  1. +19 −0 chef/cookbooks/postgresql/recipes/server.rb
@@ -98,3 +98,22 @@
end
action :run
end
+
+# For Crowbar we also need the "db_maker" user
+bash "assign-db_maker-password" do
+ user 'postgres'
+ code <<-EOH
+echo "CREATE ROLE db_maker WITH LOGIN CREATEDB CREATEROLE ENCRYPTED PASSWORD '#{node[:postgresql][:db_maker_password]}';" | psql
+ EOH
+ not_if do
+ begin
+ require 'rubygems'
+ Gem.clear_paths
+ require 'pg'
+ conn = PGconn.connect("localhost", 5432, nil, nil, nil, "db_maker", node['postgresql']['db_maker_password'])
+ rescue PGError
+ false
+ end
+ end
+ action :run
+end

0 comments on commit df4b23d

Please sign in to comment.