Skip to content

Commit

Permalink
allow environment variables when configuring fpm pools. fixes voxpupu…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisboulton committed Jan 5, 2022
1 parent 82a1698 commit 3324147
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 44 deletions.
88 changes: 44 additions & 44 deletions manifests/fpm/pool.pp
Original file line number Diff line number Diff line change
Expand Up @@ -121,50 +121,50 @@
# '/etc/php5/fpm/pool.d' or '/etc/php-fpm.d'
#
define php::fpm::pool (
Enum['present', 'absent'] $ensure = 'present',
String[1] $listen = '127.0.0.1:9000',
Integer[-1] $listen_backlog = -1,
Optional[String[1]] $listen_allowed_clients = undef,
Optional[String[1]] $listen_owner = undef,
Optional[String[1]] $listen_group = undef,
Optional[Stdlib::Filemode] $listen_mode = undef,
String[1] $user = $php::fpm::config::user,
String[1] $group = $php::fpm::config::group,
Optional[String[1]] $apparmor_hat = undef,
String[1] $pm = 'dynamic',
Integer[1] $pm_max_children = 50,
Integer[0] $pm_start_servers = 5,
Integer[0] $pm_min_spare_servers = 5,
Integer[0] $pm_max_spare_servers = 35,
Integer[0] $pm_max_requests = 0,
Php::Duration $pm_process_idle_timeout = '10s',
Optional[Stdlib::Absolutepath] $pm_status_path = undef,
Optional[Stdlib::Absolutepath] $ping_path = undef,
String[1] $ping_response = 'pong',
Optional[Stdlib::Absolutepath] $access_log = undef,
String[1] $access_log_format = '"%R - %u %t \"%m %r\" %s"',
Php::Duration $request_terminate_timeout = 0,
Php::Duration $request_slowlog_timeout = 0,
Array[String[1]] $security_limit_extensions = [],
Stdlib::Absolutepath $slowlog = "/var/log/php-fpm/${name}-slow.log",
String[1] $template = 'php/fpm/pool.conf.erb',
Optional[Integer] $rlimit_files = undef,
Optional[Integer] $rlimit_core = undef,
Optional[Stdlib::Absolutepath] $chroot = undef,
Optional[Stdlib::Absolutepath] $chdir = undef,
Enum['yes', 'no'] $catch_workers_output = 'no',
Optional[String[1]] $include = undef,
Array[String[1]] $env = [],
Hash $env_value = {},
Boolean $clear_env = true,
Hash $options = {},
Hash $php_value = {},
Hash $php_flag = {},
Hash $php_admin_value = {},
Hash $php_admin_flag = {},
Array[String[1]] $php_directives = [],
String[1] $root_group = $php::params::root_group,
Optional[Stdlib::Absolutepath] $base_dir = undef,
Enum['present', 'absent'] $ensure = 'present',
String[1] $listen = '127.0.0.1:9000',
Integer[-1] $listen_backlog = -1,
Optional[String[1]] $listen_allowed_clients = undef,
Optional[String[1]] $listen_owner = undef,
Optional[String[1]] $listen_group = undef,
Optional[Stdlib::Filemode] $listen_mode = undef,
String[1] $user = $php::fpm::config::user,
String[1] $group = $php::fpm::config::group,
Optional[String[1]] $apparmor_hat = undef,
String[1] $pm = 'dynamic',
Variant[Integer[1], Php::EnvString] $pm_max_children = 50,
Variant[Integer[0], Php::EnvString] $pm_start_servers = 5,
Variant[Integer[0], Php::EnvString] $pm_min_spare_servers = 5,
Variant[Integer[0], Php::EnvString] $pm_max_spare_servers = 35,
Variant[Integer[0], Php::EnvString] $pm_max_requests = 0,
Variant[Php::Duration, Php::EnvString] $pm_process_idle_timeout = '10s',
Optional[Stdlib::Absolutepath] $pm_status_path = undef,
Optional[Stdlib::Absolutepath] $ping_path = undef,
String[1] $ping_response = 'pong',
Optional[Stdlib::Absolutepath] $access_log = undef,
String[1] $access_log_format = '"%R - %u %t \"%m %r\" %s"',
Variant[Php::Duration, Php::EnvString] $request_terminate_timeout = 0,
Variant[Php::Duration, Php::EnvString] $request_slowlog_timeout = 0,
Array[String[1]] $security_limit_extensions = [],
Stdlib::Absolutepath $slowlog = "/var/log/php-fpm/${name}-slow.log",
String[1] $template = 'php/fpm/pool.conf.erb',
Optional[Integer] $rlimit_files = undef,
Optional[Integer] $rlimit_core = undef,
Optional[Stdlib::Absolutepath] $chroot = undef,
Optional[Stdlib::Absolutepath] $chdir = undef,
Enum['yes', 'no'] $catch_workers_output = 'no',
Optional[String[1]] $include = undef,
Array[String[1]] $env = [],
Hash $env_value = {},
Boolean $clear_env = true,
Hash $options = {},
Hash $php_value = {},
Hash $php_flag = {},
Hash $php_admin_value = {},
Hash $php_admin_flag = {},
Array[String[1]] $php_directives = [],
String[1] $root_group = $php::params::root_group,
Optional[Stdlib::Absolutepath] $base_dir = undef,
) {
# The base class must be included first because it is used by parameter defaults
if ! defined(Class['php']) {
Expand Down
18 changes: 18 additions & 0 deletions spec/defines/fpm_pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
end
let(:pre_condition) { 'include php' }

context 'with environment based config' do
let(:title) { 'env-config' }
let(:params) { {
pm_max_children: '${PM_MAX_CHILDREN}',
pm_start_servers: '${PM_START_SERVERS}',
pm_min_spare_servers: '${PM_MIN_SPARE_SERVERS}',
pm_max_spare_servers: '${PM_MAX_SPARE_SERVERS}',
pm_max_requests: '${PM_MAX_REQUESTS}',
pm_process_idle_timeout: '${PM_PROCESS_IDLE_TIMEOUT}',
request_terminate_timeout: '${REQUEST_TERMINATE_TIMEOUT}',
request_slowlog_timeout: '${REQUEST_SLOWLOG_TIMEOUT}',
} }

it {
is_expected.to compile
}
end

case facts[:os]['name']
when 'Debian'
context 'plain config' do
Expand Down
1 change: 1 addition & 0 deletions types/envstring.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Php::EnvString = Pattern[/\$\{[\w]+\}/]

0 comments on commit 3324147

Please sign in to comment.