-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathfail2ban.yml
81 lines (71 loc) · 1.99 KB
/
fail2ban.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
- name: install fail2ban
apt:
state: present
package:
- fail2ban
- ipset
- name: create fail2ban configuration directories
file:
path: "{{ item }}"
state: directory
owner: root
group: root
mode: "0755"
with_items:
- "/etc/fail2ban"
- "/etc/fail2ban/jail.d"
- "/etc/fail2ban/filter.d"
- name: copy fail2ban global configuration
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: "0644"
with_items:
- { src: 'etc_fail2ban_jail.local.j2', dest: '/etc/fail2ban/jail.local' }
- { src: 'etc_fail2ban_action.d_firewallcmd-ipset.conf.j2', dest: '/etc/fail2ban/action.d/firewallcmd-ipset.conf' }
- { src: 'etc_fail2ban_fail2ban.local.j2', dest: '/etc/fail2ban/fail2ban.local' }
- { src: 'var_lib_fail2ban_emptylog.log.j2', dest: '/var/lib/fail2ban/emptylog.log' }
notify: restart fail2ban
- name: copy fail2ban sshd jail configuration
template:
src: etc_fail2ban_jail.d_sshd.conf.j2
dest: /etc/fail2ban/jail.d/sshd.conf
owner: root
group: root
mode: "0644"
notify: reload fail2ban
- name: migration/1.17.0 - remove files from old versions of the role
file:
path: /etc/fail2ban/jail.d/pam-generic.conf
state: absent
notify: reload fail2ban
##### FACTS #####
- name: create ansible facts.d directory
file:
path: /etc/ansible/facts.d
state: directory
owner: root
group: root
mode: "0755"
ignore_errors: "{{ ansible_check_mode }}"
- name: create fail2ban fact file
template:
src: etc_ansible_facts.d_fail2ban.fact.j2
dest: /etc/ansible/facts.d/fail2ban.fact
owner: root
group: root
mode: "0644"
notify: update ansible facts
ignore_errors: "{{ ansible_check_mode }}"
- name: apply configuration (flush handlers)
meta: flush_handlers
##### SERVICES #####
- name: start and enable fail2ban
service:
name: fail2ban
state: started
enabled: yes
ignore_errors: "{{ ansible_check_mode }}"
tags: services