Skip to content

Commit

Permalink
Merge pull request #295 from abraham1901/dev
Browse files Browse the repository at this point in the history
Fix cert sanitized and add some options
  • Loading branch information
James Fryman committed Apr 15, 2014
2 parents c685708 + 7b33e45 commit 8218c59
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 20 deletions.
26 changes: 24 additions & 2 deletions manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
$spdy = $nginx::params::nx_spdy,
$proxy = undef,
$proxy_read_timeout = $nginx::params::nx_proxy_read_timeout,
$proxy_connect_timeout = $nginx::params::nx_proxy_connect_timeout,
$proxy_set_header = [],
$proxy_cache = false,
$proxy_cache_valid = false,
Expand All @@ -167,6 +168,8 @@
$location_custom_cfg = undef,
$location_cfg_prepend = undef,
$location_cfg_append = undef,
$location_custom_cfg_prepend = undef,
$location_custom_cfg_append = undef,
$try_files = undef,
$auth_basic = undef,
$auth_basic_user_file = undef,
Expand All @@ -178,6 +181,7 @@
$include_files = undef,
$access_log = undef,
$error_log = undef,
$format_log = undef,
$passenger_cgi_param = undef,
$use_default_location = true,
$rewrite_rules = [],
Expand Down Expand Up @@ -348,13 +352,20 @@
}
}


# This was a lot to add up in parameter list so add it down here
# Also opted to add more logic here and keep template cleaner which
# unfortunately means resorting to the $varname_real thing
$access_log_real = $access_log ? {
$access_log_tmp = $access_log ? {
undef => "${nginx::params::nx_logdir}/${name_sanitized}.access.log",
default => $access_log,
}

$access_log_real = $format_log ? {
undef => $access_log_tmp,
default => "${access_log_tmp} $format_log",
}

$error_log_real = $error_log ? {
undef => "${nginx::params::nx_logdir}/${name_sanitized}.error.log",
default => $error_log,
Expand All @@ -381,6 +392,7 @@
location_deny => $location_deny,
proxy => $proxy,
proxy_read_timeout => $proxy_read_timeout,
proxy_connect_timeout => $proxy_connect_timeout,
proxy_cache => $proxy_cache,
proxy_cache_valid => $proxy_cache_valid,
proxy_method => $proxy_method,
Expand Down Expand Up @@ -412,6 +424,16 @@
location_cfg_append => $location_cfg_append }
}

if $location_custom_cfg_prepend {
Nginx::Resource::Location["${name_sanitized}-default"] {
location_custom_cfg_prepend => $location_custom_cfg_prepend }
}

if $location_custom_cfg_append {
Nginx::Resource::Location["${name_sanitized}-default"] {
location_custom_cfg_append => $location_custom_cfg_append }
}

if $fastcgi != undef and !defined(File['/etc/nginx/fastcgi_params']) {
file { '/etc/nginx/fastcgi_params':
ensure => present,
Expand Down Expand Up @@ -463,7 +485,7 @@
}

#Generate ssl key/cert with provided file-locations
$cert = regsubst($name,' ','_')
$cert = regsubst($name,' ','_', 'G')

# Check if the file has been defined before creating the file to
# avoid the error when using wildcard cert on the multiple vhosts
Expand Down
8 changes: 4 additions & 4 deletions templates/vhost/vhost_location_alias.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= subkey %> <%= asubvalue %>;
<%= key %> <%= subkey %> <%= asubvalue %>
<% end -%>
<% end -%><% else -%>
<% Array(value).each do |asubvalue| -%>
<%= key %> <%= asubvalue %>;
<%= key %> <%= asubvalue %>
<% end -%>
<% end -%>
<% end -%><% end -%>
Expand Down Expand Up @@ -36,11 +36,11 @@
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= subkey %> <%= asubvalue %>;
<%= key %> <%= subkey %> <%= asubvalue %>
<% end -%>
<% end -%><% else -%>
<% Array(value).each do |asubvalue| -%>
<%= key %> <%= asubvalue %>;
<%= key %> <%= asubvalue %>
<% end -%>
<% end -%>
<% end -%><% end -%>
Expand Down
4 changes: 2 additions & 2 deletions templates/vhost/vhost_location_directory.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= subkey %> <%= asubvalue %>;
<%= key %> <%= subkey %> <%= asubvalue %>
<% end -%>
<% end -%><% else -%>
<% Array(value).each do |asubvalue| -%>
<%= key %> <%= asubvalue %>;
<%= key %> <%= asubvalue %>
<% end -%>
<% end -%>
<% end -%><% end -%>
Expand Down
8 changes: 4 additions & 4 deletions templates/vhost/vhost_location_fastcgi.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= subkey %> <%= asubvalue %>;
<%= key %> <%= subkey %> <%= asubvalue %>
<% end -%>
<% end -%><% else -%>
<% Array(value).each do |asubvalue| -%>
<%= key %> <%= asubvalue %>;
<%= key %> <%= asubvalue %>
<% end -%>
<% end -%>
<% end -%><% end -%>
Expand Down Expand Up @@ -55,11 +55,11 @@
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= subkey %> <%= asubvalue %>;
<%= key %> <%= subkey %> <%= asubvalue %>
<% end -%>
<% end -%><% else -%>
<% Array(value).each do |asubvalue| -%>
<%= key %> <%= asubvalue %>;
<%= key %> <%= asubvalue %>
<% end -%>
<% end -%>
<% end -%><% end -%>
Expand Down
8 changes: 4 additions & 4 deletions templates/vhost/vhost_location_proxy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= subkey %> <%= asubvalue %>;
<%= key %> <%= subkey %> <%= asubvalue %>
<% end -%>
<% end -%><% else -%>
<% Array(value).each do |asubvalue| -%>
<%= key %> <%= asubvalue %>;
<%= key %> <%= asubvalue %>
<% end -%>
<% end -%>
<% end -%><% end -%>
Expand Down Expand Up @@ -61,11 +61,11 @@
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= subkey %> <%= asubvalue %>;
<%= key %> <%= subkey %> <%= asubvalue %>
<% end -%>
<% end -%><% else -%>
<% Array(value).each do |asubvalue| -%>
<%= key %> <%= asubvalue %>;
<%= key %> <%= asubvalue %>
<% end -%>
<% end -%>
<% end -%><% end -%>
Expand Down
8 changes: 4 additions & 4 deletions templates/vhost/vhost_location_stub_status.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= subkey %> <%= asubvalue %>;
<%= key %> <%= subkey %> <%= asubvalue %>
<% end -%>
<% end -%><% else -%>
<% Array(value).each do |asubvalue| -%>
<%= key %> <%= asubvalue %>;
<%= key %> <%= asubvalue %>
<% end -%>
<% end -%>
<% end -%><% end -%>
Expand Down Expand Up @@ -36,11 +36,11 @@
<% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%>
<% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= subkey %> <%= asubvalue %>;
<%= key %> <%= subkey %> <%= asubvalue %>
<% end -%>
<% end -%><% else -%>
<% Array(value).each do |asubvalue| -%>
<%= key %> <%= asubvalue %>;
<%= key %> <%= asubvalue %>
<% end -%>
<% end -%>
<% end -%><% end -%>
Expand Down

0 comments on commit 8218c59

Please sign in to comment.