Adds a parameter to prepend configuration elements to the main nginx.conf file

This commit is contained in:
Prachetas Prabhu 2014-12-26 16:54:26 +00:00
parent 1ae85c522c
commit 519f17a55e
2 changed files with 16 additions and 0 deletions

View file

@ -62,6 +62,7 @@ class nginx::config(
$multi_accept = 'off',
$names_hash_bucket_size = '64',
$names_hash_max_size = '512',
$nginx_cfg_prepend = false,
$proxy_buffers = '32 4k',
$proxy_buffer_size = '8k',
$proxy_cache_inactive = '20m',
@ -151,6 +152,12 @@ class nginx::config(
}
}
if ($nginx_cfg_prepend != false) {
if !(is_hash($nginx_cfg_prepend) or is_array($nginx_cfg_prepend)) {
fail('$nginx_cfg_prepend must be either a hash or array')
}
}
validate_string($nginx_error_log)
validate_string($http_access_log)
validate_string($proxy_headers_hash_bucket_size)

View file

@ -11,6 +11,15 @@ pid <%= @pid %>;
<% end -%>
error_log <%= @nginx_error_log %>;
<% if @nginx_cfg_prepend -%>
<%- field_width = @nginx_cfg_prepend.inject(0) { |l,(k,v)| k.size > l ? k.size : l } -%>
<%- @nginx_cfg_prepend.sort_by{|k,v| k}.each do |key,value| -%>
<%- Array(value).each do |asubvalue| -%>
<%= sprintf("%-*s", field_width, key) %> <%= asubvalue %>;
<%- end -%>
<%- end -%>
<% end -%>
events {
worker_connections <%= @worker_connections -%>;
<%- if @multi_accept == 'on' -%>