Skip to content

Instantly share code, notes, and snippets.

@jtimberman
Created December 11, 2012 05:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtimberman/38ad69522a8eeb5f52be to your computer and use it in GitHub Desktop.
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
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