Explorar el Código

Merge pull request #637 from jacobmw/proxy_cache_path

Multiple proxy_cache_path entries
James Fryman hace 8 años
padre
commit
0e930e9ed3
Se han modificado 3 ficheros con 11 adiciones y 5 borrados
  1. 5 2
      manifests/config.pp
  2. 1 1
      metadata.json
  3. 5 2
      templates/conf.d/nginx.conf.erb

+ 5 - 2
manifests/config.pp

@@ -127,8 +127,11 @@ class nginx::config(
   }
   validate_bool($confd_purge)
   validate_bool($vhost_purge)
-  if ($proxy_cache_path != false) {
-    validate_string($proxy_cache_path)
+  if ( $proxy_cache_path != false) {
+    if ( is_string($proxy_cache_path) or is_hash($proxy_cache_path)) {}
+    else {
+      fail('proxy_cache_path must be a string or a hash')
+    }
   }
   validate_re($proxy_cache_levels, '^[12](:[12])*$')
   validate_string($proxy_cache_keys_zone)

+ 1 - 1
metadata.json

@@ -10,7 +10,7 @@
   "dependencies": [
     {"name":"puppetlabs/stdlib","version_requirement":">= 4.2.0 <5.0.0"},
     {"name":"puppetlabs/apt","version_requirement":">= 1.8.0 <3.0.0"},
-    {"name":"puppetlabs/concat","version_requirement":">= 1.1.1 <2.0.0"}
+    {"name":"puppetlabs/concat","version_requirement":">= 1.1.1 <3.0.0"}
   ],
   "requirements": [
     {

+ 5 - 2
templates/conf.d/nginx.conf.erb

@@ -116,9 +116,12 @@ http {
 <% if @proxy_headers_hash_bucket_size -%>
   proxy_headers_hash_bucket_size <%= @proxy_headers_hash_bucket_size %>;
 <% end -%>
-<% if @proxy_cache_path -%>
+<% if @proxy_cache_path.is_a?(Hash) -%>
+<% @proxy_cache_path.sort_by{|k,v| k}.each do |key,value| -%>
+  proxy_cache_path        <%= key %> keys_zone=<%= value %> levels=<%= @proxy_cache_levels %> max_size=<%= @proxy_cache_max_size %> inactive=<%= @proxy_cache_inactive %>;
+<% end -%>
+<% elsif @proxy_cache_path -%>
   proxy_cache_path        <%= @proxy_cache_path %> levels=<%= @proxy_cache_levels %> keys_zone=<%= @proxy_cache_keys_zone %> max_size=<%= @proxy_cache_max_size %> inactive=<%= @proxy_cache_inactive %>;
-
 <% end -%>
 <% if @fastcgi_cache_path -%>
   fastcgi_cache_path    	<%= @fastcgi_cache_path %> levels=<%= @fastcgi_cache_levels %> keys_zone=<%= @fastcgi_cache_keys_zone %> max_size=<%= @fastcgi_cache_max_size %> inactive=<%= @fastcgi_cache_inactive %>;