How to transfer Windows host env to Vagrantfile?

I have a Windows 7 host running Vagrant (1.9.1), from which I start the guest VM with CentOS

I want to pass the Windows environment variable to the guest system through Vagrantfile.

Let us call the environment variable ABC

>echo %ABC% 123

I know that I can pass static values ​​like:

config.vm.provision :shell, path: "scripts/bootstrap.sh", env: {"MYVAR" => "123"}

But I do not know how to translate env var - this does not work (passes the literal:% ABC%):

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

Any help appreciated

0
source share
1 answer

The cardboard programmer strikes again ...

Three minutes after answering the question, I found the answer (and I watched it for three hours before I asked)

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

TA-dah!

+1
source

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


All Articles