如何在rspec-puppet测试中禁用Hiera调试输出

时间:2015-07-08 11:28:06

标签: rspec puppet

我有以下规范文件

require 'spec_helper'

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

  let(:hiera_config) { 'spec/fixtures/hiera/hiera.yaml' }
  hiera = Hiera.new({ :config => 'spec/fixtures/hiera/hiera.yaml' })

  abc = hiera.lookup('PLC::PLC_LINE',nil,nil)

  let(:hiera_data) {{
    :PLC_LINE => abc
  }}

  it{ should contain_file('/test/rspec/etc/PLC').with(
        'ensure'  => 'file',
        'owner'   => 'root',
        'group'   => 'root',
        'mode'    => '0644',
        'require' => 'File[/test/rspec/etc]') }

  it{ should contain_file('/test/rspec/etc/PLC').with_PLC_LINE(abc)}


end

下面是我的/hiera/fixtures/plc.yaml

plc : puppetlab

当我运行rake spec时,会打印以下消息:

DEBUG: Wed Jul 08 07:11:55 -0400 2015: Hiera YAML backend starting
DEBUG: Wed Jul 08 07:11:55 -0400 2015: Looking up plc::plc_LINE in YAML backend
DEBUG: Wed Jul 08 07:11:55 -0400 2015: Looking for data source plc

如何抑制此输出?

1 个答案:

答案 0 :(得分:0)

刚刚加入spec_helper.rb以下:

Puppet::Util::Log.level = :warning

在客户端,您可以轻松查看log_level

puppet config print log_level --section agent

你可以在例如: /etc/puppet/puppet.conf(取决于你的配置的路径):

[agent]
log_level = info