diff --git a/manifests/fpm/config.pp b/manifests/fpm/config.pp index c67ca82..60fa953 100644 --- a/manifests/fpm/config.pp +++ b/manifests/fpm/config.pp @@ -1,145 +1,145 @@ # Configure php-fpm service # # === Parameters # # [*config_file*] # The path to the fpm config file # # [*user*] # The user that runs php-fpm # # [*group*] # The group that runs php-fpm # # [*inifile*] # The path to ini file # # [*settings*] # Nested hash of key => value to apply to php.ini # # [*pool_base_dir*] # The folder that contains the php-fpm pool configs # # [*pool_purge*] # Whether to purge pool config files not created # by this module # # [*error_log*] # Path to error log file. If it's set to "syslog", log is # sent to syslogd instead of being written in a local file. # # [*log_level*] # The php-fpm log level # # [*emergency_restart_threshold*] # The php-fpm emergency_restart_threshold # # [*emergency_restart_interval*] # The php-fpm emergency_restart_interval # # [*process_control_timeout*] # The php-fpm process_control_timeout # # [*process_max*] # The maximum number of processes FPM will fork. # # [*rlimit_files*] # Set open file descriptor rlimit for the master process. # # [*systemd_interval*] # The interval between health report notification to systemd # # [*log_owner*] # The php-fpm log owner # # [*log_group*] # The group owning php-fpm logs # # [*log_dir_mode*] # The octal mode of the directory # # [*syslog_facility*] # Used to specify what type of program is logging the message # # [*syslog_ident*] # Prepended to every message # # [*root_group*] # UNIX group of the root user # # [*pid_file*] # Path to fpm pid file # class php::fpm::config ( Stdlib::Absolutepath $config_file = $php::params::fpm_config_file, String $user = $php::params::fpm_user, String $group = $php::params::fpm_group, String $inifile = $php::params::fpm_inifile, Stdlib::Absolutepath $pid_file = $php::params::fpm_pid_file, Hash $settings = {}, Stdlib::Absolutepath $pool_base_dir = $php::params::fpm_pool_dir, Boolean $pool_purge = false, String $error_log = $php::params::fpm_error_log, String $log_level = 'notice', Integer $emergency_restart_threshold = 0, - Variant[Integer, Pattern[/^\d+[smhd]?$/]] $emergency_restart_interval = 0, - Variant[Integer, Pattern[/^\d+[smhd]?$/]] $process_control_timeout = 0, + Php::Duration $emergency_restart_interval = 0, + Php::Duration $process_control_timeout = 0, Integer $process_max = 0, Optional[Integer[1]] $rlimit_files = undef, - Optional[Variant[Integer,Pattern[/^\d+[smhd]?$/]]] $systemd_interval = undef, + Optional[Php::Duration] $systemd_interval = undef, String $log_owner = $php::params::fpm_user, String $log_group = $php::params::fpm_group, Pattern[/^\d+$/] $log_dir_mode = '0770', String[1] $root_group = $php::params::root_group, String $syslog_facility = 'daemon', String $syslog_ident = 'php-fpm', ) inherits php::params { assert_private() file { $config_file: ensure => file, content => template('php/fpm/php-fpm.conf.erb'), owner => 'root', group => $root_group, mode => '0644', } ensure_resource('file', '/var/run/php-fpm', { ensure => directory, owner => 'root', group => $root_group, mode => '0755', } ) ensure_resource('file', '/var/log/php-fpm/', { ensure => directory, owner => 'root', group => $root_group, mode => $log_dir_mode, } ) file { $pool_base_dir: ensure => directory, owner => 'root', group => $root_group, mode => '0755', } if $pool_purge { File[$pool_base_dir] { purge => true, recurse => true, } } if $inifile != $php::params::config_root_inifile { ::php::config { 'fpm': file => $inifile, config => $settings, } } } diff --git a/manifests/fpm/pool.pp b/manifests/fpm/pool.pp index d332135..03462af 100644 --- a/manifests/fpm/pool.pp +++ b/manifests/fpm/pool.pp @@ -1,206 +1,206 @@ # Configure fpm pools # # === Parameters # # See the official php-fpm documentation for parameters that are not # documented here: http://php.net/manual/en/install.fpm.configuration.php. # # [*ensure*] # Remove pool if set to `'absent'`, add otherwise # # [*listen*] # On what socket to listen for FastCGI connections, i.e. # `'127.0.0.1:9000'' or `'/var/run/php5-fpm.sock'` # # [*listen_backlog*] # # [*listen_allowed_clients*] # # [*listen_owner*] # Set owner of the Unix socket # # [*listen_group*] # Set the group of the Unix socket # # [*listen_mode*] # # [*user*] # The user that php-fpm should run as # # [*group*] # The group that php-fpm should run as # # [*apparmor_hat*] # The Apparmor hat to use # # [*pm*] # # [*pm_max_children*] # # [*pm_start_servers*] # # [*pm_min_spare_servers*] # # [*pm_max_spare_servers*] # # [*pm_max_requests*] # # [*pm_process_idle_timeout*] # # [*pm_status_path*] # # [*ping_path*] # # [*ping_response*] # # [*access_log*] # The path to the file to write access log requests to # # [*access_log_format*] # The format to save the access log entries as # # [*request_terminate_timeout*] # # [*request_slowlog_timeout*] # # [*security_limit_extensions*] # # [*slowlog*] # # [*template*] # The template to use for the pool # # [*rlimit_files*] # # [*rlimit_core*] # # [*chroot*] # # [*chdir*] # # [*catch_workers_output*] # # [*include*] # Other configuration files to include on this pool # # [*env*] # List of environment variables that are passed to the php-fpm from the # outside and will be available to php scripts in this pool # # [*env_value*] # Hash of environment variables and values as strings to use in php # scripts in this pool # # [*clear_env*] # Whether the environment should be cleared. # # [*options*] # An optional hash for any other data. # # [*php_value*] # Hash of php_value directives # # [*php_flag*] # Hash of php_flag directives # # [*php_admin_value*] # Hash of php_admin_value directives # # [*php_admin_flag*] # Hash of php_admin_flag directives # # [*php_directives*] # List of custom directives that are appended to the pool config # # [*root_group*] # UNIX group of the root user # # [*base_dir*] # The folder that contains the php-fpm pool configs. This defaults to a # sensible default depending on your operating system, like # '/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', String[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', String[1] $pm_max_children = '50', String[1] $pm_start_servers = '5', String[1] $pm_min_spare_servers = '5', String[1] $pm_max_spare_servers = '35', String[1] $pm_max_requests = '0', - String[1] $pm_process_idle_timeout = '10s', + 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"', String[1] $request_terminate_timeout = '0', String[1] $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']) { warning('You must include the php base class before using any php defined resources') } $pool = $title # Hack-ish to default to user for group too $group_final = $group ? { undef => $user, default => $group } # On FreeBSD fpm is not a separate package, but included in the 'php' package. # Implies that the option SET+=FPM was set when building the port. $real_package = $facts['os']['name'] ? { 'FreeBSD' => [], default => $php::fpm::package, } $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": ensure => absent, notify => Class['php::fpm::service'], } } else { file { "${pool_base_dir}/${pool}.conf": ensure => file, notify => Class['php::fpm::service'], require => Package[$real_package], content => template($template), owner => root, group => $root_group, mode => '0640', } } } diff --git a/types/duration.pp b/types/duration.pp new file mode 100644 index 0000000..ad645b2 --- /dev/null +++ b/types/duration.pp @@ -0,0 +1,6 @@ +# A duration in seconds are with an unit +type Php::Duration = Variant[ + Integer[0], + Pattern[/^\d+[smhd]?$/] +] +