Skip to content
Snippets Groups Projects
Commit 38e96168 authored by Marin Jankovski's avatar Marin Jankovski Committed by Jose Ivan Vargas Lopez
Browse files

Merge branch '2628-allow-setting-of-arbitrary-settings-per-pgbouncer-database-entry' into 'master'

Resolve "Allow setting of arbitrary settings per pgbouncer database entry"

Closes #2628

See merge request !1858
parent 279a0d09
No related branches found
No related tags found
No related merge requests found
class PgbouncerHelper
attr_reader :node
def initialize(node)
@node = node
end
def database_config(database)
settings = node['gitlab']['pgbouncer']['databases'][database].to_hash
# The recipe uses user and passowrd for the auth_user option and the pg_auth file
settings['auth_user'] = settings.delete('user') if settings.key?('user')
settings.delete('password') if settings.key?('password')
settings.map do |setting, value|
"#{setting}=#{value}"
end.join(' ').chomp
end
end
Loading
Loading
@@ -52,6 +52,7 @@ end
template node['gitlab']['pgbouncer']['databases_ini'] do
source "#{File.basename(name)}.erb"
user node['gitlab']['pgbouncer']['databases_ini_user']
helper(:pgb_helper) { pgb_helper }
variables lazy { node['gitlab']['pgbouncer'].to_hash }
notifies :run, 'execute[reload pgbouncer]', :immediately
end
Loading
Loading
[databases]
<% @databases.each do |db, settings| %>
<%= db %> = host=<%= settings['host'] %> port=<%= settings['port'] %> dbname=<%= db %> auth_user=<%= settings['user'] %>
<%= db %> = <%= pgb_helper.database_config(db) %>
<% end %>
Loading
Loading
@@ -98,7 +98,7 @@ def get_pg_options
options['pg_database'] = db
end
 
opts.on('--newhost HOSTNAME', 'The new master when updating pgbouncer') do|h|
opts.on('--newhost HOSTNAME', 'The new master when updating pgbouncer') do |h|
options['newhost'] = h
end
end.parse!(ARGV)
Loading
Loading
Loading
Loading
@@ -153,8 +153,8 @@ describe 'gitlab-ee::pgbouncer' do
}
)
expect(chef_run).to render_file(databases_ini).with_content { |content|
expect(content).to match(%r{^first = host=1\.2\.3\.4 port=6432 dbname=first auth_user=first_user$})
expect(content).to match(%r{^second = host=5\.6\.7\.8 port=7432 dbname=second auth_user=second_user$})
expect(content).to match(%r{^first = host=1\.2\.3\.4 port=6432 auth_user=first_user$})
expect(content).to match(%r{^second = host=5\.6\.7\.8 port=7432 auth_user=second_user$})
}
end
 
Loading
Loading
@@ -179,7 +179,7 @@ describe 'gitlab-ee::pgbouncer' do
}
)
expect(chef_run).to render_file(databases_ini)
.with_content(/^gitlabhq_production = host=127\.0\.0\.1 port=5432 dbname=gitlabhq_production auth_user=fakeuser$/)
.with_content(/^gitlabhq_production = host=127\.0\.0\.1 port=5432 auth_user=fakeuser$/)
expect(chef_run).to render_file('/var/opt/gitlab/pgbouncer/pg_auth')
.with_content(%r{^"fakeuser" "md5fakemd5password"$})
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment