Skip to content

Commit 1eff60a

Browse files
committed
add db_extra_options parameter
1 parent dbfdc94 commit 1eff60a

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

manifests/config.pp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@
6060
}
6161

6262
$db_context = {
63-
'managed' => $foreman::db_manage,
64-
'rails_env' => $foreman::rails_env,
65-
'host' => $foreman::db_host,
66-
'port' => $foreman::db_port,
67-
'sslmode' => $foreman::db_sslmode_real,
68-
'database' => $foreman::db_database,
69-
'username' => $foreman::db_username,
70-
'password' => $foreman::db_password,
63+
'managed' => $foreman::db_manage,
64+
'rails_env' => $foreman::rails_env,
65+
'host' => $foreman::db_host,
66+
'port' => $foreman::db_port,
67+
'sslmode' => $foreman::db_sslmode_real,
68+
'database' => $foreman::db_database,
69+
'username' => $foreman::db_username,
70+
'password' => $foreman::db_password,
7171
# Set the pool size to at least the amount of puma threads + 4 threads that are spawned automatically by the process.
7272
# db_pool is optional, and undef means "use default" and the second part of the max statement will be set.
7373
# The number 4 is for 4 threads that are spawned internally during the execution:
@@ -76,7 +76,8 @@
7676
# 3. Stomp listener (required by Katello)
7777
# 4. Puma server listener thread
7878
# This means for systems without Katello we can reduce the amount of the pool to puma_threads_max + 1
79-
'db_pool' => pick($foreman::db_pool, $foreman::foreman_service_puma_threads_max + 4),
79+
'db_pool' => pick($foreman::db_pool, $foreman::foreman_service_puma_threads_max + 4),
80+
'extra_options' => $foreman::db_extra_options,
8081
}
8182

8283
file { '/etc/foreman/database.yml':

manifests/init.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
# $db_pool:: Database 'production' size of connection pool. If the value is not set, it will be
8888
# set by default to the amount of puma threads + 4 (for internal system threads)
8989
#
90+
# $db_extra_options:: Database 'production' extra options. Can be used for extra options, not made
91+
# available by the above db_* parameters.
92+
#
9093
# $db_manage_rake:: if enabled, will run rake jobs, which depend on the database
9194
#
9295
# $server_port:: Defines Apache port for HTTP requests
@@ -230,6 +233,7 @@
230233
Optional[String[1]] $db_sslmode = undef,
231234
Optional[String[1]] $db_root_cert = undef,
232235
Optional[Integer[0]] $db_pool = undef,
236+
Hash[String, Variant[String, Integer]] $db_extra_options = {},
233237
Boolean $db_manage_rake = true,
234238
Stdlib::Port $server_port = 80,
235239
Stdlib::Port $server_ssl_port = 443,

spec/classes/foreman_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
db_password: 'secret',
201201
db_sslmode: 'prefer',
202202
db_pool: 9,
203+
db_extra_options: { 'target_session_attrs': 'read-write' },
203204
db_manage_rake: true,
204205
server_port: 80,
205206
server_ssl_port: 443,

templates/database.yml.epp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Optional[String[1]] $username,
99
Variant[Undef, String[1], Sensitive[String[1]]] $password,
1010
Integer[0] $db_pool,
11+
Hash[String, Variant[String, Integer]] $extra_options,
1112
| -%>
1213
---
1314
<%= template('foreman/_header.erb') %>
@@ -33,3 +34,6 @@
3334
password: <%= stdlib::to_ruby($password) %>
3435
<% } -%>
3536
pool: <%= $db_pool %>
37+
<% $extra_options.each |$k, $v| { -%>
38+
<%= $k %>: <%= stdlib::to_ruby($v) %>
39+
<% } -%>

0 commit comments

Comments
 (0)