Created
December 6, 2012 11:57
-
-
Save c10l/4223941 to your computer and use it in GitHub Desktop.
Vagrant delete Chef node and Client on destroy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
@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
What if Vagrant is configured to take node name from somewhere? Mine is configured like this:
NODE_FILE = "./chef.node"
I think in this case this snippet will not work. Also it gives an error:
rubygems_integration.rb:252:in
block in replace_gem': chef is not part of the bundle. Add it to Gemfile.`