--- - name: Install fail2ban package ansible.builtin.apt: name: fail2ban state: present update_cache: true - name: Configure fail2ban jail.local ansible.builtin.template: src: jail.local.j2 dest: /etc/fail2ban/jail.local owner: root group: root mode: "0644" notify: Restart fail2ban - name: Ensure fail2ban service is enabled ansible.builtin.service: name: fail2ban state: started enabled: true