opnsense_apply_firewall_changes
Safely apply staged firewall changes with automatic rollback protection, preventing lockout from flawed rules. Verify connectivity and cancel rollback to keep changes permanent.
Instructions
Activate staged firewall changes, with automatic rollback protection.
Requires OPNSENSE_ALLOW_WRITE=true. This wraps OPNsense's savepoint mechanism, which exists because a bad rule can lock you out of the firewall that hosts the API you would need to fix it.
The sequence, in order:
mode='savepoint' -> returns a revision timestamp
make changes -> e.g. opnsense_toggle_firewall_rule
mode='apply' -> with revision=<from step 1>; the firewall will revert to that revision by itself in 60 seconds
verify connectivity -> confirm the firewall is still reachable
mode='cancel_rollback' -> with the same revision; makes the change permanent
Skipping step 5 is safe: the firewall reverts. Skipping step 1 is not: an apply with no savepoint cannot be undone remotely.
mode='revert' rolls back to a revision immediately without waiting.
Args: params (ApplyChangesInput): Validated input containing: - mode (str): 'savepoint', 'apply', 'cancel_rollback' or 'revert' - revision (str): Revision timestamp, required for all modes except savepoint - response_format (ResponseFormat): 'markdown' or 'json'
Returns: str: Text describing what happened and what to do next, or JSON: {"mode": str, "revision": str, "result": str, "next_step": str}
Error Handling: - Returns a write-disabled explanation when OPNSENSE_ALLOW_WRITE is not set - Returns a validation message when revision is missing for a mode that needs it
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |