问题
如果变量可以传递给木偶类,例如:
class module_name (
$variable='hello_world'
) {
package { 'package_name': }
}如果运行rspec,则会失败,即:
[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'主要问题
Error from DataBinding while looking up FileSystem implementation expected Pathname,
got: 'Hash' on node配置
版本
[vagrant@vm-one opsview]$ puppet --version
3.7.5
[vagrant@vm-one opsview]$ rspec --version
3.2.2Spec_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! }尝试
发布于 2016-03-15 13:47:28
hiera_config有一个问题,应该是:
c.hiera_config = 'spec/fixtures/hiera/hiera.yaml'假设您的目录结构如下:
\spec
\fixtures
\hiera
hiera.yaml
default.yaml和hiera.yaml
---
:backends:
- yaml
:hierarchy:
- '%{::clientcert}'
- default
:yaml:
:datadir: './spec/fixtures/hiera'hiera-puppet-helper gem确实不是必需的,实际上它不应该存在。我建议使用加雷瑟骨架生成模块结构,它已经包含了Hiera的工作设置,可以节省大量时间。
https://stackoverflow.com/questions/29309341
复制相似问题