Perform Chef delete operations on the guest instead of the host
This commit is contained in:
parent
09890644c6
commit
f999218c53
|
@ -63,12 +63,6 @@ module VagrantPlugins
|
|||
errors << I18n.t("vagrant.config.chef.validation_key_path")
|
||||
end
|
||||
|
||||
if delete_client || delete_node
|
||||
if !Vagrant::Util::Which.which("knife")
|
||||
errors << I18n.t("vagrant.chef_config_knife_not_found")
|
||||
end
|
||||
end
|
||||
|
||||
{ "chef client provisioner" => errors }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,8 +31,8 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def cleanup
|
||||
delete_from_chef_server('client') if @config.delete_client
|
||||
delete_from_chef_server('node') if @config.delete_node
|
||||
delete_from_chef_server('client') if @config.delete_client
|
||||
end
|
||||
|
||||
def create_client_key_folder
|
||||
|
@ -116,6 +116,10 @@ module VagrantPlugins
|
|||
end
|
||||
end
|
||||
|
||||
def guest_client_rb_path
|
||||
File.join(guest_provisioning_path, "client.rb")
|
||||
end
|
||||
|
||||
def guest_validation_key_path
|
||||
File.join(guest_provisioning_path, "validation.pem")
|
||||
end
|
||||
|
@ -130,23 +134,13 @@ module VagrantPlugins
|
|||
return
|
||||
end
|
||||
|
||||
@machine.ui.info(I18n.t(
|
||||
"vagrant.provisioners.chef.deleting_from_server",
|
||||
@machine.ui.info(I18n.t("vagrant.provisioners.chef.deleting_from_server",
|
||||
deletable: deletable, name: node_name))
|
||||
|
||||
# Knife is not part of the current Vagrant bundle, so it needs to run
|
||||
# in the context of the system.
|
||||
Vagrant.global_lock do
|
||||
command = ["knife", deletable, "delete", "--yes", node_name]
|
||||
r = Vagrant::Util::Subprocess.execute(*command)
|
||||
if r.exit_code != 0
|
||||
@machine.ui.error(I18n.t(
|
||||
"vagrant.chef_client_cleanup_failed",
|
||||
deletable: deletable,
|
||||
stdout: r.stdout,
|
||||
stderr: r.stderr))
|
||||
end
|
||||
end
|
||||
command = "knife #{deletable} delete #{node_name}"
|
||||
command << " --config '#{guest_client_rb_path}'"
|
||||
command << " --yes"
|
||||
@machine.communicate.sudo(command, error_check: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue