]> git.openstreetmap.org Git - chef.git/blob - cookbooks/fail2ban/recipes/default.rb
Use fail2ban to block nominatim abusers
[chef.git] / cookbooks / fail2ban / recipes / default.rb
1 #
2 # Cookbook Name:: fail2ban
3 # Recipe:: default
4 #
5 # Copyright 2013, 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 "fail2ban"
21
22 if node[:lsb][:release].to_f >= 14.04
23   file "/etc/fail2ban/jail.local" do
24     action :delete
25   end
26 else
27   directory "/etc/fail2ban/jail.d" do
28     owner "root"
29     group "group"
30     mode 0755
31   end
32
33   template "/etc/fail2ban/jail.local" do
34     source "jail.local.erb"
35     owner "root"
36     group "root"
37     mode 0644
38     subscribes :create, "template[/etc/fail2ban/jail.d/00-default.conf]"
39     notifies :reload, "service[fail2ban]"
40   end
41 end
42
43 template "/etc/fail2ban/jail.d/00-default.conf" do
44   source "jail.default.erb"
45   owner "root"
46   group "root"
47   mode 0644
48   notifies :reload, "service[fail2ban]"
49 end
50
51 service "fail2ban" do
52   action [:enable, :start]
53   supports :status => true, :reload => true, :restart => true
54 end
55
56 munin_plugin "fail2ban"