Skip to content

Commit

Permalink
use datatype array for 'listen.?' parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
kengelhardt-godaddy committed Apr 29, 2021
1 parent 911fb38 commit 2d86545
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 54 deletions.
110 changes: 60 additions & 50 deletions manifests/fpm/pool.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
# [*listen_mode*]
#
# [*listen_acl_users*]
# When POSIX Access Control Lists are supported you can set them using this option.
# When set, listen.owner and listen.group are ignored. Value is a comma separated
# list of user names.
# Array. When POSIX Access Control Lists are supported you can set them using
# this option. When set, listen.owner and listen.group are ignored. Value is
# an array of user names.
#
# [*listen_acl_groups*]
# See listen_acl_users. Value is a comma separated list of group names.
# See listen_acl_users. Value is an array of group names.
#
# [*user*]
# The user that php-fpm should run as
Expand Down Expand Up @@ -129,52 +129,52 @@
# '/etc/php5/fpm/pool.d' or '/etc/php-fpm.d'
#
define php::fpm::pool (
$ensure = 'present',
$listen = '127.0.0.1:9000',
$listen_backlog = '-1',
$listen_allowed_clients = undef,
$listen_owner = undef,
$listen_group = undef,
$listen_mode = undef,
Optional[String[1]] $listen_acl_users = undef,
Optional[String[1]] $listen_acl_groups = undef,
$user = $php::fpm::config::user,
$group = $php::fpm::config::group,
Optional[String[1]] $apparmor_hat = undef,
$pm = 'dynamic',
$pm_max_children = '50',
$pm_start_servers = '5',
$pm_min_spare_servers = '5',
$pm_max_spare_servers = '35',
$pm_max_requests = '0',
$pm_process_idle_timeout = '10s',
$pm_status_path = undef,
$ping_path = undef,
$ping_response = 'pong',
$access_log = undef,
$access_log_format = '"%R - %u %t \"%m %r\" %s"',
$request_terminate_timeout = '0',
$request_slowlog_timeout = '0',
$security_limit_extensions = undef,
$slowlog = "/var/log/php-fpm/${name}-slow.log",
$template = 'php/fpm/pool.conf.erb',
$rlimit_files = undef,
$rlimit_core = undef,
$chroot = undef,
$chdir = undef,
$catch_workers_output = 'no',
$include = undef,
$env = [],
$env_value = {},
$clear_env = true,
$options = {},
$php_value = {},
$php_flag = {},
$php_admin_value = {},
$php_admin_flag = {},
$php_directives = [],
$root_group = $php::params::root_group,
Optional[Stdlib::Absolutepath] $base_dir = undef,
$ensure = 'present',
$listen = '127.0.0.1:9000',
$listen_backlog = '-1',
$listen_allowed_clients = undef,
$listen_owner = undef,
$listen_group = undef,
$listen_mode = undef,
Array[String[1]] $listen_acl_users = undef,
Array[String[1]] $listen_acl_groups = undef,
$user = $php::fpm::config::user,
$group = $php::fpm::config::group,
Optional[String[1]] $apparmor_hat = undef,
$pm = 'dynamic',
$pm_max_children = '50',
$pm_start_servers = '5',
$pm_min_spare_servers = '5',
$pm_max_spare_servers = '35',
$pm_max_requests = '0',
$pm_process_idle_timeout = '10s',
$pm_status_path = undef,
$ping_path = undef,
$ping_response = 'pong',
$access_log = undef,
$access_log_format = '"%R - %u %t \"%m %r\" %s"',
$request_terminate_timeout = '0',
$request_slowlog_timeout = '0',
$security_limit_extensions = undef,
$slowlog = "/var/log/php-fpm/${name}-slow.log",
$template = 'php/fpm/pool.conf.erb',
$rlimit_files = undef,
$rlimit_core = undef,
$chroot = undef,
$chdir = undef,
$catch_workers_output = 'no',
$include = undef,
$env = [],
$env_value = {},
$clear_env = true,
$options = {},
$php_value = {},
$php_flag = {},
$php_admin_value = {},
$php_admin_flag = {},
$php_directives = [],
$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 All @@ -196,6 +196,16 @@
default => $php::fpm::package,
}

# 'php-fpm' expects a comma separated list of user names
unless $listen_acl_users.empty {
$real_listen_acl_users = join(flatten($listen_acl_users).unique, ",")
}

# 'php-fpm' expects a comma separated list of group names
unless $listen_acl_groups.empty {
$real_listen_acl_groups = join(flatten($listen_acl_groups).unique, ",")
}

$pool_base_dir = pick_default($base_dir, $php::fpm::config::pool_base_dir, $php::params::fpm_pool_dir)
if ($ensure == 'absent') {
file { "${pool_base_dir}/${pool}.conf":
Expand Down
8 changes: 4 additions & 4 deletions templates/fpm/pool.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ listen.mode = <%= @listen_mode %>
<% else -%>
;listen.mode = 0660
<% end -%>
<% if @listen_acl_users -%>
listen.acl_users = <%= @listen_acl_users %>
<% if @real_listen_acl_users -%>
listen.acl_users = <%= @real_listen_acl_users %>
<% end -%>
<% if @listen_acl_groups -%>
listen.acl_groups = <%= @listen_acl_groups %>
<% if @real_listen_acl_groups -%>
listen.acl_groups = <%= @real_listen_acl_groups %>
<% end -%>

; Unix user/group of processes
Expand Down

0 comments on commit 2d86545

Please sign in to comment.