Skip to content

Commit

Permalink
allow to pass a pid file path (voxpupuli#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcousins authored and mmoll committed Jun 20, 2016
1 parent 7d32449 commit 036c2c3
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 60 deletions.
4 changes: 2 additions & 2 deletions manifests/fpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# 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*]
# [*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.
Expand Down Expand Up @@ -55,7 +55,7 @@
$global_pool_settings = {},
$pools = { 'www' => {} },
$log_owner = $::php::params::fpm_user,
$log_group = $::php::params::fpm_group
$log_group = $::php::params::fpm_group,
) inherits ::php::params {

if $caller_module_name != $module_name {
Expand Down
121 changes: 67 additions & 54 deletions manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
# [*config_root*]
# The configuration root directory.
#
# [*fpm_pid_file*]
# Path to pid file for fpm

class php::globals (
$php_version = undef,
$config_root = undef,
$php_version = undef,
$config_root = undef,
$fpm_pid_file = undef,
) {
if $php_version != undef {
validate_re($php_version, '^[57].[0-9]')
Expand All @@ -19,6 +23,10 @@
validate_absolute_path($config_root)
}

if $fpm_pid_file != undef {
validate_absolute_path($fpm_pid_file)
}

$default_php_version = $::osfamily ? {
'Debian' => $::operatingsystem ? {
'Ubuntu' => $::operatingsystemrelease ? {
Expand All @@ -37,87 +45,92 @@
if $::operatingsystem == 'Ubuntu' {
case $globals_php_version {
/^5\.4/: {
$default_config_root = '/etc/php5'
$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-'
$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-'
}
/^5\.5/: {
$default_config_root = "/etc/php/${globals_php_version}"
$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 = 'php5.5-'
$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 = 'php5.5-'
}
/^5\.6/: {
$default_config_root = "/etc/php/${globals_php_version}"
$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 = 'php5.6-'
$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 = 'php5.6-'
}
/^7/: {
$default_config_root = "/etc/php/${globals_php_version}"
$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 = 'php7.0-'
$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 = 'php7.0-'
}
default: {
$default_config_root = "/etc/php/${globals_php_version}"
$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-'
$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-'
}
}
} else {
case $globals_php_version {
/^7/: {
$default_config_root = "/etc/php/${globals_php_version}"
$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 = 'php7.0-'
$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 = 'php7.0-'
}
default: {
$default_config_root = '/etc/php5'
$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-'
$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': {
$default_config_root = '/etc/php5'
$default_config_root = '/etc/php5'
$default_fpm_pid_file = '/var/run/php5-fpm.pid'
}
'RedHat': {
$default_config_root = '/etc/php.d'
$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_config_root = '/usr/local/etc'
$default_fpm_pid_file = '/var/run/php-fpm.pid'
}
default: {
fail("Unsupported osfamily: ${::osfamily}")
}
}

$globals_config_root = pick($config_root, $default_config_root)

$globals_fpm_pid_file = pick($fpm_pid_file, $default_fpm_pid_file)
}
8 changes: 4 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$common_package_suffixes = ['cli', 'common']
$cli_inifile = "${config_root}/cli/php.ini"
$dev_package_suffix = 'dev'
$fpm_pid_file = $php::globals::fpm_pid_file
$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"
Expand Down Expand Up @@ -64,7 +64,7 @@
$common_package_suffixes = []
$cli_inifile = "${config_root}/cli/php.ini"
$dev_package_suffix = 'devel'
$fpm_pid_file = '/var/run/php5-fpm.pid'
$fpm_pid_file = $php::globals::globals_fpm_pid_file
$fpm_config_file = "${config_root}/fpm/php-fpm.conf"
$fpm_error_log = '/var/log/php5-fpm.log'
$fpm_inifile = "${config_root}/fpm/php.ini"
Expand Down Expand Up @@ -98,7 +98,7 @@
$common_package_suffixes = ['cli', 'common']
$cli_inifile = '/etc/php-cli.ini'
$dev_package_suffix = 'devel'
$fpm_pid_file = '/var/run/php-fpm/php-fpm.pid'
$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'
Expand Down Expand Up @@ -126,7 +126,7 @@
$common_package_suffixes = ['extensions']
$cli_inifile = "${config_root}/php-cli.ini"
$dev_package_suffix = undef
$fpm_pid_file = '/var/run/php-fpm.pid'
$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"
Expand Down

0 comments on commit 036c2c3

Please sign in to comment.