- name: Install iptables-persistent
  become: true
  ansible.builtin.apt:
    install_recommends: false
    name: iptables-persistent
    state: present

- name: Configure rule files
  ansible.builtin.include_tasks: file.yml
  loop:
    - {src: rules.v4.j2, dest: /etc/iptables/rules.v4, tool: iptables}
    - {src: rules.v6.j2, dest: /etc/iptables/rules.v6, tool: ip6tables}

- name: Reboot if necessary
  ansible.builtin.meta: flush_handlers