How to ensure that removed allowed ports will be removed using Ansible's UFW module?
Based on:


# Allow OpenSSH. (Note that as ufw manages its own state, simply removing
# a rule=allow task can leave those ports exposed. Either use delete=yes
# or a separate state=reset task)



The following snippet was added to the top of the file:

---
- name: Reset UFW
  ufw:
    state: reset


Once ansible was run:

TASK [rolename : Reset UFW]


the undefined ports were removed