---
- name: install ufw
  apt: pkg=ufw state=present

- name: enable firewall
  ufw: state=enabled policy=deny logging=on

- name: pass SSH through firewall
  ufw: rule=allow name=OpenSSH

- name: pass HTTP through firewall
  ufw: rule=allow port=80 proto=tcp

- name: pass HTTPS through firewall
  ufw: rule=allow port=443 proto=tcp

---
- name: install ufw
  apt: pkg=ufw state=present

- name: enable firewall
  ufw: state=enabled policy=deny logging=on

- name: pass SSH through firewall
  ufw: rule=allow name=OpenSSH

- name: pass HTTP through firewall
  ufw: rule=allow port=80 proto=tcp

- name: pass HTTPS through firewall
  ufw: rule=allow port=443 proto=tcp

- name: pass other ports through firewall
  ufw: rule=allow port={{item}}
  with_items: "{{extra_ports}}"

Allow firewall role to enable extra ports
Allow firewall role to enable extra ports
