Skip to content
Open
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
19 changes: 10 additions & 9 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
}

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

file { '/etc/foreman/database.yml':
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
# $db_pool:: Database 'production' size of connection pool. If the value is not set, it will be
# set by default to the amount of puma threads + 4 (for internal system threads)
#
# $db_extra_options:: Database 'production' extra options. Can be used for extra options, not made
# available by the above db_* parameters.
#
# $db_manage_rake:: if enabled, will run rake jobs, which depend on the database
#
# $server_port:: Defines Apache port for HTTP requests
Expand Down Expand Up @@ -230,6 +233,7 @@
Optional[String[1]] $db_sslmode = undef,
Optional[String[1]] $db_root_cert = undef,
Optional[Integer[0]] $db_pool = undef,
Hash[String, Variant[String, Integer]] $db_extra_options = {},
Boolean $db_manage_rake = true,
Stdlib::Port $server_port = 80,
Stdlib::Port $server_ssl_port = 443,
Expand Down
1 change: 1 addition & 0 deletions spec/classes/foreman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
db_password: 'secret',
db_sslmode: 'prefer',
db_pool: 9,
db_extra_options: { 'target_session_attrs': 'read-write' },
db_manage_rake: true,
server_port: 80,
server_ssl_port: 443,
Expand Down
4 changes: 4 additions & 0 deletions templates/database.yml.epp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Optional[String[1]] $username,
Variant[Undef, String[1], Sensitive[String[1]]] $password,
Integer[0] $db_pool,
Hash[String, Variant[String, Integer]] $extra_options,
| -%>
---
<%= template('foreman/_header.erb') %>
Expand All @@ -33,3 +34,6 @@
password: <%= stdlib::to_ruby($password) %>
<% } -%>
pool: <%= $db_pool %>
<% $extra_options.each |$k, $v| { -%>
<%= $k %>: <%= stdlib::to_ruby($v) %>
<% } -%>