]> git.openstreetmap.org Git - chef.git/blob - cookbooks/spamassassin/recipes/default.rb
49b15a583da44975fd1232d3381b5bdd9b81eece
[chef.git] / cookbooks / spamassassin / recipes / default.rb
1 #
2 # Cookbook:: spamassassin
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 #     https://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 "spamassassin"
21
22 service "spamassassin" do
23   action [:enable, :start]
24   supports :status => true, :restart => true, :reload => true
25 end
26
27 directory "/var/spool/spamassassin" do
28   owner "debian-spamd"
29   group "debian-spamd"
30   mode 0o755
31 end
32
33 template "/etc/default/spamassassin" do
34   source "spamassassin.erb"
35   owner "root"
36   group "root"
37   mode 0o644
38   notifies :restart, "service[spamassassin]"
39 end
40
41 trusted_networks = node[:exim][:relay_from_hosts]
42
43 if node[:exim][:smarthost_name]
44   search(:node, "exim_smarthost_via:#{node[:exim][:smarthost_name]}\\:*").each do |host|
45     trusted_networks |= host.ipaddresses(:role => :external)
46   end
47 end
48
49 trusted_networks -= ["127.0.0.1", "::1"]
50
51 template "/etc/spamassassin/local.cf" do
52   source "local.cf.erb"
53   owner "root"
54   group "root"
55   mode 0o644
56   variables :trusted_networks => trusted_networks.sort
57   notifies :restart, "service[spamassassin]"
58 end