首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过hiera调用其他类在rspec-puppet中不起作用

通过hiera调用其他类在rspec-puppet中不起作用
EN

Stack Overflow用户
提问于 2015-08-20 19:25:57
回答 1查看 198关注 0票数 0

我在为hiera_hash使用rspec-puppet时遇到了一个问题

下面是第一个示例

代码语言:javascript
复制
class users {

  include users::example1
  }

class users::example1 {

 $abc = {
    'example1' => {
      'ensure'   => 'present',
      'shell'    => '/usr/bin/ksh',
      'home'     => '/home/example1',
      password'  => 'xxxxxxxx',
      'mode'     => '0700',
    }
  }
  create_resources('users::example1',$abc)
}

我为此编写了rspec,请在下面找到它

代码语言:javascript
复制
require 'spec_helper'

describe 'users', :type => 'class' do

  it { should contain_class('users::example1')}
end

它工作正常,没有任何问题。

下面是第二个示例

代码语言:javascript
复制
class env {
      include env::filetype
    }

class env::filetype {

  $tmp = hiera_hash('env::abc')
  create_resources('logical::myfile, $tmp)
}

当我运行清单时,出现以下错误

代码语言:javascript
复制
Failures:

  1) env should contain Class[env::filetype]
     Failure/Error: it { should contain_class('env::filetype')}
     Puppet::Error:
       Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type logical::myfile at /etc//puppet/modules/env/spec/fixtures/modules/env/manifests/filetype.pp:7 on node 
     # ./spec/classes/env_spec.rb:5

Finished in 0.20231 secondsI 1 example, 1 failure

所以,我怀疑rspec-puppet测试用例hiera只能在同一个模块中工作,如果我们在hiera中调用任何其他类来传递数据,那么它将不支持rspec-puppet。

如果是这样,我们如何实现这是rspec-puppet

EN

回答 1

Stack Overflow用户

发布于 2015-08-21 19:33:24

错误是非常具体的:

代码语言:javascript
复制
ArgumentError: Invalid resource type logical::myfile at /etc//puppet/modules/env/spec/fixtures/modules/env/manifests/filetype.pp:7

这可能意味着rspec-puppet不能使用logical模块。确保该模块是测试套件的fixture的一部分。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32116982

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档