Shared folders: Different folders for different vagrant boxes...possible?

20 views
Skip to first unread message

jason.wi...@gmail.com

unread,
Sep 2, 2020, 4:29:58 PM9/2/20
to Vagrant

hey everyone.
I need to have the ability to use synced folders with a multi vm box setup. The caveat is, I need to map the folder to each box differently.
For example,
box 1 maps to .data/web1
box 2 maps to .data/web2

and so forth.
I have different things i need to manipulate in each folder (web dev stuff) then see how it renders in the web server.

Is that possible to do?
I'll start with that and see how it goes.

Thank you.

dnmo...@gmail.com

unread,
Sep 3, 2020, 8:39:12 AM9/3/20
to Vagrant
It is certainly possible. In your loop


itr = [
  "bento/centos-6.7",
  "bento/centos-7.2",
  "bento/ubuntu-18.04",
  "bento/debian-9"
]

Vagrant.configure(2) do |config|

   itr.each_with_index do |os, index|

      if os == ' bento/ubuntu-18.04' then
         #do some OS Specific stuff
      end

   end
end

jason.wi...@gmail.com

unread,
Sep 3, 2020, 2:33:53 PM9/3/20
to Vagrant
Got it. So in my case, i do a 'loop' where I build X number of boxes as needed, where i specify a hostname, ip address (which both increment by 1 for unique hosts and IPs).

I think what i need to figure out and test is where to put the logic in my vagrant file and make sure i pre-create the folders for the boxes.

Is this the only way? Is there a better way?
I ask because sometimes I spin up several webservers (sometimes 1, sometimes 4) and if i do not have 4 pre-created folders, then i will be missing something.

Just wondering, is there maybe aplugin?

Appreciate the help

JW
Reply all
Reply to author
Forward
0 new messages