Configuring ENV vars from host to guest in Vagrant

Is there any way to install some ENV-vars from host to guest Vagrant OS at boot time? From my guest OS, I need to connect to the database, and I want to transfer the URL of the database from the host to the guest, as well as other parameters.

I tried with TEST="foo" vagrant up, but TEST is nowhere in my env vars on guest os. Any ideas?

+4
source share
2 answers

Your way to change "stray up" will not work. The right way to do this during preparation. There are different methods depending on the backup device used.

, PATH env :

config.vm.provision "shell", inline: "echo " + ENV['PATH']

, Vagrantfile ENV . , .

-, :

  • ENV, Vagrantfile, -
  • ,
  • -, /etc/profile.d/ ,
0

@Romeo: . : fooobar.com/questions/1532982/...

config.vm.provision :shell, path: "scripts/bootstrap.sh", env: {"MYVAR" => ENV['ABC']}

@Sgoettschkes:

0

Source: https://habr.com/ru/post/1532980/


All Articles