Skip to content

Commit

Permalink
Merge pull request #122 from stepanbaghdasaryan/fix/fail2ban_use_syst…
Browse files Browse the repository at this point in the history
…emd_backend_for_debian12

fix: use systemd backend for fail2ban for Debian 12 and higher
  • Loading branch information
geerlingguy authored Mar 15, 2024
2 parents 9e826a3 + 0b9a774 commit d85046d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tasks/fail2ban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
state: present
when: ansible_os_family == 'Debian'

- name: Copy fail2ban custom configuration file into place.
- name: Copy jail custom configuration file into place.
template:
src: "{{ security_fail2ban_custom_configuration_template }}"
dest: /etc/fail2ban/jail.local
Expand All @@ -22,6 +22,19 @@
notify:
- reload fail2ban

- name: Copy fail2ban custom configuration file into place.
template:
src: fail2ban.local.j2
dest: /etc/fail2ban/fail2ban.local
owner: root
group: root
mode: 0644
when:
- ansible_os_family == 'Debian'
- ansible_distribution_major_version | int >= 12
notify:
- reload fail2ban

Check failure on line 36 in tasks/fail2ban.yml

View workflow job for this annotation

GitHub Actions / Lint

36:4 [indentation] wrong indentation: expected 4 but found 3

- name: Ensure fail2ban is running and enabled on boot.
service:
name: fail2ban
Expand Down
2 changes: 2 additions & 0 deletions templates/fail2ban.local.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Definition]
logtarget = SYSTEMD-JOURNAL
3 changes: 3 additions & 0 deletions templates/jail.local.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
enabled = true
port = {{ security_ssh_port }}
filter = sshd
{% if ansible_os_family == 'Debian' and ansible_distribution_major_version | int >= 12 %}
backend = systemd
{% endif %}

0 comments on commit d85046d

Please sign in to comment.