将环境变量传递给流氓外壳提供程序 [英] Pass environment variables to vagrant shell provisioner
本文介绍了将环境变量传递给流氓外壳提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
vagrant up
看起来像传递环境变量,如果您使用的是Ruby提供程序,则很简单: VAR = 123 vagrant up
在Vagrantfile中: / p>
ENV ['VAR']
如何使用:shell
$ VAR
解决方案
这不太理想,但我现在可以这样工作:
config.vm.provisionshelldo | s |
s.inline =VAR1为$ 1,VAR2为$ 2
s.args =#{ENV ['VAR1']}#{ENV ['VAR2']}
end
It looks like passing environment variables when calling vagrant up
is simple if you're using a Ruby provisioner:
VAR=123 vagrant up
In the Vagrantfile:
ENV['VAR']
How do I do this with the :shell
provisioner? Simply doing this does not seem to work:
$VAR
解决方案
It's not ideal, but I got this to work for now:
config.vm.provision "shell" do |s|
s.inline = "VAR1 is $1 and VAR2 is $2"
s.args = "#{ENV['VAR1']} #{ENV['VAR2']}"
end
这篇关于将环境变量传递给流氓外壳提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文