Skip to content

Commit

Permalink
Dvm changes to get external postgres working.
Browse files Browse the repository at this point in the history
Signed-off-by: Prajakta Purohit <[email protected]>
  • Loading branch information
PrajaktaPurohit committed Jul 18, 2019
1 parent 6264d09 commit da6f5da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions dev/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def define_chef_server(config, attributes)
if vmattr["postgresql"]["start"] and vmattr["postgresql"]["use-external"]
# TODO make this stuff common - we have these values in 2-3 places now...
pg = { "postgresql['external']" => true,
"postgresql['vip']" => "\"#{IPS[:database]}\"",
"postgresql['vip']" => "\"#{IPS[:db]}\"",
"postgresql['port']" => 5432,
"postgresql['db_superuser']" => "\"#{DB_SUPERUSER}\"",
"postgresql['db_superuser_password']" => "\"#{DB_SUPERPASS}\"",
Expand Down Expand Up @@ -276,13 +276,13 @@ def define_ldap_server(config, attributes)
end

def define_db_server(config, attributes)
config.vm.hostname = "database.#{VMName}.dev"
config.vm.network "private_network", ip: IPS[:database]
config.vm.hostname = "db.#{VMName}.dev"
config.vm.network "private_network", ip: IPS[:db]
customize_vm(config, name: "database#{Variant}", memory: 512, cpus: 1)
set_chef_zero_provisioning(config,
recipes: ["provisioning::hosts"],
json: { 'provisioning' => { 'hosts' => ips_to_fqdns } })
config.vm.provision "shell", path: "scripts/configure-postgres.sh"
config.vm.provision "shell", path: "scripts/provision-postgres.sh", args: "#{IPS[:cs]}"
end

def define_custom_server(config, attributes)
Expand Down
10 changes: 5 additions & 5 deletions dev/scripts/provision-postgres.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list
echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" > /etc/apt/sources.list.d/pgdg.list
wget --quiet https://www.postgresql.org/media/keys/ACCC4CF8.asc
apt-key add ACCC4CF8.asc
apt-get update
apt-get install postgresql-9.2 -y
echo "host all all #{IPS[:cs]}/32 md5" >> /etc/postgresql/9.2/main/pg_hba.conf
echo "listen_addresses='*'" >> /etc/postgresql/9.2/main/postgresql.conf
apt-get install postgresql-9.6 -y
echo "host all all $1/32 md5" >> /etc/postgresql/9.6/main/pg_hba.conf
echo "listen_addresses='*'" >> /etc/postgresql/9.6/main/postgresql.conf
service postgresql restart
export PATH=/usr/lib/postgresql/9.2/bin:$PATH
export PATH=/usr/lib/postgresql/9.6/bin:$PATH
sudo -u postgres psql -c "CREATE USER bofh SUPERUSER ENCRYPTED PASSWORD 'i1uvd3v0ps';"
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.with_connection(node, database = 'template1', opts = {})
end
max_retries = retries
begin
connection = ::PGconn.open('user' => postgres['db_superuser'],
connection = PG::Connection.open('user' => postgres['db_superuser'],
'host' => postgres['vip'],
'password' => postgres['db_superuser_password'],
'port' => postgres['port'],
Expand Down

0 comments on commit da6f5da

Please sign in to comment.