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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a mechanism to flush un-managed rules #115
base: master
Are you sure you want to change the base?
Provide a mechanism to flush un-managed rules #115
Changes from all commits
78d8286
93077e9
95636ba
3f640a7
019bde3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies not to think of earlier. Should we create a directory via a systemd::tmpfile to stick this file in.
Also question if it needs to be a parameter? Why would you want to change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. Sounds good to me, no objection. We're already depending on the systemd module so all good.
/run/puppet-nft
?Thought it was a good idea to offer it but initially it could be hardcoded. If somebody ever needs to make the path customisable then merge requests are always welcome :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
nft -s list ruleset
will also contain any chains that are present in thenftables::noflush_chains
parameter.Taking the typical use case of fail2ban maintaining a chain we expect that chain to drift almost constantly so ideally we want to ignore those chains when making the comparison to avoid unnecessary reloads.
The reloads themselves will be fine since these noflush chains are already ignored by the reload.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A hard one. The easy exit is to make them mutually exclusive, otherwise we'd have to find a way to remove the dynamic rules when Puppet takes a snapshot of what's in memory. However, having an option that purges unmanaged rules allowing unmanaged rules sounds odd to me so I'm in favour of the mutual exclusivity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we added --json to the dump filtering out the noflush chains to the dump should be doable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would certainly use both options if they were not mutually exclusive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's doable, however this would introduce a dependency on a JSON processor, like
jq
. Unfortunately the objects are not nested when dumped with--json
, so the script would have to iterate overnftables::noflush_tables
and for each element attach a filter like:The filter would probably have to filter by table name and family, as it's legal to have two tables with the same name and different families, making it even uglier.
Ugly but it should work. The script to hash the rules could be used for both dumping (to be called by Systemd as currently proposed) and comparing (to be called by the
Exec
).Another option is to do something similar to puppet.nft.epp and generate an array of managed tables by removing
nftables::noflush_tables
from$facts['nftables']['tables']
. Then sort the array, hash each table independently and then join the hashes and use that string to detect changes. Something like (pseudobash):We'd have to think here if the boostrapping makes sense as
$facts['nftables']['tables']
won't be available during the first run.