5

I'd like to have one Vagrantfile for multiple different OS types (e.g. windows and linux). I'm currently attempting to do something like this:

...
if config.vm.guest.to_s == "windows"
    # ... do something windows specific
else
    # ... do something linux specific
end

However, config.vm.guest returns an Object instance, not a string or a symbol, even though it was set in the base box Vagrant file (i.e. config.vm.guest = :windows).

How can I do this?

d0c_s4vage
  • 3,947
  • 6
  • 23
  • 32

1 Answers1

0

I'll bet you're trying to do this in a ~/.vagrant.d/Vagrantfile. The problem is that ~/.vagrant.d/Vagrantfile is run before the Vagrantfile in your current directory.

So it cannot know anything about the configuration before hand.

docwhat
  • 11,435
  • 6
  • 55
  • 54