简体   繁体   中英

Destroy vagrant machine if chef-solo fails

I have 5 machines described in Vagrantfile and have some chef-solo simple recipes. I want to identify machine where chef execution failed.

What I've tried so far: tried to run vagrant up with --destroy-on-error flag so then if on some machine chef-solo fails then I could see them in vagrant status in not created state , but it did not happen. After vagrant up all machines have running state.

Maybe there is a way to configure chef to store execution info somewhere on running machine and then I can have that info with vagrant ssh

How can I do that?

The machines are in running state because vagrant needs the machine to run before it can execute chef provisioning.

what you could do is to set chef running in debug log

Vagrant.configure("2") do |config|
  # ...
  config.vm.provision :chef_solo do |chef|
    # ...
    chef.log_level = :debug
  end
end

I know in the past there were no output to file, it might have changed but I am not sure and output still goes to STDOUT.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM