why do you need to be in the specified directory when creating multi-boxes in vagrant

StackOverflow https://stackoverflow.com/questions/21831873

  •  12-10-2022
  •  | 
  •  

Domanda

I'm trying to create multiple-boxes to be loaded by vagrant when writing

vagrant up kali
vagrant up metasploitable2

The Config I have set-up are

Within the Kali VagrantFile

Vagrant.configure("1") do |config|

config.vm.define "kali" do |kali|
kali.vm.box = "Kali"
end
end

Within the Metasploitable2

Vagrant.configure("1") do |config|

config.vm.define "metasploitable2" do |metasploitable2|
metasploitable2.vm.box = "metasploitable2"
end
end

If I browse to the directory where the .vmdk and Vagrantfile are located and say

vagrant up kali 

it creates the kali image, however if i'm not in the directory it won't load the VM.

with an error:

The machine with the name 'kali' was not found configured for
this Vagrant environment.

I'm going to presume this is because it's not being able to read the configuration file, but how can i make this globally because I thought you weren't supposed to modify the 'global' vagrantfile at all.

È stato utile?

Soluzione

Well, Vagrant has to find the Vagrantfile to read it, doesn't it? =)

So you either have to be in the same directory or any subdirectory below it. Or you can set VAGRANT_CWD environment variable to point to the directory. See the "Lookup Path" section in the Vagrantfile documentation for more information.

You can of course make wrapper script or other shortcuts if you need to use that often.

Btw, you might want to upgrade your Vagrantfiles to use V2 configuration format to use all new features of Vagrant 1.1+.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top