Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the Vagrantfile folder

Tags:

vagrant

I'm trying to tweak my Vagrantfile so it automatically creates a folder in the project root if it's missing. Creating the folder is no problem, but I'm having trouble finding out where to create that folder.

I was able to figure out that this information is available on a Vagrant::Environment object as cwd, but I can't figure out how to get the current instance from inside my Vagrantfile. The documentation for Vagrant seems to be a bit sparse.

Edit:

My question is not about how to use Puppet. I'm writing some code inside the Vagrantfile. I want to know how to get the current instance of Vagrant::Environment.

like image 202
Sarah G Avatar asked Jun 29 '13 03:06

Sarah G


1 Answers

To find the Vagrantfile directory try this in the Vagrantfile:

vagrant_root = File.dirname(__FILE__)
like image 88
Dave Avatar answered Sep 26 '22 07:09

Dave