Programatically detect if vagrant has been provisioned

48 views
Skip to first unread message

Andres Montalban

unread,
Mar 1, 2016, 1:15:03 PM3/1/16
to Vagrant
Hey guys,

I'm in the need of detecting if vagrant has been provisioned or not, the goal is to ask the user if bridged network is needed but only do that on the first "vagrant up".

I saw that you have an env variable called "provision_enable" [1] but can't find the way to use it inside Vagrantfile. If not implemented it would be great to have a method say is_provisioned? so we can do other things prior or after a machine is provisioned.

Thank you very much for your help!

Andres,

--

Andres Montalban

unread,
Mar 1, 2016, 2:17:49 PM3/1/16
to Vagrant
For now I have used the following workaround:

  if File.exists?(File.expand_path('.vagrant/machines/default/virtualbox/action_provision')) then
    puts "Machine provisioned"
  else
    puts "Machine NOT provisioned"
  end

But would be great to either be able to use @env or any other solution.

Thanks!
Reply all
Reply to author
Forward
0 new messages