An entry with delete: true (a boolean) removes the rule it describes,
passed to community.general.ufw's delete option. It lets a consumer
replace a base rule, such as an open SSH allow by narrower ones, which
the role could only add before.
- rules.yml applies the delete entries after every other rule, whatever
their place in the list, so the replacement exists before the old rule
goes.
- validate.yml: the schema check requires a boolean; a new check refuses
a rule the list both adds and deletes (compared without the comment,
port as a string), because the delete would win while the lock-out
guard counted the add; the lock-out guard no longer counts a delete
entry.
- service_rules keeps its own key list and does not accept delete.
Molecule: prepare stores a commented 9091 rule that the base list deletes
with an uncommented entry listed first; verify checks it is gone and the
untagged count is unchanged; the idempotence pass covers deleting a rule
that is gone. Two new refusals: an SSH rule that is only deleted (lock-out
guard) and a rule both added and deleted.
Verified locally: validate.yml against localhost in check mode (the
planned replacement list passes; the conflict, the delete-only SSH list
and a non-boolean delete are refused) and the apply order. Not verified
locally: the molecule scenario (CI only), including whether ufw matches
the commented rule from an uncommented delete.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm