provisioners/chef: use Subprocess to execute knife

This commit is contained in:
Mitchell Hashimoto 2013-08-29 11:26:21 -07:00
parent 38a6f863e7
commit a8ebd30cb9
2 changed files with 19 additions and 1 deletions

View File

@ -1,4 +1,5 @@
require 'pathname'
require 'vagrant/util/subprocess'
require File.expand_path("../base", __FILE__)
@ -108,7 +109,16 @@ module VagrantPlugins
env[:ui].info(I18n.t(
"vagrant.provisioners.chef.deleting_from_server",
deletable: deletable, name: node_name))
Kernel.system("knife #{deletable} delete --yes #{node_name} > /dev/null 2>&1")
command = ["knife", deletable, "delete", "--yes", node_name]
r = Vagrant::Util::Subprocess.execute(*command)
if r.exit_code != 0
env[:ui].error(I18n.t(
"vagrant.chef_client_cleanup_failed",
deletable: deletable,
stdout: r.stdout,
stderr: r.stderr))
end
end
end
end

View File

@ -25,6 +25,14 @@ en:
CFEngine running in "single run" mode. Will execute one file.
cfengine_single_run_execute: |-
Executing run file for CFEngine...
chef_client_cleanup_failed: |-
Cleaning up the '%{deletable}' for Chef failed. The stdout and
stderr are shown below. Vagrant will continue destroying the machine,
so please clean up these resources manually.
stdout: %{stdout}
stderr: %{stderr}
chef_run_list_empty: |-
Warning: Chef solo run list is empty. This may not be what you want.
provisioner_cleanup: |-