- name: Setup default firewall rules command: "/sbin/iptables -I INPUT 1 -p tcp -m tcp -m comment --comment '{{item.type}}' --dport {{item.port}} -j ACCEPT" with_items: - {'type':'SSH', 'port':22} - {'type':'HTTP', 'port':80} - {'type':'HTTPS', 'port':443} when: ansible_os_family == 'RedHat' - name: Setup default firewall rules command: ufw allow {{item}} with_items: - 22 - 80 - 443 when: ansible_os_family == 'Debian'