-
Notifications
You must be signed in to change notification settings - Fork 457
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
Apply firewall resources alphabetically #342
Conversation
|
@hunner @apenney my goal is to add next a |
|
hmmm travis fails with ruby1.8.7. I just tested with master and it also fails so it does not come from my patch. |
|
This PR fixes unit tests : #341 |
|
I merged in #341, can you rebase this one against master? |
|
@apenney done |
|
@apenney now travis is happy ! |
|
+1 works great. |
|
@hunner raised the issue that this causes all further rules to be skipped if a single rule fails to apply for any reason, which is not the current behavior. Do we think that's a significant problem? |
|
It's cool to have an easier way to order rules that are applied first vs. later, but do we want to enforce that rules ordered first in the chain should almost always be applied to the machine first? It's going to overload the semantics of the title leading-numbers, and isn't the normal Puppet Way of ordering resource application. OTOH, I don't want convention to stand in the way of ease-of-use when it wouldn't hurt to add it. |
|
On the plus side you usually want firewall rules applied in a specific order since the first rule that is matched wins and this give an easy way to accomplish that (lots of fun with Cisco ACLs in the past). This also should mean you want all rules to apply top down and probably have a further down rules skipped if a rule before it fails. We don't really want a deny all rule to be processed if our allow port 22 rule failed. You could look at it like the File auto dependency chain between /etc and /etc/hosts, in this case the 000 and 001 are being used to make this auto dependency. Personally I like the idea of knowing how what order all firewall rules will be applied in without having to create a manual requires for each one. But I can also understand it isn't really the normal way, but it does seem to make sense for firewall rules since order matters much more than in a normal puppet run. |
|
Okay. Sounds good. This should probably also come with some updates in the README, as it has a pretty large section dedicated to talking about pre/post classes to avoid locking yourself out of a box. |
|
@hunner README updated. |
|
Would it not make more sense to do this similar to how the Then you don't have to rely upon alphabetically sorting the title, which is problematic in itself. What happens when you have Having an |
|
@phemmer hmmm, if you have If it's ordered If it's ordered I'll try to look at the code to see what order is actually applied. |
|
@mckern that was my point. It is unintuitive for |
|
@phemmer maybe, but my patch is consistent with the ordering convention already applied. So I think your point shouldn't block this PR to be merged. |
|
The concat sorts the same way (alphabetically instead of numerically) and I've always hated that. It's also backwards incompatible to change the ordering to numeric. I'd rather not make the same mistake here. Since we don't yet make guarantees about ordering, it will not be backwards incompatible to merge this. But as soon as we do, it will be backwards incompatible to change the way that ordering works. If possible I'd rather get it right on the first try, now that firewall is 1.x |
|
@hunner changing the ordering to numeric is not tricky at all: autorequire(:firewall) do
catalog.resources.select { |r| (r.class.to_s == "Puppet::Type::Firewall") and (r.name.split(' ')[0].to_i < name.split(' ')[0].to_i) }.sort.last
endBut this will mismatch the actual logic applied in |
|
Sigh, good point. |
Apply firewall resources alphabetically
Revert "Merge pull request #342 from mcanevet/feature/autorequire"
Apply firewall resources alphabetically
This will apply firewall resources by alphabetical order.
This greatly simplify Module usage IMHO.
Just:
No more
Firewall { before => Class['my_fw::post'], require => Class['my_fw::pre'], } class { ['my_fw::pre', 'my_fw::post']: }