Add passenger_env_var parameter which deprecates passenger_cgi_param to support Passenger 5.0+

This commit is contained in:
Michael Marod 2015-04-29 12:33:42 -04:00
parent 0aed6c1978
commit d0464923d1
4 changed files with 37 additions and 0 deletions

View file

@ -129,6 +129,8 @@
# variables to pass to the backend application
# [*passenger_header*] - Allows one to set headers to pass to the
# backend application (Passenger 5.0+)
# [*passenger_env_var*] - Allows one to set environemnt variables to pass
# to the backend application (Passenger 5.0+)
# [*log_by_lua*] - Run the Lua source code inlined as the
# <lua-script-str> at the log request processing phase.
# This does not replace the current access logs, but runs after.
@ -230,6 +232,7 @@ define nginx::resource::vhost (
$format_log = 'combined',
$passenger_cgi_param = undef,
$passenger_header = undef,
$passenger_env_var = undef,
$log_by_lua = undef,
$log_by_lua_file = undef,
$use_default_location = true,
@ -414,6 +417,9 @@ define nginx::resource::vhost (
if ($passenger_header != undef) {
validate_hash($passenger_header)
}
if ($passenger_env_var != undef) {
validate_hash($passenger_env_var)
}
if ($log_by_lua != undef) {
validate_string($log_by_lua)
}

View file

@ -876,6 +876,29 @@ describe 'nginx::resource::vhost' do
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content( /passenger_set_header test3 test value 3;/ ) }
end
context 'when passenger_env_var is set' do
let :params do default_params.merge({
:passenger_env_var => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'test3' => 'test value 3' }
}) end
it { is_expected.to contain_concat__fragment("#{title}-header").with_content( /passenger_set_env_var test1 test value 1;/ ) }
it { is_expected.to contain_concat__fragment("#{title}-header").with_content( /passenger_set_env_var test2 test value 2;/ ) }
it { is_expected.to contain_concat__fragment("#{title}-header").with_content( /passenger_set_env_var test3 test value 3;/ ) }
end
context 'when passenger_env_var is set and ssl => true' do
let :params do default_params.merge({
:passenger_env_var => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'test3' => 'test value 3' },
:ssl => true,
:ssl_key => 'dummy.key',
:ssl_cert => 'dummy.cert',
}) end
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content( /passenger_set_env_var test1 test value 1;/ ) }
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content( /passenger_set_env_var test2 test value 2;/ ) }
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content( /passenger_set_env_var test3 test value 3;/ ) }
end
context 'when vhost name is sanitized' do
let :title do 'www rspec-vhost com' end
let :params do default_params end

View file

@ -99,6 +99,11 @@ server {
passenger_set_header <%= key %> <%= @passenger_header[key] %>;
<%- end -%>
<% end -%>
<% if @passenger_env_var -%>
<%- @passenger_env_var.keys.sort.each do |key| -%>
passenger_set_env_var <%= key %> <%= @passenger_env_var[key] %>;
<%- end -%>
<% end -%>
<% if Array(@resolver).count > 0 -%>
resolver <% Array(@resolver).each do |r| %> <%= r %><% end %>;
<% end -%>

View file

@ -155,6 +155,9 @@ server {
<% Array(@passenger_header).each do |key,value| -%>
passenger_set_header <%= key %> <%= value %>;
<% end -%>
<% Array(@passenger_env_var).each do |key,value| -%>
passenger_set_env_var <%= key %> <%= value %>;
<% end -%>
<% Array(@add_header).each do |key,value| -%>
add_header <%= key %> <%= value %>;
<% end -%>