Problem
If variables can be passed to a Puppet class, e.g.:
class module_name (
$variable='hello_world'
) {
package { 'package_name': }
}
and rspec
is run it fails, i.e.:
[user@host module_name]$ rspec
...............................FFFFFFFFFFFF..........................................
Failures:
1) opsview should contain Class[module_name]
Failure/Error: it { should contain_class('module_name') }
Puppet::Error:
Error from DataBinding 'hiera' while looking up 'module_name::variable':
FileSystem implementation expected Pathname, got: 'Hash' on node host
# /usr/share/ruby/vendor_ruby/puppet/resource.rb:393:
in `rescue in lookup_with_databinding'
# /usr/share/ruby/vendor_ruby/puppet/resource.rb:387:
in `lookup_with_databinding'
# /usr/share/ruby/vendor_ruby/puppet/resource.rb:381:
in `lookup_external_default_for'
Main issue
Error from DataBinding while looking up FileSystem implementation expected Pathname,
got: 'Hash' on node
Configuration
Versions
[vagrant@vm-one opsview]$ puppet --version
3.7.5
[vagrant@vm-one opsview]$ rspec --version
3.2.2
Spec_helper
[vagrant@vm-one opsview]$ cat spec/spec_helper.rb
require 'rspec-puppet'
require 'hiera-puppet-helper'
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
RSpec.configure do |c|
c.module_path = File.join(fixture_path, 'modules')
c.manifest_dir = File.join(fixture_path, 'manifests')
c.hiera_config = '/etc/puppet/hiera.yaml'
end
at_exit { RSpec::Puppet::Coverage.report! }
Attempt
- According to this Q&A
hiera-puppet-helper
is causing the issue. Rspec-puppet seems to support testing of hiera and 'hiera-puppet-helper' could be replaced. Ok perhaps this solves the issue, but what is causing the issue? - This post contains the same issue, but not a solution to solve the issue
- This post indicates that removing the class parameters solves the issue, but this class is used by multiple modules and therefore this is not a solution.
Aucun commentaire:
Enregistrer un commentaire