如何将Windows主机环境传递到Vagrantfile? [英] How to pass Windows host env into Vagrantfile?
问题描述
我有一台运行Vagrant(1.9.1)的Windows-7主机,从中启动了CentOS来宾VM
I have a Windows-7 host running Vagrant (1.9.1), from which I start a CentOS guest VM
我想通过Vagrantfile将Windows环境变量传递给来宾.
I want to pass a Windows environment variable into the guest via the Vagrantfile.
我们将环境变量称为ABC
Let's call the environment variable ABC
>echo %ABC%
123
>echo %ABC%
123
我知道我可以通过以下方式传递静态值:
I know I can pass static values in as:
config.vm.provision :shell, path: "scripts/bootstrap.sh", env: {"MYVAR" => "123"}
但是我不知道如何翻译环境变量-这是行不通的(通过原义:%ABC%):
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%"}
任何帮助表示赞赏
推荐答案
纸板程序员再次罢工...
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']}
多田!
这篇关于如何将Windows主机环境传递到Vagrantfile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!