I have some beaker-rspec
acceptance tests covering a Puppet module I am creating, and would like to know how to enable debug logging on the underlying Puppet calls (e.g., know exactly what happens when I call apply_manifest
). I'm pretty sure I've been been able to get debug logging working on Beaker itself (export BEAKER_debug=yes
?), but that only seems to tell me what Beaker is doing, not necessarily Puppet.
If it helps, here are some relevant file snippets:
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
I'm actually trying to work out why the the mymodule class given default params should return successfully
test fails, but at the moment I only get
Failure/Error: expect(apply_manifest(default_pp, apply_manifest_opts).exit_code).to be_zero
expected `2.zero?` to return true, got false
which is not much help. Do you see my problem?
I'll accept responses that either answer my question directly, or give me some other way to work out why the exit code is non-zero.
I was right on my hunch that it just needed an extra option supplied to apply_manifest
. It just took me a while to work out exactly where the documentation was on how to do it.
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,
}
Source: