Commit 93f3ea07cdf2223db806cd50e097da2c41560404

Authored by Antonio Terceiro
1 parent 85dfbd37

Create gitlab database

config/roles/database_server.rb
@@ -3,4 +3,5 @@ description 'Database server' @@ -3,4 +3,5 @@ description 'Database server'
3 run_list *[ 3 run_list *[
4 'recipe[postgresql]', 4 'recipe[postgresql]',
5 'recipe[postgresql::colab]', 5 'recipe[postgresql::colab]',
  6 + 'recipe[postgresql::gitlab]',
6 ] 7 ]
cookbooks/postgresql/recipes/gitlab.rb 0 → 100644
@@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
  1 +execute 'createuser:gitlab' do
  2 + command 'createuser gitlab'
  3 + user 'postgres'
  4 + only_if do
  5 + `sudo -u postgres -i psql --quiet --tuples-only -c "select count(*) from pg_user where usename = 'gitlab';"`.strip.to_i == 0
  6 + end
  7 +end
  8 +
  9 +execute 'createdb:gitlab' do
  10 + command 'createdb --owner=gitlab gitlab'
  11 + user 'postgres'
  12 + only_if do
  13 + `sudo -u postgres -i psql --quiet --tuples-only -c "select count(1) from pg_database where datname = 'gitlab';"`.strip.to_i == 0
  14 + end
  15 +end
  16 +
cookbooks/postgresql/templates/centos/pg_hba.conf.erb
@@ -8,3 +8,4 @@ host all all ::1/128 ident @@ -8,3 +8,4 @@ host all all ::1/128 ident
8 8
9 # TYPE DATABASE USER ADDRESS METHOD 9 # TYPE DATABASE USER ADDRESS METHOD
10 host colab colab <%= node['peers']['integration'] %>/32 trust 10 host colab colab <%= node['peers']['integration'] %>/32 trust
  11 +host gitlab gitlab <%= node['peers']['integration'] %>/32 trust
test/postgresql_test.sh
@@ -8,5 +8,9 @@ test_colab_database_created() { @@ -8,5 +8,9 @@ test_colab_database_created() {
8 assertTrue 'colab database created in PostgreSQL' 'run_on database sudo -u postgres -i psql colab < /dev/null' 8 assertTrue 'colab database created in PostgreSQL' 'run_on database sudo -u postgres -i psql colab < /dev/null'
9 } 9 }
10 10
  11 +test_gitlab_database_created() {
  12 + assertTrue 'gitlab database created in PostgreSQL' 'run_on database sudo -u postgres -i psql gitlab < /dev/null'
  13 +}
  14 +
11 . shunit2 15 . shunit2
12 16