Search code examples
filevagrantdirectoryvagrantfilechef-solo

Custom paths for Vagrant's files and dirs


I started use Vagrant (+ chef_solo) for my App, and now App's folder contain following files and dirs:

  ... app's files

  .vagrant
  Vagrantfile

  Cheffile
  Cheffile.lock

  data_bags

  cookbooks
  projects_cookbooks

  ... app's files

It will be great if I can move files related with Vagrant into special directory. I mean something like this:

  ... app's files

  .vagrant
  Vagrantfile

  Vagrant
    Cheffile
    Cheffile.lock

    data_bags

    cookbooks
    projects_cookbooks

  ... app's files

In this case I will get only 3 files (dirs) in the root folder of my App

  ... app's files

  .vagrant
  Vagrantfile
  Vagrant

  ... app's files

I think it will be very good for me and my project.

So, I want to restucture file structure of Vargant files.

Anybody knows how can I do that? Or stucture of Vargant files is totally hardcoded?


Solution

  • I think I found a way to make my app's folder better. If you want to cleanup your project's folder just do following:

    (I mean APP is folder of your project on HOST machine)

    1) Create Vagrant folder in APP folder

    2) move following files

    .vagrant
    Cheffile
    Cheffile.lock
    Vagrantfile
    cookbooks
    cookbooks_addons
    bata_bags
    ... and all Vagrant-related files
    

    into APP/Vagrant folder

    3) Add additional line in Vagrant file

    config.vm.synced_folder '..', '/APP'
    

    That is all. Now you have all Vagrant-related files into Vagrant folder

    Now you should use vagrant up, vagrant ssh, vagrant halt into APP/Vagrant folder.

    And you should use /APP folder in Virtual Machine to get access to yours project code.

    Looks pretty good for me!