main.yml 893 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ---
  2. - name: Install fail2ban
  3. ansible.builtin.dnf:
  4. name: fail2ban
  5. state: present
  6. - name: Deploy nginx-4xx filter
  7. ansible.builtin.template:
  8. src: nginx-4xx.conf.j2
  9. dest: /etc/fail2ban/filter.d/nginx-4xx.conf
  10. owner: root
  11. group: root
  12. mode: '0644'
  13. backup: yes
  14. notify: restart fail2ban
  15. - name: Deploy nginx-auth filter
  16. ansible.builtin.template:
  17. src: nginx-auth.conf.j2
  18. dest: /etc/fail2ban/filter.d/nginx-auth.conf
  19. owner: root
  20. group: root
  21. mode: '0644'
  22. backup: yes
  23. notify: restart fail2ban
  24. - name: Deploy jail.local configuration
  25. ansible.builtin.template:
  26. src: jail.local.j2
  27. dest: /etc/fail2ban/jail.local
  28. owner: root
  29. group: root
  30. mode: '0644'
  31. backup: yes
  32. notify: restart fail2ban
  33. - name: Enable and start fail2ban service
  34. ansible.builtin.service:
  35. name: fail2ban
  36. state: started
  37. enabled: yes