Sha256: 7ed3a6ef91123bae948aa21da087da59b67a9c81e6d7bdc24947c97fef77bbf3

Contents?: true

Size: 1.76 KB

Versions: 19

Compression:

Stored size: 1.76 KB

Contents

package 'db' do
  depends_on 'env-initialized'
  depends_on 'postgresql'
  depends_on 'postgresql-conf'
  depends_on 'postgresql-app-stage-conf'
end

package 'postgresql-conf' do
  file({
           :template => Pvcglue.template_file_name('postgresql.conf.erb'),
           :destination => '/etc/postgresql/9.1/main/postgresql.conf',
           :create_dirs => false,
           :permissions => 0644,
           :user => 'postgres',
           :group => 'postgres'
       }) { trigger 'postgresql:restart' }

  file({
           :template => Pvcglue.template_file_name('pg_hba.conf.erb'),
           :destination => '/etc/postgresql/9.1/main/pg_hba.conf',
           :create_dirs => false,
           :permissions => 0644,
           :user => 'postgres',
           :group => 'postgres'
       }) { trigger 'postgresql:restart' }
end

package 'postgresql-app-stage-conf' do
  # TODO: Add `verify` method so it will be faster, and won't display errors
  apply do
    username = Pvcglue.cloud.stage_env['DB_USER_POSTGRES_USERNAME']
    password = Pvcglue.cloud.stage_env['DB_USER_POSTGRES_PASSWORD']
    db_name = username # just for clarity in later statements.  This also must match database.yml.
    run(%Q[sudo -u postgres psql -c "CREATE ROLE #{username} LOGIN CREATEDB PASSWORD '#{password}'"])
    run(%Q[sudo -u postgres psql -c "ALTER ROLE #{username} PASSWORD '#{password}' CREATEDB LOGIN"])
    run(%Q[sudo -u postgres psql -c "CREATE DATABASE #{db_name} WITH OWNER #{username}"])
    run(%Q[sudo -u postgres psql #{db_name} -c "ALTER SCHEMA public OWNER TO #{username}"])
  end
end

package 'postgresql-root-password' do
  apply do
    # TODO: Use this to implement setting of the root password
    # sudo(%q[sudo -u postgres psql -c "ALTER ROLE postgres WITH PASSWORD 'zzz';"])
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pvcglue-0.1.24 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.23 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.22 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.21 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.20 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.19 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.18 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.17 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.15 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.14 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.13 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.12 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.11 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.10 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.9 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.8 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.7 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.6 lib/pvcglue/packages/role_db.rb
pvcglue-0.1.5 lib/pvcglue/packages/role_db.rb