Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Allow Pushy Server to optionally use a different username for establishing database connections #190

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
default['pushy']['postgresql']['database_name'] = "opscode_pushy"
default['pushy']['postgresql']['username'] = "opscode-pgsql"
default['pushy']['postgresql']['sql_user'] = "opscode_pushy"
default['pushy']['postgresql']['sql_connection_user'] = nil
default['pushy']['postgresql']['sql_ro_user'] = "opscode_pushy_ro"
default['pushy']['postgresql']['vip'] = "127.0.0.1"
default['pushy']['postgresql']['port'] = 5432
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def self.with_connection(node, database = 'template1', opts = {})
require 'pg'
password = opts['db_superuser_password'] || PushServer::Secrets.veil.get('postgresql', 'db_superuser_password')
postgres = node['pushy']['postgresql'].merge(opts)
connection = ::PGconn.open('user' => postgres['db_superuser'],
connection = ::PGconn.open('user' => postgres['db_connection_superuser'] || postgres['db_superuser'],
'host' => postgres['vip'],
'password' => password,
'port' => postgres['port'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ def generate_hash

def generate_config(node_name)
# inherit postgres config from chef-server
PushJobsServer['postgresql']['vip'] = node['private_chef']['postgresql']['vip']
PushJobsServer['postgresql']['port'] = node['private_chef']['postgresql']['port']
PushJobsServer['postgresql']['db_superuser'] = node['private_chef']['postgresql']['db_superuser']
PushJobsServer['postgresql']['vip'] = node['private_chef']['postgresql']['vip']
PushJobsServer['postgresql']['port'] = node['private_chef']['postgresql']['port']
PushJobsServer['postgresql']['db_superuser'] = node['private_chef']['postgresql']['db_superuser']
PushJobsServer['postgresql']['db_connection_superuser'] = node['private_chef']['postgresql']['db_connection_superuser']

topology = node['private_chef']['topology']
case topology
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
license "Apache 2.0"
description "Installs/Configures opscode-pushy-server"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.1.0"
version "0.2.0"

depends 'enterprise' # grabbed via Berkshelf + Git
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NOTE:
#
# Uses the value of node['private_chef']['postgresql']['db_superuser'] for the superuser name and
# Uses the value of node['private_chef']['postgresql']['db_connection_superuser'] for the superuser name and
# access the superuser password via the Secrets module.
# to make the connection to the postgres server.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
opscode_pushy_server_pg_sqitch "#{install_path}/embedded/service/pushy-server-schema" do
hostname push_attrs['vip']
port push_attrs['port']
username push_attrs['db_superuser']
username push_attrs['db_connection_superuser'] || push_attrs['db_superuser']
password PushServer::Secrets.veil.get('postgresql', 'db_superuser_password')
database database_name
end
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
%% Database connection parameters
{db_host, "<%= node['pushy']['postgresql']['vip'] %>"},
{db_port, <%= node['pushy']['postgresql']['port'] %>},
{db_user, "<%= node['pushy']['postgresql']['sql_user'] %>"},
{db_user, "<%= node['pushy']['postgresql']['sql_connection_user'] || node['pushy']['postgresql']['sql_user'] %>"},
{db_name, "opscode_pushy" },
{idle_check, 10000},
{prepared_statements, {pushy_sql, statements, []} },
Expand Down