Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to debug chef recipes from the vagrant box?

i'm struggling with the chef recipes for a vagrant box. I'm using chef-solo.

I'm not so comfortable with Ruby (i've never used it before), so the process to write my recipes is very long if i have to do vagrant provision each time.

Is there a way to debug a specific recipe? Even from the virtual machine shell.

I've seen that chef-shell exists (http://docs.opscode.com/chef_shell.html), and i can launch it (it works) when i'm inside the virtual machine, but i can't understand how to load my recipes and test them.

like image 616
apelliciari Avatar asked Jun 30 '13 09:06

apelliciari


3 Answers

The proper way to enable debug output in the current vagrant chef provisioner is with chef.log_level, not with chef-solo manually or with chef.arguments:

Vagrant.configure("2") do |config|
  # ...
  config.vm.provision :chef_solo do |chef|
    chef.log_level = :debug
    # ...
  end
end
like image 66
benh57 Avatar answered Oct 25 '22 22:10

benh57


In addition to the above input, which is execllent;-)

Runing chef-solo in debug mode (enable debug output) will definitely help.

For example

chef-solo -c solo.rb -j node.json -l debug

like image 45
Terry Wang Avatar answered Oct 25 '22 22:10

Terry Wang


If you run chef-solo inside Vagrant additional custom arguments (for logging/debugging) can be injected from the Vagrantfile like this:

 Vagrant.configure("2") do |config|
    # ...
    config.vm.provision :chef_solo do |chef|
      chef.arguments = '-l debug'
      # ...
    end
 end
like image 32
jugglefish Avatar answered Oct 25 '22 23:10

jugglefish