--- - name: Install fail2ban ansible.builtin.apt: name: fail2ban state: present when: ansible_os_family == "Debian" - name: Configure fail2ban jail ansible.builtin.template: src: fail2ban.jail.local.j2 dest: "{{ fail2ban_config_dir }}/jail.local" owner: root group: root mode: '0644' backup: yes notify: restart fail2ban service - name: Ensure fail2ban is started and enabled ansible.builtin.systemd: name: fail2ban state: started enabled: yes daemon_reload: yes