如何从Beaker启用Puppet的调试日志记录级别

时间:2015-11-08 16:24:43

标签: ruby logging rspec puppet beaker

我有一些var $root = $('html, body'); $('a').click(function() { var href = $.attr(this, 'href').replace('#',''); $root.animate({ scrollTop: $('[id="'+href +'"]').offset().top }, 500, function () { window.location.hash = href; }); return false; }); 验收测试,涵盖我正在创建的Puppet模块,并且想知道如何在底层Puppet调用上启用调试日志记录(例如,确切地知道当我调用{{1}时会发生什么})。我很确定我已经能够在Beaker本身上进行调试日志记录(beaker-rspec?),但这似乎只能告诉我 Beaker 正在做什么,不一定是Puppet。

如果有帮助,这里有一些相关的文件片段:

apply_manifest

export BEAKER_debug=yes

spec/fixtures/spec_helper_acceptance.rb

require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
require 'beaker/librarian'

RSpec.configure do |c|
  module_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))

  c.formatter = :documentation

  # Configure all nodes in nodeset
  c.before :suite do
    install_puppet
    install_librarian
    librarian_install_modules(module_root, 'mymodule')
  end
end

我实际上是想弄清楚为什么spec/acceptance/example_spec.rb测试失败了,但此刻我才得到

require 'spec_helper_acceptance'

apply_manifest_opts = {
  :catch_failures => true,
  # I seem to need this otherwise Puppet doesn't pick up the required modules.
  # Is this where I can also enable debug logging in Puppet? 
  :modulepath     => '/etc/puppetlabs/puppet/modules/',
}

default_pp = <<-EOS
  class { 'mymodule': }
EOS

describe 'the mymodule class' do
  describe 'given default params' do
    it 'should return successfully' do
      expect(apply_manifest(default_pp, apply_manifest_opts).exit_code).to be_zero
    end
  end
end

这没什么帮助。你看到我的问题吗?

我会接受直接回答我的问题的回复,或者给我一些其他方法来解决为什么退出代码非零。

1 个答案:

答案 0 :(得分:0)

我的预感是正确的,它只需要提供给apply_manifest的额外选项。我花了一段时间才弄清楚文档的确切位置。

apply_manifest_opts = {
  :catch_failures => true,
  # I seem to need this otherwise Puppet doesn't pick up the required modules. 
  :modulepath     => '/etc/puppetlabs/puppet/modules/',
  :debug          => true,
}

来源:

http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Helpers/PuppetHelpers#apply_manifest_on-instance_method