首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >rspec-puppet不支持file_line资源

rspec-puppet不支持file_line资源
EN

Stack Overflow用户
提问于 2015-07-22 19:31:21
回答 1查看 923关注 0票数 1

我有以下关于file_line资源的清单

代码语言:javascript
复制
class login {

  if $::operatingsystemmajrelease < 7 {

    file {'/etc/loginfile':
      ensure => present,
    }

    file_line { 'testfile':
      path   => '/etc/loginfile',
      line   => 'abc 022',
      match  => '^abc.*$',
    }
  }
}

下面是rspec文件

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

describe 'login' do

  it { should contain_class('login')}

  let(:facts) {{:operatingsystemmajrelease => 6}}

  if (6 < 7)
    it { should contain_file('/etc/loginfile').with_ensure('present')}

    it { should contain_file_line('testfile').with(
      :path   => '/etc/loginfile',
      :line   => 'abc 022',
      :match  => '^abc.*$'
    )}
  end
end

当我运行rake-spec命令时,出现以下错误

代码语言:javascript
复制
 login
     Failure/Error: it { should contain_class('login')}
     Puppet::Error:
       Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type file_line at /etc/puppetlabs/modulename/login/spec/fixtures/modules/login_defs/manifests/init.pp:17 on node 
     # ./spec/classes/login_spec.rb:5

rspec将不支持file_line资源?

因为如果我删除了"file_line“资源并运行rsepc文件,它就能正常工作

EN

回答 1

Stack Overflow用户

发布于 2016-06-22 05:06:32

file_line位于puppetlabs-stdlib中,因此您需要将其包含在测试夹具中。

最简单的方法是在.fixtures.yml中:

代码语言:javascript
复制
fixtures:
  repositories:
    stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31561872

复制
相关文章

相似问题

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