Ask Your Question

rspec-puppet - $facts hash is not set

asked 2015-12-11 14:44:20 -0500

bryancornies gravatar image

I'm running some rspec-puppet tests against a Puppet class that uses the $facts hash to retrieve a fact and set it to a local variable. The line in question looks like:

$noop_config = $facts["weblogic_${domain_name}_has_running_servers"]

The reason I need to use the $facts hash is because I'm interpolating a variable name to complete the fact name. I'm not sure if there's any other way to achieve this?

I'm attempting to set the fact in my spec tests like so:

let(:facts) { {
    :kernel => 'Linux',
    :weblogic_best_domain_ever_has_running_servers => true,
  } }

When I run my rspec tests, I get the follow error (see below). I suspect it's because of some difference in the way Puppet manifests get compiled using rspec vs. a "normal" Puppet compilation.

facts is not a hash or array when accessing it with weblogic_best_domain_ever_has_running_servers

Has anyone had any experience using the $facts hash in combination with rspec-puppet tests?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-12-15 08:03:23 -0500

You probably already checked but do you have the latest version of rspec-puppet? If you do, based on the above, I'd be guessing it's an issue in rspec-puppet that needs to be filed as an issue against that project.

edit flag offensive delete link more


Yes, I updated to rspec-puppet 2.2.0, which is the latest as far as I can tell. Same issue still persists. I'll head over to their github project and open an issue and see if I can get some more information. Thanks!

bryancornies gravatar imagebryancornies ( 2015-12-15 10:14:58 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-12-11 14:44:20 -0500

Seen: 315 times

Last updated: Dec 15 '15