Repository navigation
fix(roles/firewall)!: make the iptables and nftables rulesets mandatory - #748
Open
NavidSassan wants to merge 1 commit into
Open
NavidSassan wants to merge 1 commit into
NavidSassan wants to merge 1 commit into
Conversation
…ry (fix #721) The role deployed no nftables ruleset, and what the packages ship filters nothing: comments only on the Red Hat family, three chains with policy accept on Debian and Ubuntu. Since the role stops every other firewall, the host ended up unfiltered. For iptables the ruleset was optional and came from a fixed path in host_files. Both now come from a variable, firewall__iptables_ruleset and firewall__nftables_ruleset, and the preflight aborts if the one for the selected firewall is unset. The ruleset is validated and deployed before the other firewalls are stopped, so a broken one aborts the run with the old firewall still running.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #721
What changes
firewall__iptables_rulesetandfirewall__nftables_rulesethold the ruleset as a string. The one for the selectedfirewall__firewallis mandatory; the preflight aborts without it, before the role stops any firewall./etc/sysconfig/iptables, or to the filenftables.serviceloads (/etc/sysconfig/nftables.confon the Red Hat family,/etc/nftables.confon Debian and Ubuntu), and restarts the service after a change.iptables-restore --testandnft --check, and run before the other firewalls are stopped, so a broken ruleset aborts the run with the old firewall still running. For this, the package installation of both firewalls moved up intasks/main.yml.host_files/<host>/etc/sysconfig/iptablesis gone. The README example shows thelookup("ansible.builtin.file", ...)that replaces it.Breaking
Every host with
firewall__firewall: 'iptables'or'nftables'needs its variable set, otherwise the run aborts. The CHANGELOG entry describes the migration.Deviation from the issue
The issue suggests a check for a ruleset on the host. Detecting whether an nftables file "filters" needed a load in a network namespace and a JSON evaluation, and iptables had no check at all. Making the ruleset an inventory variable for both reduces the check to "is the variable set", the way other roles take whole files (
blocky__config_yml, the certificates ofopensearch).Testing
molecule test --scenario-name firewallpasses on Rocky 9 and Debian 13 (converge, idempotence, verify). The scenario covers:nftrejects, after which the original ruleset is still loadedNot run: Rocky 8 and 10, Debian 12, Ubuntu. iptables is not tested on Debian and Ubuntu, where the
iptables-servicespackage the role installs does not exist; that is unchanged.