From 650f35410941c58e4a0a494fadcd6983bbce27bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Capek?= Date: Wed, 15 Apr 2015 09:08:30 +0200 Subject: [PATCH 1/2] vhost - additional parameter for expansion in user vhost template - the 'options' parameter now allows for expanding arbitrary variables in user specified template vhost template. It is needed since vhost define expands the template. - a sample template has been provided. It can be used for redirecting the entire server to different locations has --- manifests/vhost.pp | 3 +++ templates/vhost/vhost_redirect.erb | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 templates/vhost/vhost_redirect.erb diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 1fb72ee..070c5e7 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -6,6 +6,8 @@ # - The $port to configure the host on # - The $docroot provides the Documentation Root variable # - The $template option specifies whether to use the default template or override +# - The $options can be an array or hash variable that the custom +# template may use for expanding custom variables # - The $priority of the site # - The $serveraliases of the site # @@ -26,6 +28,7 @@ $docroot, $port = '80', $template = 'nginx/vhost/vhost.conf.erb', + $options = undef, $priority = '50', $serveraliases = '', $create_docroot = true, diff --git a/templates/vhost/vhost_redirect.erb b/templates/vhost/vhost_redirect.erb new file mode 100644 index 0000000..94d01c6 --- /dev/null +++ b/templates/vhost/vhost_redirect.erb @@ -0,0 +1,10 @@ +# Virtual host <%= @name %> +# This file has been provided by puppet for <%= @fqdn %>. +# DON'T EDIT it manually, any changes will be lost +# + +server { + listen <%= @port %>; + server_name <%= @serveraliases.join(" ") %>; + return <% if @options['status_code'] then -%><%= @options['status_code'] -%><% else %>301<%- end -%> <%= @options['redirect_url'] %>$request_uri; +} From 69c36b39233d94be74d45e173c10ccede7d970c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pavl=C3=ADk?= Date: Wed, 18 Oct 2017 16:27:49 +0200 Subject: [PATCH 2/2] Adaptation to puppet 3.8 --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 95f3c8e..f05b4fa 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -430,7 +430,7 @@ } # The whole nginx configuration directory can be recursively overriden - if $nginx::source_dir { + if $nginx::source_dir != '' { file { 'nginx.dir': ensure => directory, path => $nginx::config_dir,