-
-
Save jtimberman/38ad69522a8eeb5f52be to your computer and use it in GitHub Desktop.
Put this at the end of a Vagrantfile that uses the chef-client provisioner
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 < Chef | |
def cleanup | |
if env[:vm].config.vm.host_name | |
puts `sh -c 'knife client delete #{env[:vm].config.vm.host_name} -y'` | |
puts `sh -c 'knife node delete #{env[:vm].config.vm.host_name} -y'` | |
else | |
puts "No host_name was defined for the box... unable to remove it from chef" | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment