Florian Heinle
2 years
Claus-Theodor Riegg
3 years
Claus-Theodor Riegg
3 years
Andreas Vöst
3 years
Claus-Theodor Riegg
8 years

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

Posted Almost 5 years ago. Visible to the public.

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

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'
[...]
Last edit
Almost 5 years ago
Kim Klotz
License
Source code in this card is licensed under the MIT License.