【问题标题】:How to enable Puppet's debug logging level from Beaker如何从 Beaker 启用 Puppet 的调试日志记录级别
【发布时间】:2015-11-09 01:04:42
【问题描述】:

我有一些 beaker-rspec 验收测试涵盖了我正在创建的 Puppet 模块,并且想知道如何在底层 Puppet 调用上启用调试日志记录(例如,确切知道当我调用 apply_manifest 时会发生什么)。我很确定我已经能够在 Beaker 本身 (export BEAKER_debug=yes?) 上进行调试日志记录,但这似乎只是告诉我 Beaker 在做什么,不一定是 Puppet。

如果有帮助,这里有一些相关的文件sn-ps:

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

我实际上正在尝试找出 the mymodule class given default params should return successfully 测试失败的原因,但目前我只得到了

Failure/Error: expect(apply_manifest(default_pp, apply_manifest_opts).exit_code).to be_zero
       expected `2.zero?` to return true, got false

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

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

【问题讨论】:

    标签: ruby logging rspec puppet beaker


    【解决方案1】:

    我的直觉是正确的,它只需要为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

    【讨论】:

      猜你喜欢
      • 2012-03-03
      • 1970-01-01
      • 1970-01-01
      • 2018-08-03
      • 1970-01-01
      • 2011-10-17
      • 1970-01-01
      • 2017-01-03
      • 1970-01-01
      相关资源
      最近更新 更多