diff --git a/REFERENCE.md b/REFERENCE.md index 0d64530..1cd91d3 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -1,2774 +1,2777 @@ # Reference ## Table of Contents **Classes** * [`php`](#php): Base class with global configuration parameters that pulls in all enabled components. === Parameters [*ensure*] Specify which version of * [`php::apache_config`](#phpapache_config): Install and configure php apache settings === Parameters [*inifile*] The path to the ini php-apache ini file [*settings*] Hash with ne * [`php::cli`](#phpcli): Install and configure php CLI === Parameters [*inifile*] The path to the ini php5-cli ini file [*settings*] Hash with nested hash of k * [`php::composer`](#phpcomposer): Install composer package manager === Parameters [*source*] Holds URL to the Composer source file [*path*] Holds path to the Composer e * [`php::composer::auto_update`](#phpcomposerauto_update): Install composer package manager === Parameters [*max_age*] Defines number of days after which Composer should be updated [*source*] H * [`php::dev`](#phpdev): Install the development package with headers for PHP === Parameters [*ensure*] The PHP ensure of PHP dev to install [*package*] The pa * [`php::embedded`](#phpembedded): Install and configure php embedded SAPI === Parameters [*inifile*] The path to the ini php5-embeded ini file [*settings*] Hash with ne * [`php::fpm`](#phpfpm): Install and configure mod_php for fpm === Parameters [*user*] The user that php-fpm should run as [*group*] The group that php-fpm sho * [`php::fpm::config`](#phpfpmconfig): Configure php-fpm service === Parameters [*config_file*] The path to the fpm config file [*user*] The user that runs php-fpm [*group* * [`php::fpm::service`](#phpfpmservice): Manage fpm service === Parameters [*service_name*] name of the php-fpm service [*ensure*] 'ensure' value for the service [*enable*] * [`php::global`](#phpglobal): * [`php::globals`](#phpglobals): * [`php::packages`](#phppackages): Install common PHP packages === Parameters [*ensure*] Specify which version of PHP packages to install [*names*] List of the names of * [`php::params`](#phpparams): PHP params class * [`php::pear`](#phppear): Install PEAR package manager === Parameters [*ensure*] The package ensure of PHP pear to install and run pear auto_discover [*package*] * [`php::phpunit`](#phpphpunit): Install phpunit, PHP testing framework === Parameters [*source*] Holds URL to the phpunit source file [*path*] Holds path to the phpun * [`php::phpunit::auto_update`](#phpphpunitauto_update): Install phpunit package manager === Parameters [*max_age*] Defines number of days after which phpunit should be updated [*source*] Hol * [`php::repo`](#phprepo): Configure package repository * [`php::repo::debian`](#phprepodebian): Configure debian apt repo === Parameters [*location*] Location of the apt repository [*release*] Release of the apt repository [*repo * [`php::repo::redhat`](#phpreporedhat): * [`php::repo::suse`](#phpreposuse): Configure suse repo === Parameters [*reponame*] Name of the Zypper repository [*baseurl*] Base URL of the Zypper repository * [`php::repo::ubuntu`](#phprepoubuntu): Configure ubuntu ppa === Parameters [*version*] PHP version to manage (e.g. 5.6) **Defined types** * [`php::apache_vhost`](#phpapache_vhost): Configures an apache vhost for php === Parameters [*vhost*] The vhost address [*docroot*] The vhost docroot [*port*] The vhost port * [`php::config`](#phpconfig): Configure php.ini settings for a PHP SAPI === Parameters [*file*] The path to ini file [*config*] Nested hash of key => value to apply * [`php::config::setting`](#phpconfigsetting): Configure php.ini settings === Parameters [*key*] The key of the value, like `ini_setting` [*file*] The path to ini file [*value*] * [`php::extension`](#phpextension): Install a PHP extension package === Parameters [*ensure*] The ensure of the package to install Could be "latest", "installed" or a pinn * [`php::extension::config`](#phpextensionconfig): Configure a PHP extension package === Parameters [*ensure*] The ensure of the package to install Could be "latest", "installed" or a pi * [`php::extension::install`](#phpextensioninstall): Install a PHP extension package === Parameters [*ensure*] The ensure of the package to install Could be "latest", "installed" or a pinn * [`php::fpm::pool`](#phpfpmpool): Configure fpm pools === Parameters See the official php-fpm documentation for parameters that are not documented here: http://php.net/manua **Functions** * [`ensure_prefix`](#ensure_prefix): This function ensures a prefix for all elements in an array or the keys in a hash. *Examples:* ensure_prefix({'a' => 1, 'b' => 2, 'p.c' = * [`to_hash_settings`](#to_hash_settings): This function converts a +{key => value}+ hash into a nested hash and can add an id to the outer key. The optional id string as second parame ## Classes ### php Base class with global configuration parameters that pulls in all enabled components. === Parameters [*ensure*] Specify which version of PHP packages to install, defaults to 'present'. Please note that 'absent' to remove packages is not supported! [*manage_repos*] Include repository (dotdeb, ppa, etc.) to install recent PHP from [*fpm*] Install and configure php-fpm [*fpm_service_enable*] Enable/disable FPM service [*fpm_service_ensure*] Ensure FPM service is either 'running' or 'stopped' [*fpm_service_name*] This is the name of the php-fpm service. It defaults to reasonable OS defaults but can be different in case of using php7.0/other OS/custom fpm service [*fpm_service_provider*] This is the name of the service provider, in case there is a non OS default service provider used to start FPM. Defaults to 'undef', pick system defaults. [*fpm_pools*] Hash of php::fpm::pool resources that will be created. Defaults to a single php::fpm::pool named www with default parameters. [*fpm_global_pool_settings*] Hash of defaults params php::fpm::pool resources that will be created. Defaults to empty hash. [*fpm_inifile*] Path to php.ini for fpm [*fpm_package*] Name of fpm package to install [*fpm_user*] The user that php-fpm should run as [*fpm_group*] The group that php-fpm should run as [*dev*] Install php header files, needed to install pecl modules [*composer*] Install and auto-update composer [*pear*] Install PEAR [*phpunit*] Install phpunit [*apache_config*] Manage apache's mod_php configuration [*proxy_type*] proxy server type (none|http|https|ftp) [*proxy_server*] specify a proxy server, with port number if needed. ie: https://example.com:8080. [*extensions*] Install PHP extensions, this is overwritten by hiera hash `php::extensions` [*package_prefix*] This is the prefix for constructing names of php packages. This defaults to a sensible default depending on your operating system, like 'php-' or 'php5-'. [*config_root_ini*] This is the path to the config .ini files of the extensions. This defaults to a sensible default depending on your operating system, like '/etc/php5/mods-available' or '/etc/php5/conf.d'. [*config_root_inifile*] The path to the global php.ini file. This defaults to a sensible default depending on your operating system. [*ext_tool_enable*] Absolute path to php tool for enabling extensions in debian/ubuntu systems. This defaults to '/usr/sbin/php5enmod'. [*ext_tool_query*] Absolute path to php tool for querying information about extensions in debian/ubuntu systems. This defaults to '/usr/sbin/php5query'. [*ext_tool_enabled*] Enable or disable the use of php tools on debian based systems debian/ubuntu systems. This defaults to 'true'. [*log_owner*] The php-fpm log owner [*log_group*] The group owning php-fpm logs [*embedded*] Enable embedded SAPI [*pear_ensure*] The package ensure of PHP pear to install and run pear auto_discover [*settings*] #### Parameters The following parameters are available in the `php` class. ##### `ensure` Data type: `String` Default value: $php::params::ensure ##### `manage_repos` Data type: `Boolean` Default value: $php::params::manage_repos ##### `fpm` Data type: `Boolean` Default value: `true` ##### `fpm_service_enable` Data type: `Any` Default value: $php::params::fpm_service_enable ##### `fpm_service_ensure` Data type: `Any` Default value: $php::params::fpm_service_ensure ##### `fpm_service_name` Data type: `Any` Default value: $php::params::fpm_service_name ##### `fpm_service_provider` Data type: `Any` Default value: `undef` ##### `fpm_pools` Data type: `Hash` Default value: { 'www' => {} } ##### `fpm_global_pool_settings` Data type: `Hash` Default value: {} ##### `fpm_inifile` Data type: `Any` Default value: $php::params::fpm_inifile ##### `fpm_package` Data type: `Any` Default value: `undef` ##### `fpm_user` Data type: `Any` Default value: $php::params::fpm_user ##### `fpm_group` Data type: `Any` Default value: $php::params::fpm_group ##### `embedded` Data type: `Boolean` Default value: `false` ##### `dev` Data type: `Boolean` Default value: `true` ##### `composer` Data type: `Boolean` Default value: `true` ##### `pear` Data type: `Boolean` Default value: `true` ##### `pear_ensure` Data type: `String` Default value: $php::params::pear_ensure ##### `phpunit` Data type: `Boolean` Default value: `false` ##### `apache_config` Data type: `Boolean` Default value: `false` ##### `proxy_type` Data type: `Any` Default value: `undef` ##### `proxy_server` Data type: `Any` Default value: `undef` ##### `extensions` Data type: `Hash` Default value: {} ##### `settings` Data type: `Hash` Default value: {} ##### `package_prefix` Data type: `Any` Default value: $php::params::package_prefix ##### `config_root_ini` Data type: `Stdlib::Absolutepath` Default value: $php::params::config_root_ini ##### `config_root_inifile` Data type: `Stdlib::Absolutepath` Default value: $php::params::config_root_inifile ##### `ext_tool_enable` Data type: `Optional[Stdlib::Absolutepath]` Default value: $php::params::ext_tool_enable ##### `ext_tool_query` Data type: `Optional[Stdlib::Absolutepath]` Default value: $php::params::ext_tool_query ##### `ext_tool_enabled` Data type: `Boolean` Default value: $php::params::ext_tool_enabled ##### `log_owner` Data type: `String` Default value: $php::params::fpm_user ##### `log_group` Data type: `String` Default value: $php::params::fpm_group ### php::apache_config Install and configure php apache settings === Parameters [*inifile*] The path to the ini php-apache ini file [*settings*] Hash with nested hash of key => value to set in inifile #### Parameters The following parameters are available in the `php::apache_config` class. ##### `inifile` Data type: `Stdlib::Absolutepath` Default value: $php::params::apache_inifile ##### `settings` Data type: `Hash` Default value: {} ### php::cli Install and configure php CLI === Parameters [*inifile*] The path to the ini php5-cli ini file [*settings*] Hash with nested hash of key => value to set in inifile #### Parameters The following parameters are available in the `php::cli` class. ##### `inifile` Data type: `Stdlib::Absolutepath` Default value: $php::params::cli_inifile ##### `settings` Data type: `Hash` Default value: {} ### php::composer Install composer package manager === Parameters [*source*] Holds URL to the Composer source file [*path*] Holds path to the Composer executable [*channel*] Holds the Update channel (stable|preview|snapshot|1|2) [*proxy_type*] proxy server type (none|http|https|ftp) [*proxy_server*] specify a proxy server, with port number if needed. ie: https://example.com:8080. [*auto_update*] Defines if composer should be auto updated [*max_age*] Defines the time in days after which an auto-update gets executed [*root_group*] UNIX group of the root user #### Parameters The following parameters are available in the `php::composer` class. ##### `source` Data type: `String` Default value: $php::params::composer_source ##### `path` Data type: `Stdlib::Absolutepath` Default value: $php::params::composer_path ##### `proxy_type` Data type: `Any` Default value: `undef` ##### `proxy_server` Data type: `Any` Default value: `undef` ##### `auto_update` Data type: `Boolean` Default value: `true` ##### `max_age` Data type: `Integer` Default value: $php::params::composer_max_age ##### `root_group` Data type: `Variant[Integer, String]` Default value: $php::params::root_group ### php::composer::auto_update Install composer package manager === Parameters [*max_age*] Defines number of days after which Composer should be updated [*source*] Holds URL to the Composer source file [*path*] Holds path to the Composer executable [*proxy_type*] proxy server type (none|http|https|ftp) [*proxy_server*] specify a proxy server, with port number if needed. ie: https://example.com:8080. === Examples include php::composer::auto_update class { "php::composer::auto_update": "max_age" => 90 } #### Parameters The following parameters are available in the `php::composer::auto_update` class. ##### `max_age` Data type: `Any` ##### `source` Data type: `Any` ##### `path` Data type: `Any` ##### `proxy_type` Data type: `Any` Default value: `undef` ##### `proxy_server` Data type: `Any` Default value: `undef` ### php::dev Install the development package with headers for PHP === Parameters [*ensure*] The PHP ensure of PHP dev to install [*package*] The package name for the PHP development files #### Parameters The following parameters are available in the `php::dev` class. ##### `ensure` Data type: `String` Default value: $php::ensure ##### `package` Data type: `String` Default value: "${php::package_prefix}${php::params::dev_package_suffix}" ##### `manage_repos` Data type: `Boolean` Default value: $php::manage_repos ### php::embedded Install and configure php embedded SAPI === Parameters [*inifile*] The path to the ini php5-embeded ini file [*settings*] Hash with nested hash of key => value to set in inifile [*package*] Specify which package to install [*ensure*] Specify which version of the package to install #### Parameters The following parameters are available in the `php::embedded` class. ##### `ensure` Data type: `String` Default value: $php::ensure ##### `package` Data type: `String` Default value: "${php::package_prefix}${php::params::embedded_package_suffix}" ##### `inifile` Data type: `Stdlib::Absolutepath` Default value: $php::params::embedded_inifile ##### `settings` Data type: `Hash` Default value: {} ### php::fpm Install and configure mod_php for fpm === Parameters [*user*] The user that php-fpm should run as [*group*] The group that php-fpm should run as [*service_enable*] Enable/disable FPM service [*service_ensure*] Ensure FPM service is either 'running' or 'stopped' [*service_name*] This is the name of the php-fpm service. It defaults to reasonable OS defaults but can be different in case of using php7.0/other OS/custom fpm service [*service_provider*] This is the name of the service provider, in case there is a non OS default service provider used to start FPM. Defaults to 'undef', pick system defaults. [*pools*] Hash of php::fpm::pool resources that will be created. Defaults to a single php::fpm::pool named www with default parameters. [*log_owner*] The php-fpm log owner [*log_group*] The group owning php-fpm logs [*package*] Specify which package to install [*ensure*] Specify which version of the package to install [*inifile*] Path to php.ini for fpm [*settings*] fpm settings hash [*global_pool_settings*] Hash of defaults params php::fpm::pool resources that will be created. Defaults is empty hash. #### Parameters The following parameters are available in the `php::fpm` class. ##### `ensure` Data type: `String` Default value: $php::ensure ##### `user` Data type: `Any` Default value: $php::fpm_user ##### `group` Data type: `Any` Default value: $php::fpm_group ##### `service_ensure` Data type: `Any` Default value: $php::fpm_service_ensure ##### `service_enable` Data type: `Any` Default value: $php::fpm_service_enable ##### `service_name` Data type: `Any` Default value: $php::fpm_service_name ##### `service_provider` Data type: `Any` Default value: $php::fpm_service_provider ##### `package` Data type: `String` Default value: $php::real_fpm_package ##### `inifile` Data type: `Stdlib::Absolutepath` Default value: $php::fpm_inifile ##### `settings` Data type: `Hash` Default value: $php::real_settings ##### `global_pool_settings` Data type: `Any` Default value: $php::real_fpm_global_pool_settings ##### `pools` Data type: `Hash` Default value: $php::real_fpm_pools ##### `log_owner` Data type: `Any` Default value: $php::log_owner ##### `log_group` Data type: `Any` Default value: $php::log_group ### php::fpm::config 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 #### Parameters The following parameters are available in the `php::fpm::config` class. ##### `config_file` Data type: `Any` Default value: $php::params::fpm_config_file ##### `user` Data type: `String` Default value: $php::params::fpm_user ##### `group` Data type: `String` Default value: $php::params::fpm_group ##### `inifile` Data type: `String` Default value: $php::params::fpm_inifile ##### `pid_file` Data type: `Any` Default value: $php::params::fpm_pid_file ##### `settings` Data type: `Hash` Default value: {} ##### `pool_base_dir` Data type: `Stdlib::Absolutepath` Default value: $php::params::fpm_pool_dir ##### `pool_purge` Data type: `Any` Default value: `false` ##### `error_log` Data type: `String` Default value: $php::params::fpm_error_log ##### `log_level` Data type: `String` Default value: 'notice' ##### `emergency_restart_threshold` Data type: `Integer` Default value: 0 ##### `emergency_restart_interval` Data type: `Variant[Integer, Pattern[/^\d+[smhd]?$/]]` Default value: 0 ##### `process_control_timeout` Data type: `Variant[Integer, Pattern[/^\d+[smhd]?$/]]` Default value: 0 ##### `process_max` Data type: `Integer` Default value: 0 ##### `rlimit_files` Data type: `Any` Default value: `undef` ##### `systemd_interval` Data type: `Optional[Variant[Integer,Pattern[/^\d+[smhd]?$/]]]` Default value: `undef` ##### `log_owner` Data type: `String` Default value: $php::params::fpm_user ##### `log_group` Data type: `String` Default value: $php::params::fpm_group ##### `log_dir_mode` Data type: `Pattern[/^\d+$/]` Default value: '0770' ##### `root_group` Data type: `Any` Default value: $php::params::root_group ##### `syslog_facility` Data type: `String` Default value: 'daemon' ##### `syslog_ident` Data type: `String` Default value: 'php-fpm' ### php::fpm::service Manage fpm service === Parameters [*service_name*] name of the php-fpm service [*ensure*] 'ensure' value for the service [*enable*] Defines if the service is enabled [*provider*] Defines if the service provider to use #### Parameters The following parameters are available in the `php::fpm::service` class. ##### `service_name` Data type: `Any` Default value: $php::fpm::service_name ##### `ensure` Data type: `Any` Default value: $php::fpm::service_ensure ##### `enable` Data type: `Any` Default value: $php::fpm::service_enable ##### `provider` Data type: `Any` Default value: $php::fpm::service_provider ### php::global The php::global class. #### Parameters The following parameters are available in the `php::global` class. ##### `inifile` Data type: `Stdlib::Absolutepath` Default value: $php::config_root_inifile ##### `settings` Data type: `Hash` Default value: {} ### php::globals The php::globals class. #### Parameters The following parameters are available in the `php::globals` class. ##### `php_version` Data type: `Optional[Pattern[/^(rh-)?(php)?[57](\.)?[0-9]/]]` Default value: `undef` ##### `config_root` Data type: `Optional[Stdlib::Absolutepath]` Default value: `undef` ##### `fpm_pid_file` Data type: `Optional[Stdlib::Absolutepath]` Default value: `undef` ##### `rhscl_mode` Data type: `Any` Default value: `undef` ### php::packages Install common PHP packages === Parameters [*ensure*] Specify which version of PHP packages to install [*names*] List of the names of the package to install [*names_to_prefix*] List of packages names that should be prefixed with the common package prefix `$php::package_prefix` #### Parameters The following parameters are available in the `php::packages` class. ##### `ensure` Data type: `String` Default value: $php::ensure ##### `manage_repos` Data type: `Boolean` Default value: $php::manage_repos ##### `names_to_prefix` Data type: `Array` Default value: prefix($php::params::common_package_suffixes, $php::package_prefix) ##### `names` Data type: `Array` Default value: $php::params::common_package_names ### php::params PHP params class ### php::pear Install PEAR package manager === Parameters [*ensure*] The package ensure of PHP pear to install and run pear auto_discover [*package*] The package name for PHP pear #### Parameters The following parameters are available in the `php::pear` class. ##### `ensure` Data type: `String` Default value: $php::pear_ensure ##### `package` Data type: `Optional[String]` Default value: `undef` ##### `manage_repos` Data type: `Boolean` Default value: $php::manage_repos ### php::phpunit Install phpunit, PHP testing framework === Parameters [*source*] Holds URL to the phpunit source file [*path*] Holds path to the phpunit executable [*auto_update*] Defines if phpunit should be auto updated [*max_age*] Defines the time in days after which an auto-update gets executed #### Parameters The following parameters are available in the `php::phpunit` class. ##### `source` Data type: `String` Default value: $php::params::phpunit_source ##### `path` Data type: `Stdlib::Absolutepath` Default value: $php::params::phpunit_path ##### `root_group` Data type: `String[1]` Default value: $php::params::root_group ##### `auto_update` Data type: `Boolean` Default value: `true` ##### `max_age` Data type: `Integer` Default value: $php::params::phpunit_max_age ### php::phpunit::auto_update Install phpunit package manager === Parameters [*max_age*] Defines number of days after which phpunit should be updated [*source*] Holds URL to the phpunit source file [*path*] Holds path to the phpunit executable #### Parameters The following parameters are available in the `php::phpunit::auto_update` class. ##### `max_age` Data type: `Any` ##### `source` Data type: `Any` ##### `path` Data type: `Any` ### php::repo Configure package repository ### php::repo::debian Configure debian apt repo === Parameters [*location*] Location of the apt repository [*release*] Release of the apt repository [*repos*] Apt repository names [*include_src*] Add source source repository [*key*] Public key in apt::key format [*dotdeb*] Enable special dotdeb handling [*sury*] Enable special sury handling #### Parameters The following parameters are available in the `php::repo::debian` class. ##### `location` Data type: `Any` Default value: 'https://packages.dotdeb.org' ##### `release` Data type: `Any` Default value: 'wheezy-php56' ##### `repos` Data type: `Any` Default value: 'all' ##### `include_src` Data type: `Any` Default value: `false` ##### `key` Data type: `Any` Default value: { 'id' => '6572BBEF1B5FF28B28B706837E3F070089DF5277', 'source' => 'http://www.dotdeb.org/dotdeb.gpg', } ##### `dotdeb` Data type: `Any` Default value: `true` ##### `sury` Data type: `Any` Default value: `true` ### php::repo::redhat The php::repo::redhat class. #### Parameters The following parameters are available in the `php::repo::redhat` class. ##### `yum_repo` Data type: `Any` Default value: 'remi_php56' ### php::repo::suse Configure suse repo === Parameters [*reponame*] Name of the Zypper repository [*baseurl*] Base URL of the Zypper repository #### Parameters The following parameters are available in the `php::repo::suse` class. ##### `reponame` Data type: `Any` Default value: 'mayflower-php56' ##### `baseurl` Data type: `Any` Default value: 'http://download.opensuse.org/repositories/home:/mayflower:/php5.6_based/SLE_11_SP3/' ### php::repo::ubuntu Configure ubuntu ppa === Parameters [*version*] PHP version to manage (e.g. 5.6) #### Parameters The following parameters are available in the `php::repo::ubuntu` class. ##### `version` Data type: `Any` Default value: `undef` ## Defined types ### php::apache_vhost Configures an apache vhost for php === Parameters [*vhost*] The vhost address [*docroot*] The vhost docroot [*port*] The vhost port [*default_vhost*] defines if vhost is the default vhost [*fastcgi_socket*] address of the fastcgi socket #### Parameters The following parameters are available in the `php::apache_vhost` defined type. ##### `vhost` Data type: `Any` Default value: 'example.com' ##### `docroot` Data type: `Any` Default value: '/var/www' ##### `port` Data type: `Any` Default value: 80 ##### `default_vhost` Data type: `Any` Default value: `true` ##### `fastcgi_socket` Data type: `Any` Default value: 'fcgi://127.0.0.1:9000/$1' ### php::config Configure php.ini settings for a PHP SAPI === Parameters [*file*] The path to ini file [*config*] Nested hash of key => value to apply to php.ini === Examples php::config { '$unique-name': file => '$full_path_to_ini_file' config => { {'Date/date.timezone' => 'Europe/Berlin'} } } #### Parameters The following parameters are available in the `php::config` defined type. ##### `file` Data type: `Stdlib::Absolutepath` ##### `config` Data type: `Hash` ### php::config::setting Configure php.ini settings === Parameters [*key*] The key of the value, like `ini_setting` [*file*] The path to ini file [*value*] The value to set === Examples php::config::setting { 'Date/date.timezone': file => '$full_path_to_ini_file' value => 'Europe/Berlin' } #### Parameters The following parameters are available in the `php::config::setting` defined type. ##### `key` Data type: `Any` ##### `value` Data type: `Any` ##### `file` Data type: `Stdlib::Absolutepath` ### php::extension Install a PHP extension package === Parameters [*ensure*] The ensure of the package to install Could be "latest", "installed" or a pinned version [*package_prefix*] Prefix to prepend to the package name for the package provider [*provider*] The provider used to install the package Could be "pecl", "apt", "dpkg" or any other OS package provider If set to "none", no package will be installed [*source*] The source to install the extension from. Possible values depend on the *provider* used [*so_name*] The DSO name of the package (e.g. opcache for zendopcache) [*ini_prefix*] An optional filename prefix for the settings file of the extension [*php_api_version*] This parameter is used to build the full path to the extension directory for zend_extension in PHP < 5.5 (e.g. 20100525) [*header_packages*] System packages dependencies to install for extensions (e.g. for memcached libmemcached-dev on Debian) [*compiler_packages*] System packages dependencies to install for compiling extensions (e.g. build-essential on Debian) [*zend*] Boolean parameter, whether to load extension as zend_extension. Defaults to false. [*settings*] Hash of parameters for the specific extension, which will be written to the extensions config file by php::extension::config or a hash of mutliple settings files, each with parameters (multifile_settings must be true) (f.ex. {p => '..'} or {'bz2' => {..}, {'math' => {...}}) [*multifile_settings*] Set this to true if you specify multiple setting files in *settings*. This must be used when the PHP package distribution bundles extensions in a single package (like 'common' bundles extensions 'bz2', ...) and each of the extension comes with a separate settings file. [*settings_prefix*] Boolean/String parameter, whether to prefix all setting keys with the extension name or specified name. Defaults to false. [*sapi*] String parameter, whether to specify ALL sapi or a specific sapi. Defaults to ALL. [*responsefile*] File containing answers for interactive extension setup. Supported *providers*: pear, pecl. [*install_options*] Array of String or Hash options to pass to the provider. #### Parameters The following parameters are available in the `php::extension` defined type. ##### `ensure` Data type: `String` Default value: 'installed' ##### `provider` Data type: `Optional[Php::Provider]` Default value: `undef` ##### `source` Data type: `Optional[String]` Default value: `undef` ##### `so_name` Data type: `Optional[String]` Default value: `undef` ##### `ini_prefix` Data type: `Optional[String]` Default value: `undef` ##### `php_api_version` Data type: `Optional[String]` Default value: `undef` ##### `package_prefix` Data type: `String` Default value: $php::package_prefix ##### `zend` Data type: `Boolean` Default value: `false` ##### `settings` Data type: `Variant[Hash, Hash[String, Hash]]` Default value: {} ##### `multifile_settings` Data type: `Boolean` Default value: `false` ##### `sapi` Data type: `Php::Sapi` Default value: 'ALL' ##### `settings_prefix` Data type: `Variant[Boolean, String]` Default value: `false` ##### `responsefile` Data type: `Optional[Stdlib::AbsolutePath]` Default value: `undef` ##### `header_packages` Data type: `Variant[String, Array[String]]` Default value: [] ##### `compiler_packages` Data type: `Variant[String, Array[String]]` Default value: $php::params::compiler_packages ##### `install_options` Data type: `Php::InstallOptions` Default value: `undef` ### php::extension::config Configure a PHP extension package === Parameters [*ensure*] The ensure of the package to install Could be "latest", "installed" or a pinned version [*provider*] The provider used to install the package Could be "pecl", "apt", "dpkg" or any other OS package provider If set to "none", no package will be installed [*so_name*] The DSO name of the package (e.g. opcache for zendopcache) [*ini_prefix*] An optional filename prefix for the settings file of the extension [*php_api_version*] This parameter is used to build the full path to the extension directory for zend_extension in PHP < 5.5 (e.g. 20100525) [*header_packages*] System packages dependencies to install for extensions (e.g. for memcached libmemcached-dev on Debian) [*compiler_packages*] System packages dependencies to install for compiling extensions (e.g. build-essential on Debian) [*zend*] Boolean parameter, whether to load extension as zend_extension. Defaults to false. [*settings*] Nested hash of global config parameters for php.ini [*settings_prefix*] Boolean/String parameter, whether to prefix all setting keys with the extension name or specified name. Defaults to false. [*sapi*] String parameter, whether to specify ALL sapi or a specific sapi. Defaults to ALL. #### Parameters The following parameters are available in the `php::extension::config` defined type. ##### `ensure` Data type: `String` Default value: 'installed' ##### `provider` Data type: `Optional[Php::Provider]` Default value: `undef` ##### `so_name` Data type: `Optional[String]` Default value: downcase($name) ##### `ini_prefix` Data type: `Optional[String]` Default value: `undef` ##### `php_api_version` Data type: `Optional[String]` Default value: `undef` ##### `zend` Data type: `Boolean` Default value: `false` ##### `settings` Data type: `Hash` Default value: {} ##### `settings_prefix` Data type: `Variant[Boolean, String]` Default value: `false` ##### `sapi` Data type: `Php::Sapi` Default value: 'ALL' ### php::extension::install Install a PHP extension package === Parameters [*ensure*] The ensure of the package to install Could be "latest", "installed" or a pinned version [*package_prefix*] Prefix to prepend to the package name for the package provider [*provider*] The provider used to install the package Could be "pecl", "apt", "dpkg" or any other OS package provider If set to "none", no package will be installed [*source*] The source to install the extension from. Possible values depend on the *provider* used [*header_packages*] System packages dependencies to install for extensions (e.g. for memcached libmemcached-dev on Debian) [*compiler_packages*] System packages dependencies to install for compiling extensions (e.g. build-essential on Debian) [*responsefile*] File containing answers for interactive extension setup. Supported *providers*: pear, pecl. [*install_options*] Array of String or Hash options to pass to the provider. #### Parameters The following parameters are available in the `php::extension::install` defined type. ##### `ensure` Data type: `String` Default value: 'installed' ##### `provider` Data type: `Optional[Php::Provider]` Default value: `undef` ##### `source` Data type: `Optional[String]` Default value: `undef` ##### `package_prefix` Data type: `String` Default value: $php::package_prefix ##### `responsefile` Data type: `Optional[Stdlib::AbsolutePath]` Default value: `undef` ##### `header_packages` Data type: `Variant[String, Array[String]]` Default value: [] ##### `compiler_packages` Data type: `Variant[String, Array[String]]` Default value: $php::params::compiler_packages ##### `install_options` Data type: `Php::InstallOptions` Default value: `undef` ### php::fpm::pool 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 [*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' #### Parameters The following parameters are available in the `php::fpm::pool` defined type. ##### `ensure` Data type: `Any` Default value: 'present' ##### `listen` Data type: `Any` Default value: '127.0.0.1:9000' ##### `listen_backlog` Data type: `Any` Default value: '-1' ##### `listen_allowed_clients` Data type: `Any` Default value: `undef` ##### `listen_owner` Data type: `Any` Default value: `undef` ##### `listen_group` Data type: `Any` Default value: `undef` ##### `listen_mode` Data type: `Any` Default value: `undef` ##### `user` Data type: `Any` Default value: $php::fpm::config::user ##### `group` Data type: `Any` Default value: $php::fpm::config::group ##### `pm` Data type: `Any` Default value: 'dynamic' ##### `pm_max_children` Data type: `Any` Default value: '50' ##### `pm_start_servers` Data type: `Any` Default value: '5' ##### `pm_min_spare_servers` Data type: `Any` Default value: '5' ##### `pm_max_spare_servers` Data type: `Any` Default value: '35' ##### `pm_max_requests` Data type: `Any` Default value: '0' ##### `pm_process_idle_timeout` Data type: `Any` Default value: '10s' ##### `pm_status_path` Data type: `Any` Default value: `undef` ##### `ping_path` Data type: `Any` Default value: `undef` ##### `ping_response` Data type: `Any` Default value: 'pong' ##### `access_log` Data type: `Any` Default value: `undef` ##### `access_log_format` Data type: `Any` Default value: '"%R - %u %t \"%m %r\" %s"' ##### `request_terminate_timeout` Data type: `Any` Default value: '0' ##### `request_slowlog_timeout` Data type: `Any` Default value: '0' ##### `security_limit_extensions` Data type: `Any` Default value: `undef` ##### `slowlog` Data type: `Any` Default value: "/var/log/php-fpm/${name}-slow.log" ##### `template` Data type: `Any` Default value: 'php/fpm/pool.conf.erb' ##### `rlimit_files` Data type: `Any` Default value: `undef` ##### `rlimit_core` Data type: `Any` Default value: `undef` ##### `chroot` Data type: `Any` Default value: `undef` ##### `chdir` Data type: `Any` Default value: `undef` ##### `catch_workers_output` Data type: `Any` Default value: 'no' ##### `include` Data type: `Any` Default value: `undef` ##### `env` Data type: `Any` Default value: [] ##### `env_value` Data type: `Any` Default value: {} ##### `options` Data type: `Any` Default value: {} ##### `php_value` Data type: `Any` Default value: {} ##### `php_flag` Data type: `Any` Default value: {} ##### `php_admin_value` Data type: `Any` Default value: {} ##### `php_admin_flag` Data type: `Any` Default value: {} ##### `php_directives` Data type: `Any` Default value: [] ##### `root_group` Data type: `Any` Default value: $php::params::root_group ##### `base_dir` Data type: `Optional[Stdlib::Absolutepath]` Default value: `undef` ## Functions ### ensure_prefix Type: Ruby 3.x API This function ensures a prefix for all elements in an array or the keys in a hash. *Examples:* ensure_prefix({'a' => 1, 'b' => 2, 'p.c' => 3}, 'p.') Will return: { 'p.a' => 1, 'p.b' => 2, 'p.c' => 3, } ensure_prefix(['a', 'p.b', 'c'], 'p.') Will return: ['p.a', 'p.b', 'p.c'] #### `ensure_prefix()` This function ensures a prefix for all elements in an array or the keys in a hash. *Examples:* ensure_prefix({'a' => 1, 'b' => 2, 'p.c' => 3}, 'p.') Will return: { 'p.a' => 1, 'p.b' => 2, 'p.c' => 3, } ensure_prefix(['a', 'p.b', 'c'], 'p.') Will return: ['p.a', 'p.b', 'p.c'] Returns: `Any` ### to_hash_settings Type: Ruby 3.x API This function converts a +{key => value}+ hash into a nested hash and can add an id to the outer key. The optional id string as second parameter is prepended to the resource name. *Examples:* to_hash_settings({'a' => 1, 'b' => 2}) Would return: { 'a' => {'key' => 'a', 'value' => 1}, 'b' => {'key' => 'b', 'value' => 2} } and: to_hash_settings({'a' => 1, 'b' => 2}, 'foo') Would return: { 'foo: a' => {'key' => 'a', 'value' => 1}, 'foo: b' => {'key' => 'b', 'value' => 2} } #### `to_hash_settings()` This function converts a +{key => value}+ hash into a nested hash and can add an id to the outer key. The optional id string as second parameter is prepended to the resource name. *Examples:* to_hash_settings({'a' => 1, 'b' => 2}) Would return: { 'a' => {'key' => 'a', 'value' => 1}, 'b' => {'key' => 'b', 'value' => 2} } and: to_hash_settings({'a' => 1, 'b' => 2}, 'foo') Would return: { 'foo: a' => {'key' => 'a', 'value' => 1}, 'foo: b' => {'key' => 'b', 'value' => 2} } Returns: `Any` diff --git a/manifests/fpm/pool.pp b/manifests/fpm/pool.pp index aa7025d..d97337c 100644 --- a/manifests/fpm/pool.pp +++ b/manifests/fpm/pool.pp @@ -1,202 +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 ( $ensure = 'present', $listen = '127.0.0.1:9000', $listen_backlog = '-1', $listen_allowed_clients = undef, $listen_owner = undef, $listen_group = undef, $listen_mode = 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']) { 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/spec/classes/php_spec.rb b/spec/classes/php_spec.rb index 7be513d..4d0f065 100644 --- a/spec/classes/php_spec.rb +++ b/spec/classes/php_spec.rb @@ -1,323 +1,363 @@ require 'spec_helper' describe 'php', type: :class do on_supported_os.each do |os, facts| context "on #{os}" do let :facts do facts end php_cli_package = case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '10' 'php7.3-cli' when '9' 'php7.0-cli' else 'php5-cli' end when 'Ubuntu' case facts[:os]['release']['major'] when '18.04' 'php7.2-cli' when '16.04' 'php7.0-cli' else 'php5-cli' end end php_fpm_package = case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '10' 'php7.3-fpm' when '9' 'php7.0-fpm' else 'php5-fpm' end when 'Ubuntu' case facts[:os]['release']['major'] when '18.04' 'php7.2-fpm' when '16.04' 'php7.0-fpm' else 'php5-fpm' end end php_dev_package = case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '10' 'php7.3-dev' when '9' 'php7.0-dev' else 'php5-dev' end when 'Ubuntu' case facts[:os]['release']['major'] when '18.04' 'php7.2-dev' when '16.04' 'php7.0-dev' else 'php5-dev' end end describe 'works without params' do it { is_expected.to compile.with_all_deps } end describe 'when called with no parameters' do case facts[:osfamily] when 'Suse', 'RedHat', 'CentOS' it { is_expected.to contain_class('php::global') } end case facts[:osfamily] when 'Debian' it { is_expected.not_to contain_class('php::global') } it { is_expected.to contain_class('php::fpm') } it { is_expected.to contain_package('php-pear').with_ensure('present') } it { is_expected.to contain_class('php::composer') } it { is_expected.to contain_package(php_cli_package).with_ensure('present') } it { is_expected.to contain_package(php_fpm_package).with_ensure('present') } it { is_expected.to contain_package(php_dev_package).with_ensure('present') } when 'Suse' it { is_expected.to contain_package('php5').with_ensure('present') } it { is_expected.to contain_package('php5-devel').with_ensure('present') } it { is_expected.to contain_package('php5-pear').with_ensure('present') } it { is_expected.not_to contain_package('php5-cli') } it { is_expected.not_to contain_package('php5-dev') } it { is_expected.not_to contain_package('php-pear') } when 'RedHat', 'CentOS' it { is_expected.to contain_package('php-cli').with_ensure('present') } it { is_expected.to contain_package('php-common').with_ensure('present') } end end describe 'when called with extensions' do let(:params) { { extensions: { xml: {} } } } it { is_expected.to contain_php__extension('xml').with_ensure('present') } end describe 'when called with ensure absent and extensions' do extensions = { xml: {} } let(:params) { { ensure: 'absent', extensions: extensions } } it { is_expected.to contain_php__extension('xml').with_ensure('absent') } case facts[:osfamily] when 'Debian' it { is_expected.to contain_package(php_cli_package).with_ensure('absent') } it { is_expected.to contain_package(php_fpm_package).with_ensure('absent') } it { is_expected.to contain_package(php_dev_package).with_ensure('absent') } when 'Suse' it { is_expected.to contain_package('php5').with_ensure('absent') } it { is_expected.to contain_package('php5-devel').with_ensure('absent') } when 'RedHat', 'CentOS' it { is_expected.to contain_package('php-cli').with_ensure('absent') } it { is_expected.to contain_package('php-common').with_ensure('absent') } end end describe 'when called with package_prefix parameter' do package_prefix = 'myphp-' let(:params) { { package_prefix: package_prefix } } case facts[:osfamily] when 'Suse', 'RedHat', 'CentOS' it { is_expected.to contain_class('php::global') } end case facts[:osfamily] when 'Debian', 'RedHat', 'CentOS' it { is_expected.to contain_package("#{package_prefix}cli").with_ensure('present') } end case facts[:osfamily] when 'Debian' it { is_expected.not_to contain_class('php::global') } it { is_expected.to contain_class('php::fpm') } it { is_expected.to contain_class('php::composer') } it { is_expected.to contain_package('php-pear').with_ensure('present') } it { is_expected.to contain_package("#{package_prefix}dev").with_ensure('present') } it { is_expected.to contain_package("#{package_prefix}fpm").with_ensure('present') } when 'Suse' it { is_expected.to contain_package('php5').with_ensure('present') } it { is_expected.to contain_package("#{package_prefix}devel").with_ensure('present') } it { is_expected.to contain_package("#{package_prefix}pear").with_ensure('present') } it { is_expected.not_to contain_package("#{package_prefix}cli").with_ensure('present') } it { is_expected.not_to contain_package("#{package_prefix}dev") } it { is_expected.not_to contain_package('php-pear') } when 'RedHat', 'CentOS' it { is_expected.to contain_package("#{package_prefix}common").with_ensure('present') } end end describe 'when called with fpm_user parameter' do let(:params) { { fpm_user: 'nginx' } } it { is_expected.to contain_class('php::fpm').with(user: 'nginx') } it { is_expected.to contain_php__fpm__pool('www').with(user: 'nginx') } dstfile = case facts[:osfamily] when 'Debian' case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '10' '/etc/php/7.3/fpm/pool.d/www.conf' when '9' '/etc/php/7.0/fpm/pool.d/www.conf' else '/etc/php5/fpm/pool.d/www.conf' end when 'Ubuntu' case facts[:os]['release']['major'] when '18.04' '/etc/php/7.2/fpm/pool.d/www.conf' when '16.04' '/etc/php/7.0/fpm/pool.d/www.conf' else '/etc/php5/fpm/pool.d/www.conf' end end when 'Archlinux' '/etc/php/php-fpm.d/www.conf' when 'Suse' '/etc/php5/fpm/pool.d/www.conf' when 'RedHat' '/etc/php-fpm.d/www.conf' when 'FreeBSD' '/usr/local/etc/php-fpm.d/www.conf' end it { is_expected.to contain_file(dstfile).with_content(%r{user = nginx}) } end describe 'when called with fpm_group parameter' do let(:params) { { fpm_group: 'nginx' } } it { is_expected.to contain_class('php::fpm').with(group: 'nginx') } it { is_expected.to contain_php__fpm__pool('www').with(group: 'nginx') } dstfile = case facts[:osfamily] when 'Debian' case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] when '10' '/etc/php/7.3/fpm/pool.d/www.conf' when '9' '/etc/php/7.0/fpm/pool.d/www.conf' else '/etc/php5/fpm/pool.d/www.conf' end when 'Ubuntu' case facts[:os]['release']['major'] when '18.04' '/etc/php/7.2/fpm/pool.d/www.conf' when '16.04' '/etc/php/7.0/fpm/pool.d/www.conf' else '/etc/php5/fpm/pool.d/www.conf' end end when 'Archlinux' '/etc/php/php-fpm.d/www.conf' when 'Suse' '/etc/php5/fpm/pool.d/www.conf' when 'RedHat' '/etc/php-fpm.d/www.conf' when 'FreeBSD' '/usr/local/etc/php-fpm.d/www.conf' end it { is_expected.to contain_file(dstfile).with_content(%r{group = nginx}) } end + describe 'when configured with a pool with apparmor_hat parameter' do + let(:params) { { fpm_pools: { 'www' => { 'apparmor_hat' => 'www' } } } } + + it { is_expected.to contain_php__fpm__pool('www').with(apparmor_hat: 'www') } + + dstfile = case facts[:osfamily] + when 'Debian' + case facts[:os]['name'] + when 'Debian' + case facts[:os]['release']['major'] + when '10' + '/etc/php/7.3/fpm/pool.d/www.conf' + when '9' + '/etc/php/7.0/fpm/pool.d/www.conf' + else + '/etc/php5/fpm/pool.d/www.conf' + end + when 'Ubuntu' + case facts[:os]['release']['major'] + when '18.04' + '/etc/php/7.2/fpm/pool.d/www.conf' + when '16.04' + '/etc/php/7.0/fpm/pool.d/www.conf' + else + '/etc/php5/fpm/pool.d/www.conf' + end + end + when 'Archlinux' + '/etc/php/php-fpm.d/www.conf' + when 'Suse' + '/etc/php5/fpm/pool.d/www.conf' + when 'RedHat' + '/etc/php-fpm.d/www.conf' + when 'FreeBSD' + '/usr/local/etc/php-fpm.d/www.conf' + end + + it { is_expected.to contain_file(dstfile).with_content(%r{apparmor_hat = www}) } + end + describe 'when fpm is disabled' do let(:params) { { fpm: false } } it { is_expected.not_to contain_class('php::fpm') } end describe 'when composer is disabled' do let(:params) { { composer: false } } it { is_expected.not_to contain_class('php::composer') } end if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'CentOS' describe 'when called with cli_settings parameter' do let(:params) do { 'settings' => { 'PHP/memory_limit' => '300M' }, 'cli_settings' => { 'PHP/memory_limit' => '1000M' } } end it { is_expected.to contain_php__config__setting('/etc/php.ini: PHP/memory_limit').with_value('300M') } it { is_expected.to contain_php__config__setting('/etc/php-fpm.ini: PHP/memory_limit').with_value('300M') } it { is_expected.to contain_php__config__setting('/etc/php-cli.ini: PHP/memory_limit').with_value('1000M') } end describe 'when called with global option for rhscl_mode' do describe 'when called with mode "remi"' do scl_php_version = 'php56' rhscl_mode = 'remi' let(:pre_condition) do "class {'::php::globals': php_version => '#{scl_php_version}', rhscl_mode => '#{rhscl_mode}' }" end let(:params) do { settings: { 'Date/date.timezone' => 'Europe/Berlin' } } end it { is_expected.to contain_class('php::global') } it { is_expected.to contain_package("#{scl_php_version}-php-cli").with_ensure('present') } it { is_expected.to contain_package("#{scl_php_version}-php-common").with_ensure('present') } it { is_expected.to contain_php__config('global').with(file: "/etc/opt/#{rhscl_mode}/#{scl_php_version}/php.ini") } it { is_expected.not_to contain_php__config('cli') } # see: https://github.com/voxpupuli/puppet-php/blob/master/lib/puppet/parser/functions/to_hash_settings.rb it { is_expected.to contain_php__config__setting("/etc/opt/#{rhscl_mode}/#{scl_php_version}/php.ini: Date/date.timezone").with_value('Europe/Berlin') } end describe 'when called with mode "rhscl"' do scl_php_version = 'rh-php56' rhscl_mode = 'rhscl' let(:pre_condition) do "class {'::php::globals': php_version => '#{scl_php_version}', rhscl_mode => '#{rhscl_mode}' }" end let(:params) do { settings: { 'Date/date.timezone' => 'Europe/Berlin' } } end it { is_expected.to contain_class('php::global') } it { is_expected.to contain_package("#{scl_php_version}-php-cli").with_ensure('present') } it { is_expected.to contain_package("#{scl_php_version}-php-common").with_ensure('present') } it { is_expected.to contain_php__config('global').with(file: "/etc/opt/rh/#{scl_php_version}/php.ini") } it { is_expected.to contain_php__config('cli').with(file: "/etc/opt/rh/#{scl_php_version}/php-cli.ini") } it { is_expected.to contain_php__config__setting("/etc/opt/rh/#{scl_php_version}/php.ini: Date/date.timezone").with_value('Europe/Berlin') } end end end describe 'when called with pool_purge => true and fpm_pools => {}' do let(:params) { { pool_purge: true, fpm_pools: {} } } it { is_expected.to contain_class('php::fpm').with(pool_purge: true) } it { is_expected.not_to contain_php__fpm__pool('www') } end end end end diff --git a/templates/fpm/pool.conf.erb b/templates/fpm/pool.conf.erb index 2f32be6..99981d1 100644 --- a/templates/fpm/pool.conf.erb +++ b/templates/fpm/pool.conf.erb @@ -1,379 +1,383 @@ [<%= @pool %>] ; The address on which to accept FastCGI requests. listen = <%= @listen %> ; Set listen(2) backlog. A value of '-1' means unlimited. listen.backlog = <%= @listen_backlog %> ; List of ipv4 addresses of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address ; must be separated by a comma. If this value is left blank, connections will be ; accepted from any ip address. ; Default Value: any <% if @listen_allowed_clients -%> listen.allowed_clients = <%= @listen_allowed_clients %> <% else -%> ;listen.allowed_clients = 127.0.0.1 <% end -%> ; Set permissions for unix socket, if one is used. In Linux, read/write ; permissions must be set in order to allow connections from a web server. Many ; BSD-derived systems allow connections regardless of permissions. ; Default Values: user and group are set as the running user ; mode is set to 0666 <% if @listen_owner -%> listen.owner = <%= @listen_owner %> <% else -%> ;listen.owner = nobody <% end -%> <% if @listen_group -%> listen.group = <%= @listen_group %> <% else -%> ;listen.group = nobody <% end -%> <% if @listen_mode -%> listen.mode = <%= @listen_mode %> <% else -%> ;listen.mode = 0660 <% end -%> ; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. ; RPM: apache Choosed to be able to access some dir as httpd user = <%= @user %> ; RPM: Keep a group allowed to write in log dir. group = <%= @group_final %> +<% if @apparmor_hat -%> +; Apparmor hat to change to +apparmor_hat = <%= @apparmor_hat %> +<% end -%> ; Choose how the process manager will control the number of child processes. ; Possible Values: ; static - a fixed number (pm.max_children) of child processes; ; dynamic - the number of child processes are set dynamically based on the ; following directives: ; pm.max_children - the maximum number of children that can ; be alive at the same time. ; pm.start_servers - the number of children created on startup. ; pm.min_spare_servers - the minimum number of children in 'idle' ; state (waiting to process). If the number ; of 'idle' processes is less than this ; number then some children will be created. ; pm.max_spare_servers - the maximum number of children in 'idle' ; state (waiting to process). If the number ; of 'idle' processes is greater than this ; number then some children will be killed. ; ondemand - no children are created at startup. Children will be forked when ; new requests will connect. The following parameter are used: ; pm.max_children - the maximum number of children that ; can be alive at the same time. ; pm.process_idle_timeout - The number of seconds after which ; an idle process will be killed. ; Note: This value is mandatory. pm = <%= @pm %> ; The number of child processes to be created when pm is set to 'static' and the ; maximum number of child processes to be created when pm is set to 'dynamic'. ; This value sets the limit on the number of simultaneous requests that will be ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP ; CGI. ; Note: Used when pm is set to either 'static' or 'dynamic' ; Note: This value is mandatory. pm.max_children = <%= @pm_max_children %> ; The number of child processes created on startup. ; Note: Used only when pm is set to 'dynamic' ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 pm.start_servers = <%= @pm_start_servers %> ; The desired minimum number of idle server processes. ; Note: Used only when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' pm.min_spare_servers = <%= @pm_min_spare_servers %> ; The desired maximum number of idle server processes. ; Note: Used only when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' pm.max_spare_servers = <%= @pm_max_spare_servers %> ; The number of seconds after which an idle process will be killed. ; Note: Used only when pm is set to 'ondemand' ; Default Value: 10s pm.process_idle_timeout = <%= @pm_process_idle_timeout %> ; The number of requests each child process should execute before respawning. ; This can be useful to work around memory leaks in 3rd party libraries. For ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. ; Default Value: 0 pm.max_requests = <%= @pm_max_requests %> ; The URI to view the FPM status page. If this value is not set, no URI will be ; recognized as a status page. By default, the status page shows the following ; information: ; accepted conn - the number of request accepted by the pool; ; pool - the name of the pool; ; process manager - static or dynamic; ; idle processes - the number of idle processes; ; active processes - the number of active processes; ; total processes - the number of idle + active processes. ; The values of 'idle processes', 'active processes' and 'total processes' are ; updated each second. The value of 'accepted conn' is updated in real time. ; Example output: ; accepted conn: 12073 ; pool: www ; process manager: static ; idle processes: 35 ; active processes: 65 ; total processes: 100 ; By default the status page output is formatted as text/plain. Passing either ; 'html' or 'json' as a query string will return the corresponding output ; syntax. Example: ; http://www.foo.bar/status ; http://www.foo.bar/status?json ; http://www.foo.bar/status?html ; Note: The value must start with a leading slash (/). The value can be ; anything, but it may not be a good idea to use the .php extension or it ; may conflict with a real PHP file. ; Default Value: not set <% if @pm_status_path -%> pm.status_path = <%= @pm_status_path %> <% else -%> ;pm.status_path = /status <% end -%> ; The ping URI to call the monitoring page of FPM. If this value is not set, no ; URI will be recognized as a ping page. This could be used to test from outside ; that FPM is alive and responding, or to ; - create a graph of FPM availability (rrd or such); ; - remove a server from a group if it is not responding (load balancing); ; - trigger alerts for the operating team (24/7). ; Note: The value must start with a leading slash (/). The value can be ; anything, but it may not be a good idea to use the .php extension or it ; may conflict with a real PHP file. ; Default Value: not set <% if @ping_path -%> ping.path = <%= @ping_path %> <% else -%> ;ping.path = /ping <% end -%> ; This directive may be used to customize the response of a ping request. The ; response is formatted as text/plain with a 200 response code. ; Default Value: pong ping.response = <%= @ping_response %> ; The access log file ; Default: not set <% if @access_log -%> access.log = <%= @access_log %> <% end -%> ; The access log format. ; The following syntax is allowed ; %%: the '%' character ; %C: %CPU used by the request ; it can accept the following format: ; - %{user}C for user CPU only ; - %{system}C for system CPU only ; - %{total}C for user + system CPU (default) ; %d: time taken to serve the request ; it can accept the following format: ; - %{seconds}d (default) ; - %{miliseconds}d ; - %{mili}d ; - %{microseconds}d ; - %{micro}d ; %e: an environment variable (same as $_ENV or $_SERVER) ; it must be associated with embraces to specify the name of the env ; variable. Some exemples: ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e ; %f: script filename ; %l: content-length of the request (for POST request only) ; %m: request method ; %M: peak of memory allocated by PHP ; it can accept the following format: ; - %{bytes}M (default) ; - %{kilobytes}M ; - %{kilo}M ; - %{megabytes}M ; - %{mega}M ; %n: pool name ; %o: ouput header ; it must be associated with embraces to specify the name of the header: ; - %{Content-Type}o ; - %{X-Powered-By}o ; - %{Transfert-Encoding}o ; - .... ; %p: PID of the child that serviced the request ; %P: PID of the parent of the child that serviced the request ; %q: the query string ; %Q: the '?' character if query string exists ; %r: the request URI (without the query string, see %q and %Q) ; %R: remote IP address ; %s: status (response code) ; %t: server time the request was received ; it can accept a strftime(3) format: ; %d/%b/%Y:%H:%M:%S %z (default) ; %T: time the log has been written (the request has finished) ; it can accept a strftime(3) format: ; %d/%b/%Y:%H:%M:%S %z (default) ; %u: remote user ; ; Default: "%R - %u %t \"%m %r\" %s" access.format = <%= @access_log_format %> ; The timeout for serving a single request after which the worker process will ; be killed. This option should be used when the 'max_execution_time' ini option ; does not stop script execution for some reason. A value of '0' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 request_terminate_timeout = <%= @request_terminate_timeout %> ; The timeout for serving a single request after which a PHP backtrace will be ; dumped to the 'slowlog' file. A value of '0s' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 request_slowlog_timeout = <%= @request_slowlog_timeout %> ; The log file for slow requests ; Default Value: not set ; Note: slowlog is mandatory if request_slowlog_timeout is set slowlog = <%= @slowlog %> ; Set open file descriptor rlimit. ; Default Value: system defined value <% if @rlimit_files -%> rlimit_files = <%= @rlimit_files %> <% else -%> ;rlimit_files = 1024 <% end -%> ; Set max core size rlimit. ; Possible Values: 'unlimited' or an integer greater or equal to 0 ; Default Value: system defined value <% if @rlimit_core -%> rlimit_core = <%= @rlimit_core %> <% else -%> ;rlimit_core = 0 <% end -%> ; Chroot to this directory at the start. This value must be defined as an ; absolute path. When this value is not set, chroot is not used. ; Note: chrooting is a great security feature and should be used whenever ; possible. However, all PHP paths will be relative to the chroot ; (error_log, sessions.save_path, ...). ; Default Value: not set <% if @chroot -%> chroot = <%= @chroot %> <% else -%> ;chroot = <% end -%> ; Chdir to this directory at the start. This value must be an absolute path. ; Default Value: current directory or / when chroot <% if @chdir -%> chdir = <%= @chdir %> <% else -%> ;chdir = /var/www <% end -%> ; Redirect worker stdout and stderr into main error log. If not set, stdout and ; stderr will be redirected to /dev/null according to FastCGI specs. ; Default Value: no catch_workers_output = <%= @catch_workers_output %> ; Include one or more files. If glob(3) exists, it is used to include a bunch of ; files from a glob(3) pattern. This directive can be used everywhere in the ; file. ; Relative path can also be used. They will be prefixed by: ; - the global prefix if it's been set (-p arguement) ; - /usr otherwise <% if @include -%> include=<%= @include %> <% else -%> ;include=/etc/php5/fpm/*.conf <% end -%> ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; the current environment. ; Default Value: clean env ;env[HOSTNAME] = $HOSTNAME ;env[PATH] = /usr/local/bin:/usr/bin:/bin ;env[TMP] = /tmp ;env[TMPDIR] = /tmp ;env[TEMP] = /tmp <% if @clear_env -%> <% @env.each do |var| -%> env[<%= var %>] = $<%= var %> <% end -%> <% @env_value.sort_by {|key,value| key}.each do |key,value| -%> <% if !value.empty? -%> env[<%= key %>] = '<%= value %>' <% end -%> <% end -%> <% else -%> clear_env = no <% end -%> ; Additional php.ini defines, specific to this pool of workers. These settings ; overwrite the values previously defined in the php.ini. The directives are the ; same as the PHP SAPI: ; php_value/php_flag - you can set classic ini defines which can ; be overwritten from PHP call 'ini_set'. ; php_admin_value/php_admin_flag - these directives won't be overwritten by ; PHP call 'ini_set' ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. ; Defining 'extension' will load the corresponding shared extension from ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not ; overwrite previously defined php.ini values, but will append the new value ; instead. ; Default Value: nothing is defined by default except the values in php.ini and ; specified at startup with the -d argument ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com ;php_flag[display_errors] = off ;php_admin_value[error_log] = /var/log/php-fpm/www-error.log ;php_admin_flag[log_errors] = on ;php_admin_value[memory_limit] = 32M ; ; Custom PHP values ; <% @php_value.sort_by {|key,value| key}.each do |key,value| -%> php_value[<%= key %>] = <%= value %> <% end -%> ; ; Custom PHP flags ; <% @php_flag.sort_by {|key,flag| key}.each do |key,flag| -%> php_flag[<%= key %>] = <%= flag %> <% end -%> ; ; Custom PHP admin values ; <% @php_admin_value.sort_by {|key,value| key}.each do |key,value| -%> php_admin_value[<%= key %>] = <%= value %> <% end -%> ; ; Custom PHP admin flags ; <% @php_admin_flag.sort_by {|key,flag| key}.each do |key,flag| -%> php_admin_flag[<%= key %>] = <%= flag %> <% end -%> ; ; Custom PHP directives ; <% @php_directives.each do |line| -%> <%= line.gsub "{", "%{" %> <% end -%> <% if @security_limit_extensions -%> security.limit_extensions = <%= @security_limit_extensions.join(" ") %> <% end -%>