Module: Puppet::Parser::Functions - - - -
--
-
- Defined in: -
- lib/puppet/parser/functions/to_hash_settings.rb,
- lib/puppet/parser/functions/ensure_prefix.rb -
-
diff --git a/docs/Puppet/Parser/Functions.html b/docs/Puppet/Parser/Functions.html deleted file mode 100644 index 54615e00..00000000 --- a/docs/Puppet/Parser/Functions.html +++ /dev/null @@ -1,105 +0,0 @@ - - -
- - -
-
-
-
|
-
-
-
-
|
-
- - - - - | -
-
-
-
|
-
-
-
-
|
-
t |
- - - -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245- |
-
- # File 'manifests/init.pp', line 115
-
-class php (
- String $ensure = $::php::params::ensure,
- Boolean $manage_repos = $::php::params::manage_repos,
- Boolean $fpm = true,
- $fpm_service_enable = $::php::params::fpm_service_enable,
- $fpm_service_ensure = $::php::params::fpm_service_ensure,
- $fpm_service_name = $::php::params::fpm_service_name,
- $fpm_service_provider = undef,
- Hash $fpm_pools = { 'www' => {} },
- Hash $fpm_global_pool_settings = {},
- $fpm_inifile = $::php::params::fpm_inifile,
- $fpm_package = undef,
- $fpm_user = $::php::params::fpm_user,
- $fpm_group = $::php::params::fpm_group,
- Boolean $embedded = false,
- Boolean $dev = true,
- Boolean $composer = true,
- Boolean $pear = true,
- String $pear_ensure = $::php::params::pear_ensure,
- Boolean $phpunit = false,
- Boolean $apache_config = false,
- $proxy_type = undef,
- $proxy_server = undef,
- Hash $extensions = {},
- Hash $settings = {},
- $package_prefix = $::php::params::package_prefix,
- Stdlib::Absolutepath $config_root_ini = $::php::params::config_root_ini,
- Stdlib::Absolutepath $config_root_inifile = $::php::params::config_root_inifile,
- Optional[Stdlib::Absolutepath] $ext_tool_enable = $::php::params::ext_tool_enable,
- Optional[Stdlib::Absolutepath] $ext_tool_query = $::php::params::ext_tool_query,
- Boolean $ext_tool_enabled = $::php::params::ext_tool_enabled,
- String $log_owner = $::php::params::fpm_user,
- String $log_group = $::php::params::fpm_group,
-) inherits ::php::params {
-
- $real_fpm_package = pick($fpm_package, "${package_prefix}${::php::params::fpm_package_suffix}")
-
- # Deep merge global php settings
- $real_settings = deep_merge($settings, hiera_hash('php::settings', {}))
-
- # Deep merge global php extensions
- $real_extensions = deep_merge($extensions, hiera_hash('php::extensions', {}))
-
- # Deep merge fpm_pools
- $real_fpm_pools = deep_merge($fpm_pools, hiera_hash('php::fpm_pools', {}))
-
- # Deep merge fpm_global_pool_settings
- $real_fpm_global_pool_settings = deep_merge($fpm_global_pool_settings, hiera_hash('php::fpm_global_pool_settings', {}))
-
- if $manage_repos {
- class { '::php::repo': }
- -> Anchor['php::begin']
- }
-
- anchor { 'php::begin': }
- -> class { '::php::packages': }
- -> class { '::php::cli':
- settings => $real_settings,
- }
- -> anchor { 'php::end': }
-
- # Configure global PHP settings in php.ini
- if $facts['os']['family'] != 'Debian' {
- Class['php::packages']
- -> class {'::php::global':
- settings => $real_settings,
- }
- -> Anchor['php::end']
- }
-
- if $fpm { contain '::php::fpm' }
- if $embedded {
- if $facts['os']['family'] == 'RedHat' and $fpm {
- # Both fpm and embeded SAPIs are using same php.ini
- fail('Enabling both cli and embedded sapis is not currently supported')
- }
-
- Anchor['php::begin']
- -> class { '::php::embedded':
- settings => $real_settings,
- }
- -> Anchor['php::end']
- }
- if $dev {
- Anchor['php::begin']
- -> class { '::php::dev': }
- -> Anchor['php::end']
- }
- if $composer {
- Anchor['php::begin']
- -> class { '::php::composer':
- proxy_type => $proxy_type,
- proxy_server => $proxy_server,
- }
- -> Anchor['php::end']
- }
- if $pear {
- Anchor['php::begin']
- -> class { '::php::pear':
- ensure => $pear_ensure,
- }
- -> Anchor['php::end']
- }
- if $phpunit {
- Anchor['php::begin']
- -> class { '::php::phpunit': }
- -> Anchor['php::end']
- }
- if $apache_config {
- Anchor['php::begin']
- -> class { '::php::apache_config':
- settings => $real_settings,
- }
- -> Anchor['php::end']
- }
-
- create_resources('::php::extension', $real_extensions, {
- require => Class['::php::cli'],
- before => Anchor['php::end']
- })
-
- # On FreeBSD purge the system-wide extensions.ini. It is going
- # to be replaced with per-module configuration files.
- if $::osfamily == 'FreeBSD' {
- # Purge the system-wide extensions.ini
- file { '/usr/local/etc/php/extensions.ini':
- ensure => absent,
- require => Class['::php::packages'],
- }
- }
-}
- |
-
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
- -
- - - -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26- |
-
- # File 'manifests/apache_config.pp', line 11
-
-class php::apache_config(
- Stdlib::Absolutepath $inifile = $::php::params::apache_inifile,
- Hash $settings = {}
-) inherits ::php::params {
-
- if $caller_module_name != $module_name {
- warning('php::apache_config is private')
- }
-
- $real_settings = deep_merge($settings, hiera_hash('php::apache::settings', {}))
-
- ::php::config { 'apache':
- file => $inifile,
- config => $real_settings,
- }
-}
- |
-
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
- -
- - - -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26- |
-
- # File 'manifests/cli.pp', line 11
-
-class php::cli(
- Stdlib::Absolutepath $inifile = $::php::params::cli_inifile,
- Hash $settings = {}
-) inherits ::php::params {
-
- if $caller_module_name != $module_name {
- warning('php::cli is private')
- }
-
- $real_settings = deep_merge($settings, hiera_hash('php::cli::settings', {}))
-
- ::php::config { 'cli':
- file => $inifile,
- config => $real_settings,
- }
-}
- |
-
Install composer package manager
- -=== Parameters
- -[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.
- -[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
- -
- - - -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61- |
-
- # File 'manifests/composer.pp', line 26
-
-class php::composer (
- String $source = $::php::params::composer_source,
- Stdlib::Absolutepath $path = $::php::params::composer_path,
- $proxy_type = undef,
- $proxy_server = undef,
- Boolean $auto_update = true,
- Integer $max_age = $::php::params::composer_max_age,
- Variant[Integer, String] $root_group = $::php::params::root_group,
-) inherits ::php::params {
-
- if $caller_module_name != $module_name {
- warning('php::composer is private')
- }
-
- archive { 'download composer':
- path => $path,
- source => $source,
- proxy_type => $proxy_type,
- proxy_server => $proxy_server,
- }
- -> file { $path:
- mode => '0555',
- owner => root,
- group => $root_group,
- }
-
- if $auto_update {
- class { '::php::composer::auto_update':
- max_age => $max_age,
- source => $source,
- path => $path,
- proxy_type => $proxy_type,
- proxy_server => $proxy_server,
- }
- }
-}
- |
-
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 - }
- -
- - - -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53- |
-
- # File 'manifests/composer/auto_update.pp', line 28
-
-class php::composer::auto_update (
- $max_age,
- $source,
- $path,
- $proxy_type = undef,
- $proxy_server = undef,
-) {
-
- if $caller_module_name != $module_name {
- warning('php::composer::auto_update is private')
- }
-
- if $proxy_type and $proxy_server {
- $env = [ 'HOME=/root', "${proxy_type}_proxy=${proxy_server}" ]
- } else {
- $env = [ 'HOME=/root' ]
- }
-
- exec { 'update composer':
- command => "${path} --no-interaction --quiet self-update",
- environment => $env,
- onlyif => "test `find '${path}' -mtime +${max_age}`",
- path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/', '/usr/local/bin', '/usr/local/sbin' ],
- require => [File[$path], Class['::php::cli']],
- }
-}
- |
-
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
- -
- - - -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43- |
-
- # File 'manifests/dev.pp', line 11
-
-class php::dev(
- String $ensure = $::php::ensure,
- String $package = "${::php::package_prefix}${::php::params::dev_package_suffix}",
-) inherits ::php::params {
-
- if $caller_module_name != $module_name {
- warning('php::dev is private')
- }
-
- # On FreeBSD there is no 'devel' package.
- $real_package = $facts['os']['family'] ? {
- 'FreeBSD' => [],
- default => $package,
- }
-
- # Default PHP come with xml module and no seperate package for it
- if $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16.04') >= 0 {
- ensure_packages(["${php::package_prefix}xml"], {
- ensure => present,
- require => Class['::apt::update'],
- })
-
- package { $real_package:
- ensure => $ensure,
- require => Class['::php::packages'],
- }
- } else {
- package { $real_package:
- ensure => $ensure,
- require => Class['::php::packages'],
- }
- }
-}
- |
-
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
- -
- - - -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47- |
-
- # File 'manifests/embedded.pp', line 17
-
-class php::embedded(
- String $ensure = $::php::ensure,
- String $package = "${::php::package_prefix}${::php::params::embedded_package_suffix}",
- Stdlib::Absolutepath $inifile = $::php::params::embedded_inifile,
- Hash $settings = {},
-) inherits ::php::params {
-
- if $caller_module_name != $module_name {
- warning('php::embedded is private')
- }
-
- $real_settings = deep_merge(
- $settings,
- hiera_hash('php::embedded::settings', {})
- )
-
- $real_package = $facts['os']['family'] ? {
- 'Debian' => "lib${package}",
- default => $package,
- }
-
- package { $real_package:
- ensure => $ensure,
- require => Class['::php::packages'],
- }
- -> ::php::config { 'embedded':
- file => $inifile,
- config => $real_settings,
- }
-
-}
- |
-
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.
- -
- - - -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121- |
-
- # File 'manifests/fpm.pp', line 52
-
-class php::fpm (
- String $ensure = $::php::ensure,
- $user = $::php::fpm_user,
- $group = $::php::fpm_group,
- $service_ensure = $::php::fpm_service_ensure,
- $service_enable = $::php::fpm_service_enable,
- $service_name = $::php::fpm_service_name,
- $service_provider = $::php::fpm_service_provider,
- String $package = $::php::real_fpm_package,
- Stdlib::Absolutepath $inifile = $::php::fpm_inifile,
- Hash $settings = $::php::real_settings,
- $global_pool_settings = $::php::real_fpm_global_pool_settings,
- Hash $pools = $::php::real_fpm_pools,
- $log_owner = $::php::log_owner,
- $log_group = $::php::log_group,
-) {
-
- if ! defined(Class['php']) {
- warning('php::fpm is private')
- }
-
- $real_settings = deep_merge($settings, hiera_hash('php::fpm::settings', {}))
-
- # 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']['family'] ? {
- 'FreeBSD' => [],
- default => $package,
- }
-
- package { $real_package:
- ensure => $ensure,
- require => Class['::php::packages'],
- }
-
- class { '::php::fpm::config':
- user => $user,
- group => $group,
- inifile => $inifile,
- settings => $real_settings,
- log_owner => $log_owner,
- log_group => $log_group,
- require => Package[$real_package],
- }
- contain '::php::fpm::config'
- contain '::php::fpm::service'
-
- Class['php::fpm::config'] ~> Class['php::fpm::service']
-
- $real_global_pool_settings = hiera_hash('php::fpm::global_pool_settings', $global_pool_settings)
- $real_pools = hiera_hash('php::fpm::pools', $pools)
- create_resources(::php::fpm::pool, $real_pools, $real_global_pool_settings)
-
- # Create an override to use a reload signal as trusty and utopic's
- # upstart version supports this
- if ($facts['os']['name'] == 'Ubuntu'
- and versioncmp($facts['os']['release']['full'], '14') >= 0
- and versioncmp($facts['os']['release']['full'], '16') < 0) {
- if ($service_enable) {
- $fpm_override = 'reload signal USR2'
- }
- else {
- $fpm_override = "reload signal USR2\nmanual"
- }
- file { "/etc/init/${::php::fpm::service::service_name}.override":
- content => $fpm_override,
- before => Package[$real_package],
- }
- }
-}
- |
-
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
- -
- - - -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134- |
-
- # File 'manifests/fpm/config.pp', line 73
-
-class php::fpm::config(
- $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,
- $pid_file = $::php::params::fpm_pid_file,
- Hash $settings = {},
- Stdlib::Absolutepath $pool_base_dir = $::php::params::fpm_pool_dir,
- $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,
- Integer $process_max = 0,
- $rlimit_files = undef,
- Optional[Variant[Integer,Pattern[/^\d+[smhd]?$/]]] $systemd_interval = undef,
- String $log_owner = $::php::params::fpm_user,
- String $log_group = $::php::params::fpm_group,
- Pattern[/^\d+$/] $log_dir_mode = '0770',
- $root_group = $::php::params::root_group,
- String $syslog_facility = 'daemon',
- String $syslog_ident = 'php-fpm',
-) inherits ::php::params {
-
- if $caller_module_name != $module_name {
- warning('php::fpm::config is private')
- }
-
- # Hack-ish to default to user for group too
- $log_group_final = $log_group ? {
- undef => $log_owner,
- default => $log_group,
- }
-
- file { $config_file:
- ensure => file,
- content => template('php/fpm/php-fpm.conf.erb'),
- owner => root,
- group => $root_group,
- mode => '0644',
- }
-
- file { $pool_base_dir:
- ensure => directory,
- owner => root,
- group => $root_group,
- mode => '0755',
- }
-
- if $pool_purge {
- File[$pool_base_dir] {
- purge => true,
- recurse => true,
- }
- }
-
- ::php::config { 'fpm':
- file => $inifile,
- config => $settings,
- }
-}
- |
-
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
- -
- - - -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50- |
-
- # File 'manifests/fpm/service.pp', line 17
-
-class php::fpm::service(
- $service_name = $::php::fpm::service_name,
- $ensure = $::php::fpm::service_ensure,
- $enable = $::php::fpm::service_enable,
- $provider = $::php::fpm::service_provider,
-) {
-
- if ! defined(Class['php::fpm']) {
- warning('php::fpm::service is private')
- }
-
- $reload = "service ${service_name} reload"
-
- if ($facts['os']['name'] == 'Ubuntu'
- and versioncmp($facts['os']['release']['full'], '12') >= 0
- and versioncmp($facts['os']['release']['full'], '14') < 0) {
- # Precise upstart doesn't support reload signals, so use
- # regular service restart instead
- $restart = undef
- } else {
- $restart = $reload
- }
-
- service { $service_name:
- ensure => $ensure,
- enable => $enable,
- provider => $provider,
- hasrestart => true,
- restart => $restart,
- hasstatus => true,
- }
-
- ::Php::Extension <| |> ~> Service[$service_name]
-}
- |
-
- - - -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30- |
-
- # File 'manifests/global.pp', line 14
-
-class php::global(
- Stdlib::Absolutepath $inifile = $::php::config_root_inifile,
- Hash $settings = {}
-) inherits ::php {
-
- if $caller_module_name != $module_name {
- warning('php::global is private')
- }
-
- # No deep merging required since the settings we have are the global settings.
- $real_settings = $settings
-
- ::php::config { 'global':
- file => $inifile,
- config => $real_settings,
- }
-}
- |
-
- - - -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126- |
-
- # File 'manifests/globals.pp', line 14
-
-class php::globals (
- Optional[Pattern[/^[57].[0-9]/]] $php_version = undef,
- Optional[Stdlib::Absolutepath] $config_root = undef,
- Optional[Stdlib::Absolutepath] $fpm_pid_file = undef,
-) {
-
- $default_php_version = $facts['os']['family'] ? {
- 'Debian' => $facts['os']['name'] ? {
- 'Ubuntu' => $facts['os']['release']['full'] ? {
- /^(1[67].04)$/ => '7.0',
- default => '5.x',
- },
- default => '5.x',
- },
- default => '5.x',
- }
-
- $globals_php_version = pick($php_version, $default_php_version)
-
- case $facts['os']['family'] {
- 'Debian': {
- if $facts['os']['name'] == 'Ubuntu' {
- case $globals_php_version {
- /^5\.4/: {
- $default_config_root = '/etc/php5'
- $default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid"
- $fpm_error_log = '/var/log/php5-fpm.log'
- $fpm_service_name = 'php5-fpm'
- $ext_tool_enable = '/usr/sbin/php5enmod'
- $ext_tool_query = '/usr/sbin/php5query'
- $package_prefix = 'php5-'
- }
- /^[57].[0-9]/: {
- $default_config_root = "/etc/php/${globals_php_version}"
- $default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid"
- $fpm_error_log = "/var/log/php${globals_php_version}-fpm.log"
- $fpm_service_name = "php${globals_php_version}-fpm"
- $ext_tool_enable = "/usr/sbin/phpenmod -v ${globals_php_version}"
- $ext_tool_query = "/usr/sbin/phpquery -v ${globals_php_version}"
- $package_prefix = "php${globals_php_version}-"
- }
- default: {
- # Default php installation from Ubuntu official repository use the following paths until 16.04
- # For PPA please use the $php_version to override it.
- $default_config_root = '/etc/php5'
- $default_fpm_pid_file = '/var/run/php5-fpm.pid'
- $fpm_error_log = '/var/log/php5-fpm.log'
- $fpm_service_name = 'php5-fpm'
- $ext_tool_enable = '/usr/sbin/php5enmod'
- $ext_tool_query = '/usr/sbin/php5query'
- $package_prefix = 'php5-'
- }
- }
- } else {
- case $globals_php_version {
- /^7/: {
- $default_config_root = "/etc/php/${globals_php_version}"
- $default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid"
- $fpm_error_log = "/var/log/php${globals_php_version}-fpm.log"
- $fpm_service_name = "php${globals_php_version}-fpm"
- $ext_tool_enable = "/usr/sbin/phpenmod -v ${globals_php_version}"
- $ext_tool_query = "/usr/sbin/phpquery -v ${globals_php_version}"
- $package_prefix = "php${globals_php_version}-"
- }
- default: {
- $default_config_root = '/etc/php5'
- $default_fpm_pid_file = '/var/run/php5-fpm.pid'
- $fpm_error_log = '/var/log/php5-fpm.log'
- $fpm_service_name = 'php5-fpm'
- $ext_tool_enable = '/usr/sbin/php5enmod'
- $ext_tool_query = '/usr/sbin/php5query'
- $package_prefix = 'php5-'
- }
- }
- }
- }
- 'Suse': {
- case $globals_php_version {
- /^7/: {
- $default_config_root = '/etc/php7'
- $package_prefix = 'php7-'
- $default_fpm_pid_file = '/var/run/php7-fpm.pid'
- $fpm_error_log = '/var/log/php7-fpm.log'
- }
- default: {
- $default_config_root = '/etc/php5'
- $package_prefix = 'php5-'
- $default_fpm_pid_file = '/var/run/php5-fpm.pid'
- $fpm_error_log = '/var/log/php5-fpm.log'
- }
- }
- }
- 'RedHat': {
- $default_config_root = '/etc/php.d'
- $default_fpm_pid_file = '/var/run/php-fpm/php-fpm.pid'
- }
- 'FreeBSD': {
- $default_config_root = '/usr/local/etc'
- $default_fpm_pid_file = '/var/run/php-fpm.pid'
- }
- 'Archlinux': {
- $default_config_root = '/etc/php'
- $default_fpm_pid_file = '/run/php-fpm/php-fpm.pid'
- }
- default: {
- fail("Unsupported osfamily: ${facts['os']['family']}")
- }
- }
-
- $globals_config_root = pick($config_root, $default_config_root)
-
- $globals_fpm_pid_file = pick($fpm_pid_file, $default_fpm_pid_file)
-}
- |
-
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
- - - -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40- |
-
- # File 'manifests/packages.pp', line 15
-
-class php::packages (
- String $ensure = $::php::ensure,
- Boolean $manage_repos = $::php::manage_repos,
- Array $names_to_prefix = prefix($::php::params::common_package_suffixes, $::php::package_prefix),
- Array $names = $::php::params::common_package_names,
-) inherits ::php::params {
-
- if $caller_module_name != $module_name {
- warning('php::packages is private')
- }
-
- $real_names = union($names, $names_to_prefix)
- if $facts['os']['family'] == 'debian' {
- if $manage_repos {
- include ::apt
- Class['::apt::update'] -> Package[$real_names]
- }
- package { $real_names:
- ensure => $ensure,
- }
- } else {
- package { $real_names:
- ensure => $ensure,
- }
- }
-}
- |
-
PHP params class
- -
- - - -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191- |
-
- # File 'manifests/params.pp', line 3
-
-class php::params inherits php::globals {
-
- $ensure = 'present'
- $fpm_service_enable = true
- $fpm_service_ensure = 'running'
- $composer_source = 'https://getcomposer.org/composer.phar'
- $composer_path = '/usr/local/bin/composer'
- $composer_max_age = 30
- $pear_ensure = 'present'
- $pear_package_suffix = 'pear'
- $phpunit_source = 'https://phar.phpunit.de/phpunit.phar'
- $phpunit_path = '/usr/local/bin/phpunit'
- $phpunit_max_age = 30
-
- case $facts['os']['family'] {
- 'Debian': {
- $config_root = $php::globals::globals_config_root
- $config_root_ini = "${config_root}/mods-available"
- $config_root_inifile = "${config_root}/php.ini"
- $common_package_names = []
- $common_package_suffixes = ['cli', 'common']
- $cli_inifile = "${config_root}/cli/php.ini"
- $dev_package_suffix = 'dev'
- $fpm_pid_file = $php::globals::globals_fpm_pid_file
- $fpm_config_file = "${config_root}/fpm/php-fpm.conf"
- $fpm_error_log = $php::globals::fpm_error_log
- $fpm_inifile = "${config_root}/fpm/php.ini"
- $fpm_package_suffix = 'fpm'
- $fpm_pool_dir = "${config_root}/fpm/pool.d"
- $fpm_service_name = $php::globals::fpm_service_name
- $fpm_user = 'www-data'
- $fpm_group = 'www-data'
- $apache_inifile = "${config_root}/apache2/php.ini"
- $embedded_package_suffix = 'embed'
- $embedded_inifile = "${config_root}/embed/php.ini"
- $package_prefix = $php::globals::package_prefix
- $compiler_packages = 'build-essential'
- $root_group = 'root'
- $ext_tool_enable = $php::globals::ext_tool_enable
- $ext_tool_query = $php::globals::ext_tool_query
- $ext_tool_enabled = true
-
- case $facts['os']['name'] {
- 'Debian': {
- $manage_repos = (versioncmp($facts['os']['release']['major'], '8') < 0)
- }
-
- 'Ubuntu': {
- $manage_repos = false
- }
-
- default: {
- $manage_repos = false
- }
- }
- }
-
- 'Suse': {
- if ($php::globals::php_version != undef) {
- $php_version_major = regsubst($php::globals::php_version, '^(\d+)\.(\d+)$','\1')
- } else {
- $php_version_major = 5
- }
-
- $config_root = $php::globals::globals_config_root
- $config_root_ini = "${config_root}/conf.d"
- $config_root_inifile = "${config_root}/php.ini"
- $common_package_names = ["php${php_version_major}"]
- $common_package_suffixes = []
- $cli_inifile = "${config_root}/cli/php.ini"
- $dev_package_suffix = 'devel'
- $fpm_pid_file = $php::globals::globals_fpm_pid_file
- $fpm_config_file = "${config_root}/fpm/php-fpm.conf"
- $fpm_error_log = $php::globals::fpm_error_log
- $fpm_inifile = "${config_root}/fpm/php.ini"
- $fpm_package_suffix = 'fpm'
- $fpm_pool_dir = "${config_root}/fpm/pool.d"
- $fpm_service_name = 'php-fpm'
- $fpm_user = 'wwwrun'
- $fpm_group = 'www'
- $embedded_package_suffix = 'embed'
- $embedded_inifile = "${config_root}/embed/php.ini"
- $package_prefix = $php::globals::package_prefix
- $manage_repos = true
- $root_group = 'root'
- $ext_tool_enable = undef
- $ext_tool_query = undef
- $ext_tool_enabled = false
- case $facts['os']['name'] {
- 'SLES': {
- $compiler_packages = []
- }
- 'OpenSuSE': {
- $compiler_packages = 'devel_basis'
- }
- default: {
- fail("Unsupported operating system ${facts['os']['name']}")
- }
- }
- }
- 'RedHat': {
- $config_root_ini = '/etc/php.d'
- $config_root_inifile = '/etc/php.ini'
- $common_package_names = []
- $common_package_suffixes = ['cli', 'common']
- $cli_inifile = '/etc/php-cli.ini'
- $dev_package_suffix = 'devel'
- $fpm_pid_file = $php::globals::globals_fpm_pid_file
- $fpm_config_file = '/etc/php-fpm.conf'
- $fpm_error_log = '/var/log/php-fpm/error.log'
- $fpm_inifile = '/etc/php-fpm.ini'
- $fpm_package_suffix = 'fpm'
- $fpm_pool_dir = '/etc/php-fpm.d'
- $fpm_service_name = 'php-fpm'
- $fpm_user = 'apache'
- $fpm_group = 'apache'
- $apache_inifile = '/etc/php.ini'
- $embedded_package_suffix = 'embedded'
- $embedded_inifile = '/etc/php.ini'
- $package_prefix = 'php-'
- $compiler_packages = ['gcc', 'gcc-c++', 'make']
- $manage_repos = false
- $root_group = 'root'
- $ext_tool_enable = undef
- $ext_tool_query = undef
- $ext_tool_enabled = false
- }
- 'FreeBSD': {
- $config_root = $php::globals::globals_config_root
- $config_root_ini = "${config_root}/php"
- $config_root_inifile = "${config_root}/php.ini"
- # No common packages, because the required PHP base package will be
- # pulled in as a dependency. This preserves the ability to choose
- # any available PHP version by setting the 'package_prefix' parameter.
- $common_package_names = []
- $common_package_suffixes = ['extensions']
- $cli_inifile = "${config_root}/php-cli.ini"
- $dev_package_suffix = undef
- $fpm_pid_file = $php::globals::globals_fpm_pid_file
- $fpm_config_file = "${config_root}/php-fpm.conf"
- $fpm_error_log = '/var/log/php-fpm.log'
- $fpm_inifile = "${config_root}/php-fpm.ini"
- $fpm_package_suffix = undef
- $fpm_pool_dir = "${config_root}/php-fpm.d"
- $fpm_service_name = 'php-fpm'
- $fpm_user = 'www'
- $fpm_group = 'www'
- $embedded_package_suffix = 'embed'
- $embedded_inifile = "${config_root}/php-embed.ini"
- $package_prefix = 'php56-'
- $compiler_packages = ['gcc']
- $manage_repos = false
- $root_group = 'wheel'
- $ext_tool_enable = undef
- $ext_tool_query = undef
- $ext_tool_enabled = false
- }
- 'Archlinux': {
- $config_root_ini = '/etc/php/conf.d'
- $config_root_inifile = '/etc/php/php.ini'
- $common_package_names = []
- $common_package_suffixes = ['cli', 'common']
- $cli_inifile = '/etc/php/php.ini'
- $dev_package_suffix = undef
- $fpm_pid_file = '/run/php-fpm/php-fpm.pid'
- $fpm_config_file = '/etc/php/php-fpm.conf'
- $fpm_error_log = '/var/log/php-fpm/error.log'
- $fpm_inifile = '/etc/php/php.ini'
- $fpm_package_suffix = 'fpm'
- $fpm_pool_dir = '/etc/php/php-fpm.d'
- $fpm_service_name = 'php-fpm'
- $fpm_user = 'root'
- $fpm_group = 'root'
- $apache_inifile = '/etc/php/php.ini'
- $embedded_package_suffix = 'embedded'
- $embedded_inifile = '/etc/php/php.ini'
- $package_prefix = 'php-'
- $compiler_packages = ['gcc', 'make']
- $manage_repos = false
- $root_group = 'root'
- $ext_tool_enable = undef
- $ext_tool_query = undef
- $ext_tool_enabled = false
- }
- default: {
- fail("Unsupported osfamily: ${facts['os']['family']}")
- }
- }
-}
- |
-
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
- -
- - - -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64- |
-
- # File 'manifests/pear.pp', line 11
-
-class php::pear (
- String $ensure = $::php::pear_ensure,
- Optional[String] $package = undef,
-) inherits ::php::params {
-
- if $caller_module_name != $module_name {
- warning('php::pear is private')
- }
-
- # Defaults for the pear package name
- if $package {
- $package_name = $package
- } else {
- case $facts['os']['family'] {
- 'Debian': {
- # Debian is a litte stupid: The pear package is called 'php-pear'
- # even though others are called 'php5-fpm' or 'php5-dev'
- $package_name = "php-${::php::params::pear_package_suffix}"
- }
- 'Amazon': {
- # On Amazon Linux the package name is also just 'php-pear'.
- # This would normally not be problematic but if you specify a
- # package_prefix other than 'php' then it will fail.
- $package_name = "php-${::php::params::pear_package_suffix}"
- }
- 'FreeBSD': {
- # On FreeBSD the package name is just 'pear'.
- $package_name = $::php::params::pear_package_suffix
- }
- default: {
- # This is the default for all other architectures
- $package_name = "${::php::package_prefix}${::php::params::pear_package_suffix}"
- }
- }
- }
-
- # Default PHP come with xml module and no seperate package for it
- if $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16.04') >= 0 {
- ensure_packages(["${php::package_prefix}xml"], {
- ensure => present,
- require => Class['::apt::update'],
- })
-
- package { $package_name:
- ensure => $ensure,
- require => [Class['::apt::update'],Class['::php::cli'],Package["${php::package_prefix}xml"]],
- }
- } else {
- package { $package_name:
- ensure => $ensure,
- require => Class['::php::cli'],
- }
- }
-}
- |
-
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
- -
- - - -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49- |
-
- # File 'manifests/phpunit.pp', line 17
-
-class php::phpunit (
- String $source = $::php::params::phpunit_source,
- Stdlib::Absolutepath $path = $::php::params::phpunit_path,
- Boolean $auto_update = true,
- Integer $max_age = $::php::params::phpunit_max_age,
-) inherits ::php::params {
-
- if $caller_module_name != $module_name {
- warning('php::phpunit is private')
- }
-
- ensure_packages(['wget'])
-
- exec { 'download phpunit':
- command => "wget ${source} -O ${path}",
- creates => $path,
- path => ['/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/'],
- require => [Class['::php::cli'],Package['wget']],
- }
- -> file { $path:
- mode => '0555',
- owner => root,
- group => root,
- }
-
- if $auto_update {
- class { '::php::phpunit::auto_update':
- max_age => $max_age,
- source => $source,
- path => $path,
- }
- }
-}
- |
-
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
- -
- - - -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30- |
-
- # File 'manifests/phpunit/auto_update.pp', line 14
-
-class php::phpunit::auto_update (
- $max_age,
- $source,
- $path,
-) {
-
- if $caller_module_name != $module_name {
- warning('php::phpunit::auto_update is private')
- }
-
- exec { 'update phpunit':
- command => "wget ${source} -O ${path}",
- onlyif => "test `find '${path}' -mtime +${max_age}`",
- path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ],
- require => File[$path],
- }
-}
- |
-
Configure package repository
- -
- - - -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33- |
-
- # File 'manifests/repo.pp', line 3
-
-class php::repo {
-
- $msg_no_repo = "No repo available for ${facts['os']['family']}/${facts['os']['name']}"
-
- case $facts['os']['family'] {
- 'Debian': {
- # no contain here because apt does that already
- case $facts['os']['name'] {
- 'Debian': {
- include ::php::repo::debian
- }
- 'Ubuntu': {
- include ::php::repo::ubuntu
- }
- default: {
- fail($msg_no_repo)
- }
- }
- }
- 'FreeBSD': {}
- 'Suse': {
- contain ::php::repo::suse
- }
- 'RedHat': {
- contain '::php::repo::redhat'
- }
- default: {
- fail($msg_no_repo)
- }
- }
-}
- |
-
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
- -
- - - -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72- |
-
- # File 'manifests/repo/debian.pp', line 23
-
-class php::repo::debian(
- $location = 'http://packages.dotdeb.org',
- $release = 'wheezy-php56',
- $repos = 'all',
- $include_src = false,
- $key = {
- 'id' => '6572BBEF1B5FF28B28B706837E3F070089DF5277',
- 'source' => 'http://www.dotdeb.org/dotdeb.gpg',
- },
- $dotdeb = true,
-) {
-
- if $caller_module_name != $module_name {
- warning('php::repo::debian is private')
- }
-
- include '::apt'
-
- create_resources(::apt::key, { 'php::repo::debian' => {
- id => $key['id'],
- source => $key['source'],
- }})
-
- ::apt::source { "source_php_${release}":
- location => $location,
- release => $release,
- repos => $repos,
- include => {
- 'src' => $include_src,
- 'deb' => true,
- },
- require => Apt::Key['php::repo::debian'],
- }
-
- if ($dotdeb) {
- # both repositories are required to work correctly
- # See: http://www.dotdeb.org/instructions/
- if $release == 'wheezy-php56' {
- ::apt::source { 'dotdeb-wheezy':
- location => $location,
- release => 'wheezy',
- repos => $repos,
- include => {
- 'src' => $include_src,
- 'deb' => true,
- },
- }
- }
- }
-}
- |
-
- - - -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35- |
-
- # File 'manifests/repo/redhat.pp', line 9
-
-class php::repo::redhat (
- $yum_repo = 'remi_php56',
-) {
-
- $releasever = $facts['os']['name'] ? {
- /(?i:Amazon)/ => '6',
- default => '$releasever', # Yum var
- }
-
- yumrepo { 'remi':
- descr => 'Remi\'s RPM repository for Enterprise Linux $releasever - $basearch',
- mirrorlist => "https://rpms.remirepo.net/enterprise/${releasever}/remi/mirror",
- enabled => 1,
- gpgcheck => 1,
- gpgkey => 'https://rpms.remirepo.net/RPM-GPG-KEY-remi',
- priority => 1,
- }
-
- yumrepo { 'remi-php56':
- descr => 'Remi\'s PHP 5.6 RPM repository for Enterprise Linux $releasever - $basearch',
- mirrorlist => "https://rpms.remirepo.net/enterprise/${releasever}/php56/mirror",
- enabled => 1,
- gpgcheck => 1,
- gpgkey => 'https://rpms.remirepo.net/RPM-GPG-KEY-remi',
- priority => 1,
- }
-}
- |
-
Configure suse repo
- -=== Parameters
- -[reponame] - Name of the Zypper repository
- -[baseurl] - Base URL of the Zypper repository
- -
- - - -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25- |
-
- # File 'manifests/repo/suse.pp', line 11
-
-class php::repo::suse (
- $reponame = 'mayflower-php56',
- $baseurl = 'http://download.opensuse.org/repositories/home:/mayflower:/php5.6_based/SLE_11_SP3/',
-) {
- zypprepo { $reponame:
- baseurl => $baseurl,
- enabled => 1,
- autorefresh => 1,
- }
- ~> exec { 'zypprepo-accept-key':
- command => 'zypper --gpg-auto-import-keys update -y',
- path => '/usr/bin:/bin',
- refreshonly => true,
- }
-}
- |
-
Configure ubuntu ppa
- -=== Parameters
- -[version] - PHP version to manage (e.g. 5.6)
- -
- - - -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31- |
-
- # File 'manifests/repo/ubuntu.pp', line 8
-
-class php::repo::ubuntu (
- $version = undef,
-) {
- include '::apt'
-
- if($version == undef) {
- $version_real = '5.6'
- } else {
- $version_real = $version
- }
-
- if ($version_real == '5.5') {
- fail('PHP 5.5 is no longer available for download')
- }
- assert_type(Pattern[/^\d\.\d/], $version_real)
-
- $version_repo = $version_real ? {
- '5.4' => 'ondrej/php5-oldstable',
- '5.6' => 'ondrej/php',
- '7.0' => 'ondrej/php'
- }
-
- ::apt::ppa { "ppa:${version_repo}": }
-}
- |
-
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
- -
- - - -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35- |
-
- # File 'manifests/apache_vhost.pp', line 20
-
-define php::apache_vhost(
- $vhost = 'example.com',
- $docroot = '/var/www',
- $port = 80,
- $default_vhost = true,
- $fastcgi_socket = 'fcgi://127.0.0.1:9000/$1'
-) {
-
- ::apache::vhost { $vhost:
- docroot => $docroot,
- default_vhost => $default_vhost,
- port => $port,
- override => 'all',
- custom_fragment => "ProxyPassMatch ^/(.*\\.php(/.*)?)$ ${fastcgi_socket}",
- }
-}
- |
-
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 => { - => 'Europe/Berlin' - } - }
- -
- - - -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32- |
-
- # File 'manifests/config.pp', line 20
-
-define php::config(
- Stdlib::Absolutepath $file,
- Hash $config
-) {
-
- if $caller_module_name != $module_name {
- warning('php::config is private')
- }
-
- create_resources(::php::config::setting, to_hash_settings($config, $file), {
- file => $file
- })
-}
- |
-
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' - }
- -
- - - -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53- |
-
- # File 'manifests/config/setting.pp', line 21
-
-define php::config::setting(
- $key,
- $value,
- Stdlib::Absolutepath $file,
-) {
-
- if $caller_module_name != $module_name {
- warning('php::config::setting is private')
- }
-
- $split_name = split($key, '/')
- if count($split_name) == 1 {
- $section = '' # lint:ignore:empty_string_assignment
- $setting = $split_name[0]
- } else {
- $section = $split_name[0]
- $setting = $split_name[1]
- }
-
- if $value == undef {
- $ensure = 'absent'
- } else {
- $ensure = 'present'
- }
-
- ini_setting { $name:
- ensure => $ensure,
- value => $value,
- path => $file,
- section => $section,
- setting => $setting,
- }
-}
- |
-
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] - 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.
- -[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.
- -
- - - -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109- |
-
- # File 'manifests/extension.pp', line 61
-
-define php::extension (
- String $ensure = 'installed',
- Optional[Php::Provider] $provider = undef,
- Optional[String] $source = undef,
- Optional[String] $so_name = downcase($name),
- Optional[String] $ini_prefix = undef,
- Optional[String] $php_api_version = undef,
- String $package_prefix = $::php::package_prefix,
- Boolean $zend = false,
- Hash $settings = {},
- Php::Sapi $sapi = 'ALL',
- Variant[Boolean, String] $settings_prefix = false,
- Optional[Stdlib::AbsolutePath] $responsefile = undef,
- Variant[String, Array[String]] $header_packages = [],
- Variant[String, Array[String]] $compiler_packages = $::php::params::compiler_packages,
- Php::InstallOptions $install_options = undef,
-) {
-
- if ! defined(Class['php']) {
- warning('php::extension is private')
- }
-
- php::extension::install { $title:
- ensure => $ensure,
- provider => $provider,
- source => $source,
- responsefile => $responsefile,
- package_prefix => $package_prefix,
- header_packages => $header_packages,
- compiler_packages => $compiler_packages,
- install_options => $install_options,
- }
-
- # PEAR packages don't require any further configuration, they just need to "be there".
- if $provider != 'pear' {
- php::extension::config { $title:
- ensure => $ensure,
- provider => $provider,
- so_name => $so_name,
- ini_prefix => $ini_prefix,
- php_api_version => $php_api_version,
- zend => $zend,
- settings => $settings,
- settings_prefix => $settings_prefix,
- sapi => $sapi,
- subscribe => Php::Extension::Install[$title],
- }
- }
-}
- |
-
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.
- -
- - - -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120- |
-
- # File 'manifests/extension/config.pp', line 47
-
-define php::extension::config (
- String $ensure = 'installed',
- Optional[Php::Provider] $provider = undef,
- Optional[String] $so_name = downcase($name),
- Optional[String] $ini_prefix = undef,
- Optional[String] $php_api_version = undef,
- Boolean $zend = false,
- Hash $settings = {},
- Variant[Boolean, String] $settings_prefix = false,
- Php::Sapi $sapi = 'ALL',
-) {
-
- if ! defined(Class['php']) {
- warning('php::extension::config is private')
- }
-
- if $zend == true {
- $extension_key = 'zend_extension'
- $module_path = $php_api_version? {
- undef => undef,
- default => "/usr/lib/php5/${php_api_version}/",
- }
- } else {
- $extension_key = 'extension'
- $module_path = undef
- }
-
- $ini_name = downcase($so_name)
-
- # Ensure "<extension>." prefix is present in setting keys if requested
- $full_settings = $settings_prefix? {
- true => ensure_prefix($settings, "${so_name}."),
- false => $settings,
- String => ensure_prefix($settings, "${settings_prefix}."),
- }
-
- if $provider != 'pear' {
- $final_settings = deep_merge(
- {"${extension_key}" => "${module_path}${so_name}.so"},
- $full_settings
- )
- } else {
- $final_settings = $full_settings
- }
-
- $config_root_ini = pick_default($::php::config_root_ini, $::php::params::config_root_ini)
- ::php::config { $title:
- file => "${config_root_ini}/${ini_prefix}${ini_name}.ini",
- config => $final_settings,
- }
-
- # Ubuntu/Debian systems use the mods-available folder. We need to enable
- # settings files ourselves with php5enmod command.
- $ext_tool_enable = pick_default($::php::ext_tool_enable, $::php::params::ext_tool_enable)
- $ext_tool_query = pick_default($::php::ext_tool_query, $::php::params::ext_tool_query)
- $ext_tool_enabled = pick_default($::php::ext_tool_enabled, $::php::params::ext_tool_enabled)
-
- if $facts['os']['family'] == 'Debian' and $ext_tool_enabled {
- $cmd = "${ext_tool_enable} -s ${sapi} ${so_name}"
-
- $_sapi = $sapi? {
- 'ALL' => 'cli',
- default => $sapi,
- }
- exec { $cmd:
- onlyif => "${ext_tool_query} -s ${_sapi} -m ${so_name} | /bin/grep 'No module matches ${so_name}'",
- require => ::Php::Config[$title],
- }
-
- if $::php::fpm {
- Package[$::php::fpm::package] ~> Exec[$cmd]
- }
- }
-}
- |
-
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.
- -
- - - -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90- |
-
- # File 'manifests/extension/install.pp', line 36
-
-define php::extension::install (
- String $ensure = 'installed',
- Optional[Php::Provider] $provider = undef,
- Optional[String] $source = undef,
- String $package_prefix = $::php::package_prefix,
- Optional[Stdlib::AbsolutePath] $responsefile = undef,
- Variant[String, Array[String]] $header_packages = [],
- Variant[String, Array[String]] $compiler_packages = $::php::params::compiler_packages,
- Php::InstallOptions $install_options = undef,
-) {
-
- if ! defined(Class['php']) {
- warning('php::extension::install is private')
- }
-
- case $provider {
- /pecl|pear/: {
- $real_package = $title
-
- unless empty($header_packages) {
- ensure_resource('package', $header_packages)
- Package[$header_packages] -> Package[$real_package]
- }
- unless empty($compiler_packages) {
- ensure_resource('package', $compiler_packages)
- Package[$compiler_packages] -> Package[$real_package]
- }
-
- $package_require = [
- Class['::php::pear'],
- Class['::php::dev'],
- ]
- }
-
- 'none' : {
- debug("No package installed for php::extension: `${title}`.")
- }
-
- default: {
- $real_package = "${package_prefix}${title}"
- $package_require = undef
- }
- }
-
- unless $provider == 'none' {
- package { $real_package:
- ensure => $ensure,
- provider => $provider,
- source => $source,
- responsefile => $responsefile,
- install_options => $install_options,
- require => $package_require,
- }
- }
-}
- |
-
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
- -[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'
- -
- - - -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199- |
-
- # File 'manifests/fpm/pool.pp', line 117
-
-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,
- $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 = {},
- $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 => '0644',
- }
- }
-}
- |
-
This function ensures a prefix for all elements in an array or the keys in a hash.
- -Examples:
- -ensure_prefix(=> 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']
- -
- - - -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56- |
-
- # File 'lib/puppet/parser/functions/ensure_prefix.rb', line 3 - -newfunction(:ensure_prefix, type: :rvalue, doc: <<-EOS - 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'] -EOS - ) do |arguments| - if arguments.size < 2 - raise(Puppet::ParseError, 'ensure_prefix(): Wrong number of arguments ' \ - "given (#{arguments.size} for 2)") - end - - enumerable = arguments[0] - - unless enumerable.is_a?(Array) || enumerable.is_a?(Hash) - raise Puppet::ParseError, "ensure_prefix(): expected first argument to be an Array or a Hash, got #{enumerable.inspect}" - end - - prefix = arguments[1] if arguments[1] - - if prefix - unless prefix.is_a?(String) - raise Puppet::ParseError, "ensure_prefix(): expected second argument to be a String, got #{prefix.inspect}" - end - end - - result = if enumerable.is_a?(Array) - # Turn everything into string same as join would do ... - enumerable.map do |i| - i = i.to_s - prefix && !i.start_with?(prefix) ? prefix + i : i - end - else - Hash[enumerable.map do |k, v| - k = k.to_s - [prefix && !k.start_with?(prefix) ? prefix + k : k, v] - end] - end - - return result -end- |
-
This function converts a +=> 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(=> 1, 'b' => 2)
- -Would return: - { - 'a' => => 'a', 'value' => 1, - 'b' => => 'b', 'value' => 2 - }
- -and:
- -to_hash_settings(=> 1, 'b' => 2, 'foo')
- -Would return: - { - 'foo: a' => => 'a', 'value' => 1, - 'foo: b' => => 'b', 'value' => 2 - }
- -
- - - -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36- |
-
- # File 'lib/puppet/parser/functions/to_hash_settings.rb', line 3 - -newfunction(:to_hash_settings, type: :rvalue, doc: <<-EOS - 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} - } -EOS - ) do |arguments| - hash, id = arguments - id = (id.nil? ? '' : "#{id}: ") - - raise(Puppet::ParseError, 'to_hash_settings(): Requires hash to work with') unless hash.is_a?(Hash) - - return hash.each_with_object({}) do |kv, acc| - acc[id + kv[0]] = { 'key' => kv[0], 'value' => kv[1] } - end -end- |
-
Package management via pear
.
Package management via pecl
.