]> git.openstreetmap.org Git - chef.git/blob - cookbooks/squid/recipes/default.rb
89377089f072bf912448f81180600dab10fc00f7
[chef.git] / cookbooks / squid / recipes / default.rb
1 #
2 # Cookbook Name:: squid
3 # Recipe:: default
4 #
5 # Copyright 2011, OpenStreetMap Foundation
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 package "squid"
21 package "squidclient"
22
23 template "/etc/squid/squid.conf" do
24   source "squid.conf.erb"
25   owner "root"
26   group "root"
27   mode 0644
28 end
29
30 template "/etc/default/squid" do
31   source "squid.erb"
32   owner "root"
33   group "root"
34   mode 0644
35 end
36
37 directory "/etc/squid/squid.conf.d" do
38   owner "root"
39   group "root"
40   mode 0755
41 end
42
43 if node[:lsb][:release].to_f >= 15.10
44   execute "systemctl-daemon-reload" do
45     action :nothing
46     command "systemctl daemon-reload"
47   end
48
49   template "/etc/systemd/system/squid.service" do
50     source "squid.service.erb"
51     owner "root"
52     group "root"
53     mode 0644
54     notifies :run, "execute[systemctl-daemon-reload]"
55   end
56
57   service "squid" do
58     provider Chef::Provider::Service::Systemd
59     action [:enable, :start]
60     supports :status => true, :restart => true, :reload => true
61     subscribes :restart, "template[/etc/systemd/system/squid.service]"
62     subscribes :reload, "template[/etc/squid/squid.conf]"
63     subscribes :restart, "template[/etc/default/squid]"
64     subscribes :reload, "template[/etc/resolv.conf]"
65   end
66 else
67   service "squid" do
68     provider Chef::Provider::Service::Upstart
69     action [:enable, :start]
70     supports :status => true, :restart => true, :reload => true
71     subscribes :reload, "template[/etc/squid/squid.conf]"
72     subscribes :restart, "template[/etc/default/squid]"
73     subscribes :reload, "template[/etc/resolv.conf]"
74   end
75 end
76
77 munin_plugin "squid_cache"
78 munin_plugin "squid_delay_pools"
79 munin_plugin "squid_times"
80 munin_plugin "squid_icp"
81 munin_plugin "squid_objectsize"
82 munin_plugin "squid_requests"
83 munin_plugin "squid_traffic"