Read more

Debug Puppet "Error: Failed to apply catalog: undefined method [...] for nil:NilClass"

Kim Klotz
May 22, 2019Software engineer at makandra GmbH

If you get e.g. this error message when you try to run puppet agent:

Error: Failed to apply catalog: undefined method `strip' for nil:NilClass
Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

you could have a very bad time debugging it. Because there will be no messages in the logs which could help you.

You should always remember puppet agents --trace option, because that's probably the only way how you can track this error. For example if you have an unparsable mail aliases file you will get this:

# puppet agent --test --trace --noop
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Applying configuration version '1558534846'
Error: Failed to apply catalog: undefined method `strip' for nil:NilClass
/usr/local/lib/ruby/site_ruby/2.4/puppet/provider/mailalias/aliases.rb:28:in `process'
/usr/local/lib/ruby/site_ruby/2.4/puppet/util/fileparsing.rb:152:in `handle_record_line'
/usr/local/lib/ruby/site_ruby/2.4/puppet/util/fileparsing.rb:244:in `block in parse_line'
/usr/local/lib/ruby/site_ruby/2.4/puppet/util/fileparsing.rb:240:in `each'
/usr/local/lib/ruby/site_ruby/2.4/puppet/util/fileparsing.rb:240:in `parse_line'
[...]
Posted by Kim Klotz to makandra Operations (2019-05-22 16:33)