- block: - name: Install fail2ban packages ansible.builtin.apt: name: - fail2ban - sendmail - name: Copy files copy: src: "{{ item }}" dest: /etc/fail2ban/jail.d/ with_fileglob: - "jail.d/*.conf" - name: Copy files copy: src: "{{ item }}" dest: /etc/fail2ban/filter.d/ with_fileglob: - "filter.d/*.conf" - name: Copy files copy: src: "{{ item }}" dest: /etc/fail2ban/action.d/ with_fileglob: - "action.d/*.conf" - name: disable sendmail service ansible.builtin.service: name: sendmail.service state: stopped enabled: false - name: Restart fail2ban service ansible.builtin.service: name: fail2ban.service state: restarted enabled: true become: true