This repository has been archived by the owner on Aug 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
122 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,8 @@ | |
|
||
- name: Reload firewall | ||
ufw: state=reloaded | ||
|
||
- name: Restart fail2ban | ||
service: | ||
name: fail2ban | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
|
||
- name: Update ssh port in config | ||
replace: | ||
path: '{{ server_fail2ban_jail_file }}' | ||
regexp: '^port\s+=\s+ssh$' | ||
replace: 'port = {{ ssh_port }}' | ||
notify: Restart fail2ban | ||
when: ssh_port is defined and ssh_port != 22 | ||
|
||
- name: Update email in config | ||
lineinfile: | ||
path: '{{ server_fail2ban_jail_file }}' | ||
regexp: '^destemail\s+=' | ||
line: 'destemail = {{ server_fail2ban_email }}' | ||
state: present | ||
notify: Restart fail2ban | ||
|
||
- name: Send more than an ip on jailed | ||
lineinfile: | ||
path: '{{ server_fail2ban_jail_file }}' | ||
regexp: '^action\s+=\s+\%\(action_\w+\)s' | ||
line: 'action = %(action_mwl)s' | ||
state: present | ||
notify: Restart fail2ban | ||
|
||
- name: Generate jail.local file | ||
template: | ||
src: fail2ban/jail.local.j2 | ||
dest: '{{ server_fail2ban_jail_local_file }}' | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
notify: Restart fail2ban |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
|
||
- name: "Add {{ nopasswd_user }} to sudoers with the NOPASSWD option" | ||
lineinfile: | ||
path: /etc/sudoers | ||
state: present | ||
regexp: "^%{{ nopasswd_user }} ALL=" | ||
line: "%{{ nopasswd_user }} ALL=(ALL) NOPASSWD: ALL" | ||
validate: '/usr/sbin/visudo -cf %s' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# {{ ansible_managed }} | ||
|
||
{% for service in server_fail2ban_services %} | ||
[{{ service.name }}] | ||
|
||
enabled = {{ '"%s"' | format(service.enabled | lower) }} | ||
port = {{ service.port }} | ||
filter = {{ service.filter }} | ||
logpath = {{ service.logpath }} | ||
{% if service.maxretry is defined %} | ||
maxretry = {{ service.maxretry }} | ||
{% endif %} | ||
{% if service.protocol is defined %} | ||
protocol = {{ service.protocol }} | ||
{% endif %} | ||
{% if service.action is defined %} | ||
action = %({{ service.action }})s | ||
{% endif %} | ||
{% if service.banaction is defined %} | ||
banaction = {{ service.banaction }} | ||
{% endif %} | ||
|
||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters