-
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
Initial creation of class firewall for issue #10984 #34
Conversation
| @@ -0,0 +1,3 @@ | |||
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 think this file probably can be removed IMHO. It's not that useful from a unit test perspective. Better to use rspec-puppet for testing.
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.
Agreed. I added it because puppet-module would create it. However, it seems I did it wrong.
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.
Yeah - I'm not a fan of the scaffold we use for puppet-module. Its not bad for most things, but there are parts I don't agree with. I probably should help fix that instead of whinging about it right? :-).
|
So generally:
|
|
I'm working on future-proofing against Squeeze and Wheezy. Meanwhile, are there any working examples of rspec-puppet that I can reference? I'm very much a ruby neophyte. |
|
Sure. Well rpec-puppet isn't the easiest of things but I believe rodjek's project has some sweet docs these days. https://github.com/rodjek/rspec-puppet You'll need the rspec and mocha gems for any testing - plus the rspec-puppet gem of course (I just use 'gem' & 'rvm' on my mac). So the idea is ... if you want to test that on debian for example a file gets created, you mock those facts: Then using this kind of describe you declare that you are analyzing a class context: And inside you want an example that makes sure in the context the correct file is installed. Putting it all together in say spec/classes/firewall_spec.rb (the path is magic and implies the firewall class in this case): You can then see if it works with: Other examples: You starting to get the idea? Even if you do the most basic of tests, its going to:
So yeah - I'm happy to help if you need it ... I don't want make this feel overwhelming so if you want to pair up on this patch or you want me to help just let me know. |
| } | ||
| it { should contain_service('iptables-persistent') } | ||
| end | ||
| end |
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.
This doesn't work yet.
Failures:
- firewall Debian Lenny tests
Failure/Error: it { should contain_service('iptables-persistent') }
Puppet::Error:
Could not find class firewall for testhost at line 2 on node testhost./spec/classes/firewall_spec.rb:14:in `block (3 levels) in <top (required)>'
Definitely seeking insight here.
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.
So ... you need to do this:
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -8,6 +8,7 @@ require 'puppet'
require 'mocha'
gem 'rspec', '>=2.0.0'
require 'rspec/expectations'
+require 'rspec-puppet'
# So everyone else doesn't have to include this base constant.
module PuppetSpec
@@ -31,6 +32,8 @@ end
RSpec.configure do |config|
include PuppetSpec::Fixtures
+ config.module_path = File.join(File.dirname(__FILE__), '../../')
+
config.mock_with :mocha
config.before :each do
@@ -47,7 +50,7 @@ RSpec.configure do |config|
# Set the confdir and vardir to gibberish so that tests
# have to be correctly mocked.
- Puppet[:confdir] = "/dev/null"
Puppet[:vardir] = "/dev/null"
# Avoid opening ports to the outside world
@@ -79,4 +82,5 @@ RSpec.configure do |config|
GC.enable
end
And the directory needs to be 'firewall' for the autoloader to do the right thing. I'd love a workaround for that though ... I guess there might be a way to do an explicit 'import' somehow before the tests run.
|
Ok, tests implemented! This is ready for final review. |
| } | ||
| exec { 'set-ipv6-iptables-policy': | ||
| command => '/sbin/service ip6tables restart', | ||
| subscribe => File[$ip6tables_config], |
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.
Where does ip6tables_config come from? I can't see it defined elsewhere in the code.
* Add Exec[firewall-persist] to save rules. This allows the host to have iptables rules on reboot, before puppet runs. * Debian hates you. Add iptables init scripts for loading iptables at boot on releases of Debian that do not have them already. * Add brains to the iptables/ip6tables providers to ensure kernel modules are loaded.
Initial creation of class firewall for issue #10984
|
Is there a way to reopen this pull request so it gets merged ? |
|
I'd love to see this merged as well. As it stands, I backported this into a site-specific class on my local configuration. Can pull requests be re-opened, or do you have to file another one? |
Initial creation of class firewall for issue #10984
have iptables rules on reboot, before puppet runs.
modules.
boot on Debian.