Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Chef recipe

Tags:

chef-infra

I am working on a Chef recipe and now I would like to know how debugging of recipes can be done. This seems to be not all straightforward.

For example adding simple log statements is unclear. I can use for example

     Chef::Log.info "My message"

But it is unclear where this message will be logged. It doesn't appear in the chef client run console even with verbose output for example as follows

     knife ssh mynode "sudo chef-client" --manual-list --ssh-user myuser -VV

The best/most advanced way I found so far for debugging to just raise an exception. Not at all advanced.

like image 976
onknows Avatar asked Jan 21 '15 13:01

onknows


1 Answers

Here you're setting knife command as verbose with -VV.

To change chef-client run log level the parameter is -l info or -l debug for its command call.

In your command line it would give (info level, debug is really verbose, and you're loggin at info level in your recipe):

knife ssh mynode "sudo chef-client -l info" --manual-list --ssh-user myuser -VV
like image 109
Tensibai Avatar answered Oct 09 '22 10:10

Tensibai