Implementation of new vars configtest_enable and service_restart and their respective optional arguments.
Argument configtest_enable / params.pp $nx_configtest_enable * Default false * If true will set service[nginx] restart with contents of nx_service_restart. Argument service_restart / params.pp $nx_service_restart * Default '/etc/init.d/nginx configtest && /etc/init.d/nginx restart' * Since nginx 0.7.53 nginx supports '-s HUP' which will reload testing configuration first, to be backwards compatible above default was choosen. Many distributions of nginx already implement a configtest before restart, however many doesn't, and many even don't provide restart but a stop/start combination. If configtest_enable is true then puppet will force nginx to do a configtest no matter if it was going or not to do it itself.
This commit is contained in:
parent
e9d984eaaf
commit
197ad06bce
3 changed files with 22 additions and 2 deletions
|
@ -33,6 +33,8 @@ class nginx (
|
|||
$worker_connections = $nginx::params::nx_worker_connections,
|
||||
$proxy_set_header = $nginx::params::nx_proxy_set_header,
|
||||
$confd_purge = $nginx::params::nx_confd_purge,
|
||||
$configtest_enable = $nginx::params::nx_configtest_enable,
|
||||
$service_restart = $nginx::params::nx_service_restrart,
|
||||
) inherits nginx::params {
|
||||
|
||||
include stdlib
|
||||
|
@ -50,7 +52,10 @@ class nginx (
|
|||
notify => Class['nginx::service'],
|
||||
}
|
||||
|
||||
class { 'nginx::service': }
|
||||
class { 'nginx::service':
|
||||
configtest_enable => $configtest_enable,
|
||||
service_restart => $service_restart,
|
||||
}
|
||||
|
||||
# Allow the end user to establish relationships to the "main" class
|
||||
# and preserve the relationship to the implementation classes through
|
||||
|
|
|
@ -54,4 +54,11 @@ class nginx::params {
|
|||
/(?i-mx:debian|ubuntu)/ => 'www-data',
|
||||
/(?i-mx:fedora|rhel|redhat|centos|suse|opensuse)/ => 'nginx',
|
||||
}
|
||||
|
||||
# Service restart after Nginx 0.7.53 could also be just "/path/to/nginx/bin -s HUP"
|
||||
# Some init scripts do a configtest, some don't. If configtest_enable it's true
|
||||
# then service restart will take $nx_service_restart value, forcing configtest.
|
||||
$nx_configtest_enable = false
|
||||
$nx_service_restart = "/etc/init.d/nginx configtest && /etc/init.d/nginx restart"
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
# Sample Usage:
|
||||
#
|
||||
# This class file is not called directly
|
||||
class nginx::service {
|
||||
class nginx::service(
|
||||
$configtest_enable = $nginx::params::nx_configtest_enable,
|
||||
$service_restart = $nginx::params::nx_service_restart,
|
||||
) {
|
||||
exec { 'rebuild-nginx-vhosts':
|
||||
command => "/bin/cat ${nginx::params::nx_temp_dir}/nginx.d/* > ${nginx::params::nx_conf_dir}/conf.d/vhost_autogen.conf",
|
||||
refreshonly => true,
|
||||
|
@ -27,4 +30,9 @@ class nginx::service {
|
|||
hasrestart => true,
|
||||
subscribe => Exec['rebuild-nginx-vhosts'],
|
||||
}
|
||||
if $configtest_enable == true {
|
||||
Service["nginx"] {
|
||||
restart => $service_restart,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue