Skip to content

Instantly share code, notes, and snippets.

@c10l
Created December 6, 2012 11:57
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c10l/4223941 to your computer and use it in GitHub Desktop.
Save c10l/4223941 to your computer and use it in GitHub Desktop.
Vagrant delete Chef node and Client on destroy
module Vagrant
module Provisioners
class ChefClient
def cleanup
env[:ui].info "Attempting to remove client #{env[:vm].config.vm.host_name}"
`knife client show #{env[:vm].config.vm.host_name}`
if $?.to_i == 0
env[:ui].info "Removing client #{env[:vm].config.vm.host_name}"
`knife client delete #{env[:vm].config.vm.host_name} -y`
end
env[:ui].info "Attempting to remove node #{env[:vm].config.vm.host_name}"
`knife node show #{env[:vm].config.vm.host_name}`
if $?.to_i == 0
env[:ui].info "Removing node #{env[:vm].config.vm.host_name}"
`knife node delete #{env[:vm].config.vm.host_name} -y`
end
end
end
end
end
@lukas0krupa
Copy link

@FractalizeR I was having similar issue, I read most of conversations and no luck with any workaround provided. You may got here as well (hashicorp/vagrant#2476)

Then I tried similar thing, I removed/uninstall vagrant and install it again. However, I got another error, which sounds better:

stderr: WARNING: No knife configuration file found ERROR: Your private key could not be loaded from /etc/chef/client.pem

It might help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment