--- - name: Install ufw apt: name: - ufw state: present - name: Configure UFW rules ufw: rule: allow port: "{{ item }}" direction: in proto: any loop: "{{ firewall_in_ports }}" - name: Set firewall default in policy ufw: state: enabled direction: incoming policy: deny - name: Set firewall default out policy ufw: state: enabled direction: outgoing policy: allow