Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix puppet 3 issue with multiple classes and functions by moving re-initing puppet each catalog compile #61

Closed
wants to merge 1 commit into from

3 participants

@jmslagle

This fixes the issue described in #60 and #58 for me. It passes tests on puppet 3 also.

I'm positive there is a better way to re-initialize the puppet engine, however, I tried calling various clear methods before settling on this with no positive results.

@mitchellh

This doesn't work for me, because Puppet includes a check that raises an exception if this is called more than once:

https://github.com/puppetlabs/puppet/blob/87aaffbf6f0e3d2214bb3056c5481b1c96a4fe09/lib/puppet/settings.rb#L140

@jmslagle

What version of puppet? I've been using the version here for some time locally with no issues. 3.0.1 here.

@mitchellh

@jmslagle Look at the related issues (#60 and #58), which are caused by a known Puppet bug. You can work around by making 1 spec per class or something like that. That is how I am getting around it.

But I just wanted to note that this pull request could just never work.

@mitchellh

Oh sorry, thought you were someone different. If you look at the source code of Puppet no matter what it hits that line and raises an exception. I have no idea how yours is working.

@jmslagle jmslagle closed this
@jmslagle

The fix to puppet seems to address this, however it raises the multiple init thing reported above. rspec-puppet will need modified to no longer init.

@rodjek rodjek referenced this pull request from a commit
@rodjek Fix for Puppet > 3 && < 3.1
From @jmslagle's PR #61
d5c63b8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 16, 2012
  1. @jmslagle
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +0 −4 lib/rspec-puppet.rb
  2. +4 −0 lib/rspec-puppet/support.rb
View
4 lib/rspec-puppet.rb
@@ -6,10 +6,6 @@
require 'rspec-puppet/example'
require 'rspec-puppet/setup'
-if Integer(Puppet.version.split('.').first) >= 3
- Puppet.initialize_settings
-end
-
RSpec.configure do |c|
c.add_setting :module_path, :default => '/etc/puppet/modules'
c.add_setting :manifest_dir, :default => nil
View
4 lib/rspec-puppet/support.rb
@@ -5,6 +5,10 @@ module Support
protected
def build_catalog_without_cache(nodename, facts_val, code)
+ if Integer(Puppet.version.split('.').first) >= 3
+ Puppet.initialize_settings
+ end
+
Puppet[:code] = code
node_obj = Puppet::Node.new(nodename)
Something went wrong with that request. Please try again.