Skip to content

Commit 2a6184c

Browse files
author
Federico Fapitalle
committed
Adds config file validation for fpm service
Defines validation command for fpm service configuration files, and sets it as a requirement.
1 parent eb304ad commit 2a6184c

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

manifests/fpm/config.pp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,12 @@
104104
}
105105

106106
file { $config_file:
107-
ensure => file,
108-
content => template('php/fpm/php-fpm.conf.erb'),
109-
owner => root,
110-
group => $root_group,
111-
mode => '0644',
107+
ensure => file,
108+
content => template('php/fpm/php-fpm.conf.erb'),
109+
owner => root,
110+
group => $root_group,
111+
mode => '0644',
112+
validate_cmd => $php::globals::fpm_checkconf_cmd,
112113
}
113114

114115
ensure_resource('file', ['/var/run/php-fpm/', '/var/log/php-fpm/'], {

manifests/fpm/pool.pp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,14 @@
191191
}
192192
} else {
193193
file { "${pool_base_dir}/${pool}.conf":
194-
ensure => file,
195-
notify => Class['::php::fpm::service'],
196-
require => Package[$real_package],
197-
content => template($template),
198-
owner => root,
199-
group => $root_group,
200-
mode => '0640',
194+
ensure => file,
195+
notify => Class['::php::fpm::service'],
196+
require => Package[$real_package],
197+
content => template($template),
198+
owner => root,
199+
group => $root_group,
200+
mode => '0640',
201+
validate_cmd => $php::globals::fpm_checkconf_cmd,
201202
}
202203
}
203204
}

manifests/globals.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
$default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid"
5252
$fpm_error_log = '/var/log/php5-fpm.log'
5353
$fpm_service_name = 'php5-fpm'
54+
$fpm_checkconf_cmd = '/usr/sbin/php5-fpm -t --fpm-config %'
5455
$ext_tool_enable = '/usr/sbin/php5enmod'
5556
$ext_tool_query = '/usr/sbin/php5query'
5657
$package_prefix = 'php5-'
@@ -60,6 +61,7 @@
6061
$default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid"
6162
$fpm_error_log = "/var/log/php${globals_php_version}-fpm.log"
6263
$fpm_service_name = "php${globals_php_version}-fpm"
64+
$fpm_checkconf_cmd = "/usr/sbin/php-fpm${globals_php_version} -t --fpm-config %"
6365
$ext_tool_enable = "/usr/sbin/phpenmod -v ${globals_php_version}"
6466
$ext_tool_query = "/usr/sbin/phpquery -v ${globals_php_version}"
6567
$package_prefix = "php${globals_php_version}-"
@@ -71,6 +73,7 @@
7173
$default_fpm_pid_file = '/var/run/php5-fpm.pid'
7274
$fpm_error_log = '/var/log/php5-fpm.log'
7375
$fpm_service_name = 'php5-fpm'
76+
$fpm_checkconf_cmd = '/usr/sbin/php5-fpm -t --fpm-config %'
7477
$ext_tool_enable = '/usr/sbin/php5enmod'
7578
$ext_tool_query = '/usr/sbin/php5query'
7679
$package_prefix = 'php5-'
@@ -84,6 +87,7 @@
8487
$default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid"
8588
$fpm_error_log = "/var/log/php${globals_php_version}-fpm.log"
8689
$fpm_service_name = "php${globals_php_version}-fpm"
90+
$fpm_checkconf_cmd = "/usr/sbin/php-fpm${globals_php_version} -t --fpm-config %"
8791
$ext_tool_enable = "/usr/sbin/phpenmod -v ${globals_php_version}"
8892
$ext_tool_query = "/usr/sbin/phpquery -v ${globals_php_version}"
8993
$package_prefix = "php${globals_php_version}-"
@@ -93,6 +97,7 @@
9397
$default_fpm_pid_file = '/var/run/php5-fpm.pid'
9498
$fpm_error_log = '/var/log/php5-fpm.log'
9599
$fpm_service_name = 'php5-fpm'
100+
$fpm_checkconf_cmd = '/usr/sbin/php5-fpm -t --fpm-config %'
96101
$ext_tool_enable = '/usr/sbin/php5enmod'
97102
$ext_tool_query = '/usr/sbin/php5query'
98103
$package_prefix = 'php5-'

0 commit comments

Comments
 (0)