Marshall Æon
Marshall Æon

Reputation: 407

How to prevent "vagrant halt" for production machine?

On my team, we're using vagrant for both development (dev) and production (web).

It works great, but sometimes, my team will accidentally run vagrant halt to halt their dev server, but this also brings down the production (web) server. Yikes!

Is there anyway for me to prevent them from halting the production server? Like disabling the command or password protecting?

Upvotes: 0

Views: 152

Answers (2)

tmatilai
tmatilai

Reputation: 4176

vagrant-managed-servers plugin might help when using Vagrant with production servers.

Upvotes: 2

Matt Cooper
Matt Cooper

Reputation: 10880

Try adding the following to the top of your Vagrantfile:

Vagrant.configure("2") do |config|
    if ARGV[0] == 'halt'
      if ARGV[1] != 'dev'
        puts "Sorry! No way I am letting you do that!"
        ARGV.clear
      end
    end
end

What this does is it looks at the command line arguments supplied to Vagrant and if you just run vagrant halt it will not allow it to happen. If you run vagrant halt dev however it would allow the command through and it would halt only the box called dev

Upvotes: 2

Related Questions