Skip to content
Snippets Groups Projects
Commit c3af896b 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 acb2131a
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
@@ -15,6 +15,7 @@
#
 
account_helper = AccountHelper.new(node)
pgb_helper = PgbouncerHelper.new(node)
 
include_recipe 'gitlab::postgresql_user'
 
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
@@ -100,7 +100,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
 
Loading
Loading
Loading
Loading
@@ -173,6 +173,24 @@ describe 'gitlab-ee::pgbouncer' do
.with_content(%r{^"fakeuser" "md5fakemd5password"$})
end
 
it 'adds arbitrary values to the databases.ini file' do
stub_gitlab_rb(
{
pgbouncer: {
enable: true,
databases: {
gitlab_db: {
host: 'fakehost',
fakefield: 'fakedata'
}
}
}
}
)
expect(chef_run).to render_file(databases_ini)
.with_content(/^gitlab_db = host=fakehost fakefield=fakedata$/)
end
it 'creates arbitrary user' do
stub_gitlab_rb(
{
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