vagrant-digitalocean
vagrant-digitalocean copied to clipboard
'vagrant rebuild' should ask for confirmation before destroying a droplet
I just lost a droplet to 'vagrant rebuild'. It should provide the same confirmation as the usual 'vagrant destroy'.
Luckily the droplet I accidentally destroyed wasn't super important.
@eyemyth Something you could try that would solve this for you in your setups is to use the vagrant-triggers plugin to put up a warning. I've done that here, and you're welcome to copy that snippet into your own project if you'd like:
# verify with user before allowing a rebuild to take place
conf.trigger.before :rebuild do
confirm = nil
until ["Y", "y", "N", "n"].include?(confirm)
puts "The rebuild command is a potentially destructive operation. All data on the VM will be erased!"
confirm = ask "Are you sure you want to rebuild the VM? [y/N] "
end
exit unless confirm.upcase == "Y"
end
Damn! Just accidently lost a droplet too :( Restored from 3-days ago backup but anyway too dangerous operation. And btw I was trying just to see a command help
vagrant rebuild --help
So I got help message and command rebuild
executed right after it. So first of my hosts has been lost immediately without any prompt. And I am completely disagree about this is nice-to-have
feature - it should be must-have
mandatory feature.
@davidalger script is very useful but no doubts it should be default behaviour without any additional scripts.