5 # Copyright:: 2011, OpenStreetMap Foundation
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
11 # https://www.apache.org/licenses/LICENSE-2.0
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.
20 include_recipe "networking"
28 package "exim4-daemon-heavy" if File.exist?("/var/run/clamav/clamd.ctl")
36 if node[:exim][:certificate_names]
37 include_recipe "apache"
39 apache_site node[:exim][:certificate_names].first do
41 variables :aliases => node[:exim][:certificate_names].drop(1)
44 ssl_certificate node[:exim][:certificate_names].first do
45 domains node[:exim][:certificate_names]
46 notifies :restart, "service[exim4]"
49 openssl_x509_certificate "/etc/ssl/certs/exim.pem" do
50 key_file "/etc/ssl/private/exim.key"
55 email "postmaster@openstreetmap.org"
56 common_name node[:fqdn]
58 notifies :restart, "service[exim4]"
63 action [:enable, :start]
64 supports :status => true, :restart => true, :reload => true
67 relay_to_domains = node[:exim][:relay_to_domains]
69 node[:exim][:routes].each_value do |route|
70 relay_to_domains |= route[:domains] if route[:host]
73 relay_from_hosts = node[:exim][:relay_from_hosts]
75 if node[:exim][:smarthost_name]
76 search(:node, "exim_smarthost_via:#{node[:exim][:smarthost_name]}\\:*").each do |host|
77 relay_from_hosts |= host.ipaddresses(:role => :external)
80 domains = node[:exim][:local_domains].reject { |d| ["localhost", "@", "noreply.openstreetmap.org"].any?(d) }
81 primary_domain = domains.first
83 directory "/srv/mta-sts.#{primary_domain}" do
89 domains.each do |domain|
90 template "/srv/mta-sts.#{primary_domain}/#{domain}.txt" do
95 variables :domain => domain
99 ssl_certificate "mta-sts.#{primary_domain}" do
100 domains domains.collect { |d| "mta-sts.#{d}" }
101 notifies :reload, "service[apache2]"
104 apache_site "mta-sts.#{primary_domain}" do
105 template "apache-mta-sts.erb"
106 variables :domains => domains
110 file "/etc/exim4/blocked-senders" do
116 template "/etc/exim4/exim4.conf" do
117 source "exim4.conf.erb"
121 variables :relay_to_domains => relay_to_domains.sort,
122 :relay_from_hosts => relay_from_hosts.sort
123 notifies :restart, "service[exim4]"
126 search(:accounts, "*:*").each do |account|
128 details = node[:accounts][:users][name] || {}
130 if details[:status] && account["email"]
131 node.default[:exim][:aliases][name] = account["email"]
135 if node[:exim][:private_aliases]
136 aliases = data_bag_item("exim", "aliases")
138 aliases[node[:exim][:private_aliases]].each do |name, address|
139 node.default[:exim][:aliases][name] = address
143 template "/etc/aliases" do
150 remote_directory "/etc/exim4/noreply" do
156 files_group "Debian-exim"
161 munin_plugin "exim_mailqueue"
162 munin_plugin "exim_mailstats"
164 if node[:exim][:smarthost_name]
165 node[:exim][:daemon_smtp_ports].each do |port|
166 firewall_rule "accept-inbound-smtp-#{port}" do
176 node[:exim][:daemon_smtp_ports].each do |port|
177 firewall_rule "accept-inbound-smtp-#{port}" do
179 source "bm:mail.openstreetmap.org"
188 if node[:exim][:smarthost_via]
189 firewall_rule "deny-outbound-smtp" do