From dc682dc898e6f5fa1297c85fb983b76ac2a8c413 Mon Sep 17 00:00:00 2001 From: Babis Kaidos Date: Fri, 27 Nov 2015 15:42:44 +0200 Subject: [PATCH 1/3] Added 3 squid configuration parameters: cache_peer, memory_replacement_policy and cache_replacement_policy along with their validators. Signed-off-by: Babis Kaidos --- .gitignore | 3 +++ manifests/init.pp | 6 ++++++ templates/squid.conf.long.erb | 9 +++++++++ templates/squid.conf.short.erb | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/.gitignore b/.gitignore index 2f6d24c..843bc39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ .idea Gemfile.lock + +#Geppetto files +.project \ No newline at end of file diff --git a/manifests/init.pp b/manifests/init.pp index e27a043..959e7cb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -11,6 +11,7 @@ $http_access = [], $icp_access = [], $tcp_outgoing_address = [], + $cache_peer = [], $cache_mem = '256 MB', $cache_dir = [], $cache = [], @@ -22,6 +23,8 @@ $server_persistent_connections = 'on', $maximum_object_size = '4096 KB', $maximum_object_size_in_memory = '512 KB', + $memory_replacement_policy = undef, + $cache_replacement_policy = undef, $config_hash = {}, $refresh_patterns = [], $template = 'long', @@ -31,6 +34,9 @@ $service_enable = $::squid3::params::service_enable, $service_name = $::squid3::params::service_name, ) inherits ::squid3::params { + validate_re($cache_replacement_policy, '^(lru|heap GDSF|heap LFUDA|heap LRU)$') + validate_re($memory_replacement_policy, '^(lru|heap GDSF|heap LFUDA|heap LRU)$') + validate_array($cache_peer) $use_template = $template ? { 'short' => 'squid3/squid.conf.short.erb', diff --git a/templates/squid.conf.long.erb b/templates/squid.conf.long.erb index 8df1b62..21184b2 100644 --- a/templates/squid.conf.long.erb +++ b/templates/squid.conf.long.erb @@ -1796,6 +1796,9 @@ tcp_outgoing_address <%= line %> # #Default: # none +<% @cache_peer.each do |line| -%> +cache_peer <%= line %> +<% end -%> # TAG: cache_peer_domain # Use to limit the domains for which a neighbor cache will be @@ -1947,6 +1950,9 @@ maximum_object_size_in_memory <%= @maximum_object_size_in_memory %> # See cache_replacement_policy for details. #Default: # memory_replacement_policy lru +<% if @memory_replacement_policy -%> +memory_replacement_policy <%= @memory_replacement_policy %> +<% end -%> # DISK CACHE OPTIONS # ----------------------------------------------------------------------------- @@ -1987,6 +1993,9 @@ maximum_object_size_in_memory <%= @maximum_object_size_in_memory %> # and http://fog.hpl.external.hp.com/techreports/98/HPL-98-173.html. #Default: # cache_replacement_policy lru +<% if @cache_replacement_policy -%> +cache_replacement_policy <%= @cache_replacement_policy %> +<% end -%> # TAG: cache_dir # Usage: diff --git a/templates/squid.conf.short.erb b/templates/squid.conf.short.erb index c92f057..2556f19 100644 --- a/templates/squid.conf.short.erb +++ b/templates/squid.conf.short.erb @@ -63,6 +63,10 @@ https_port <%= line %> tcp_outgoing_address <%= line %> <% end -%> +<% @cache_peer.each do |line| -%> +cache_peer <%= line %> +<% end -%> + # user-defined cache-dirs <% @cache_dir.each do |line| -%> cache_dir <%= line %> @@ -73,6 +77,8 @@ cache_dir <%= line %> hierarchy_stoplist cgi-bin ? coredump_dir <%= @coredump_dir %> maximum_object_size_in_memory <%= @maximum_object_size_in_memory %> +memory_replacement_policy <%= @memory_replacement_policy %> +cache_replacement_policy <%= @cache_replacement_policy %> maximum_object_size <%= @maximum_object_size %> ignore_expect_100 <%= @ignore_expect_100 %> cache_mgr <%= @cache_mgr %> From 802043ea1e9074b9f028500fe1472dbbd685364a Mon Sep 17 00:00:00 2001 From: Babis Kaidos Date: Fri, 27 Nov 2015 16:07:54 +0200 Subject: [PATCH 2/3] REs validated if they exist Signed-off-by: Babis Kaidos --- manifests/init.pp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 959e7cb..d848ca4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -34,8 +34,12 @@ $service_enable = $::squid3::params::service_enable, $service_name = $::squid3::params::service_name, ) inherits ::squid3::params { - validate_re($cache_replacement_policy, '^(lru|heap GDSF|heap LFUDA|heap LRU)$') - validate_re($memory_replacement_policy, '^(lru|heap GDSF|heap LFUDA|heap LRU)$') + if $cache_replacement_policy != undef { + validate_re($cache_replacement_policy, '^(lru|heap GDSF|heap LFUDA|heap LRU)$') + } + if $memory_replacement_policy != undef { + validate_re($memory_replacement_policy, '^(lru|heap GDSF|heap LFUDA|heap LRU)$') + } validate_array($cache_peer) $use_template = $template ? { From 9570c395792ad2e9cb8487d60f8529ff5788e78e Mon Sep 17 00:00:00 2001 From: Babis Kaidos Date: Fri, 27 Nov 2015 16:25:48 +0200 Subject: [PATCH 3/3] Added refresh patterns in the long template. Also added a validator for refresh patterns Signed-off-by: Babis Kaidos --- manifests/init.pp | 1 + templates/squid.conf.long.erb | 3 +++ 2 files changed, 4 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index d848ca4..3c4985d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -41,6 +41,7 @@ validate_re($memory_replacement_policy, '^(lru|heap GDSF|heap LFUDA|heap LRU)$') } validate_array($cache_peer) + validate_array($refresh_patterns) $use_template = $template ? { 'short' => 'squid3/squid.conf.short.erb', diff --git a/templates/squid.conf.long.erb b/templates/squid.conf.long.erb index 21184b2..d8c442c 100644 --- a/templates/squid.conf.long.erb +++ b/templates/squid.conf.long.erb @@ -2966,6 +2966,9 @@ cache <%= line %> # # Add any of your own refresh_pattern entries above these. +<% @refresh_patterns.each do |line| -%> +refresh_pattern <%= line %> +<% end -%> refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0