Fixed conditionals, made explicit superuser, added new app configurations

This commit is contained in:
Alex Tavarez
2025-07-21 16:54:18 -04:00
parent 85b1f6cd25
commit a904b6ddf4
5 changed files with 144 additions and 34 deletions

View File

@@ -8,18 +8,24 @@
path: /etc/systemd/system/fail2ban.service.d
register: fail2serve_path
- name: Create relevant fail2ban configuration directory
become: yes
become_method: sudo
file:
path: /etc/fail2ban/jail.d
state: directory
register: fail2bandir_created
when: not fail2path.stat.exists
- name: Create relevant fail2ban configuration directory
become: yes
become_method: sudo
file:
path: /etc/systemd/system/fail2ban.service.d
state: directory
register: fail2servdir_created
when: not fail2serve_path.stat.exists
- name: Copy sshd jail file
- name: Copy protftpd jail file
become: yes
become_method: sudo
copy:
src: ftp.local
dest: /etc/fail2ban/jail.d/ftp.local
@@ -27,6 +33,8 @@
backup: yes
when: fail2path.stat.exists
- name: Copy sshd jail file
become: yes
become_method: sudo
copy:
src: sshd.local
dest: /etc/fail2ban/jail.d/sshd.local
@@ -34,25 +42,33 @@
backup: yes
when: fail2path.stat.exists
- name: Copy fail2ban modified service configuration
become: yes
become_method: sudo
copy:
src: override.conf
dest: /etc/systemd/system/fail2ban.service.d/sshd.local
force: yes
backup: yes
when: fail2serve_path.stat.exists
- name: Start fail2ban service
- name: Reload fail2ban service
become: yes
become_method: sudo
service:
name: fail2ban
state: reloaded
register: fail2ban_reloaded
- name: Start fail2ban service
- name: Start and enable fail2ban service
become: yes
become_method: sudo
service:
name: fail2ban
enabled: yes
state: started
enabled: yes
register: fail2ban_running
when: fail2ban_reloaded
- name: Start fail2ban service
- name: Restart fail2ban service
become: yes
become_method: sudo
service:
name: fail2ban
state: restarted