From 609ff9f7b299050eb0378642975760752979a98a Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 19 Nov 2015 14:55:46 -0800 Subject: [PATCH] Allow provisioner cleanup task to exit on failure --- .../provisioners/chef/provisioner/chef_client.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/provisioners/chef/provisioner/chef_client.rb b/plugins/provisioners/chef/provisioner/chef_client.rb index d5168efa8..e876703d5 100644 --- a/plugins/provisioners/chef/provisioner/chef_client.rb +++ b/plugins/provisioners/chef/provisioner/chef_client.rb @@ -145,7 +145,20 @@ module VagrantPlugins command = "knife #{deletable} delete #{node_name}" command << " --config '#{guest_client_rb_path}'" command << " --yes" - @machine.communicate.sudo(command, error_check: true) + + output = [] + result = @machine.communicate.sudo(command, error_check: false) do |_, data| + output << data + end + + if result != 0 + @machine.ui.error("There were errors removing the #{deletable} from the Chef Server:") + @machine.ui.error("") + @machine.ui.error(output.join("\n")) + @machine.ui.error("") + @machine.ui.error("Vagrant will continue destroying the virtual machine, but you may need") + @machine.ui.error("to manually delete the #{deletable} from the Chef Server!") + end end end end