From 6f1744b11de39b32062bf80ff2b2b725fc0c127e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20L=C3=A9on?= Date: Tue, 24 Mar 2015 15:45:29 +0100 Subject: [PATCH] feat (maintenance): allow to specify maintenance behavior. Add docs. --- manifests/resource/vhost.pp | 4 ++++ templates/vhost/vhost_header.erb | 2 +- templates/vhost/vhost_ssl_header.erb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index ab2cd21..d6ed9e5 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -135,6 +135,9 @@ # [*owner*] - Defines owner of the .conf file # [*group*] - Defines group of the .conf file # [*mode*] - Defines mode of the .conf file +# [*maintenance*] - A boolean value to set a vhost in maintenance +# [*maintenance_value*] - Value to return when maintenance is on. +# Default to return 503 # Actions: # # Requires: @@ -232,6 +235,7 @@ define nginx::resource::vhost ( $group = $::nginx::config::global_group, $mode = $::nginx::config::global_mode, $maintenance = false, + $maintenance_value = 'return 503' ) { validate_re($ensure, '^(present|absent)$', diff --git a/templates/vhost/vhost_header.erb b/templates/vhost/vhost_header.erb index 3f577c5..3b280be 100644 --- a/templates/vhost/vhost_header.erb +++ b/templates/vhost/vhost_header.erb @@ -108,7 +108,7 @@ server { set $maintenance "off"; <% end -%> if ($maintenance = "on") { - return 503; + <%= @maintenance_value %>; } <% if @rewrite_to_https -%> if ($ssl_protocol = "") { diff --git a/templates/vhost/vhost_ssl_header.erb b/templates/vhost/vhost_ssl_header.erb index 09c8aa1..59ae5af 100644 --- a/templates/vhost/vhost_ssl_header.erb +++ b/templates/vhost/vhost_ssl_header.erb @@ -78,7 +78,7 @@ server { set $maintenance "off"; <% end -%> if ($maintenance = "on") { - return 503; + <%= @maintenance_value %>; } <% if Array(@resolver).count > 0 -%> resolver <% Array(@resolver).each do |r| %> <%= r %><% end %>;