0

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

I want to pass a Windows environment variable into the guest via the Vagrantfile.

Let's call the environment variable ABC

>echo %ABC% 123

I know I can pass static values in as:

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

But I don't know how to translate the env var - this doesn't work (passes literal: %ABC%):

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

Any help appreciated

1 Answers1

4

Cardboard programmer strikes again...

Three minutes after asking the question I found the answer (and I'd already spent three hours looking before I asked)

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

tada!

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103