使用流浪者,是否可以将从vagrant up {args}
的参数传递到配置文件?流浪者从命令行传递参数到配置文件
我希望人们能够在他们的github帐户名传递,这样我可以把它传递给供应文件 - 是这样的:
vagrant up iwayneo
和iwayneo
随后被传递到供应文件 - 这是可能?
如果我做的在被vagrant up
跑前一个sh脚本如下:
echo "Please enter the local username - for vagrant boxes enter vagrant:"
read uname
export LOCALUSER=$uname
echo " " >> ~/.bashrc
echo "LOCALUSER=$uname" >> ~/.bashrc
echo "Please enter the bitbucket username:"
read bbuname
export BITBUCKETUSER=$bbuname
echo " " >> ~/.bashrc
echo "BITBUCKETUSER=$bbuname" >> ~/.bashrc
echo "Please enter bitbucket password:"
read bbpass
export BITBUCKETPASS=$bbpass
echo " " >> ~/.bashrc
echo "BITBUCKETPASS=$bbpass" >> ~/.bashrc
echo "configured for local username $uname, bitbucket username $bbuname and bitbucket pass $bbpass"
source ~/.bashrc
然后在我的流浪者文件中的以下内容:
puts "Current user is #{ENV['LOCALUSER']}"
if !ENV.has_key?("LOCALUSER")
raise "Please specify the `LOCALUSER` environment variable - you can do this by running config.sh"
end
if !ENV.has_key?("BITBUCKETUSER")
raise "Please specify the `BITBUCKETUSER` environment variable - you can do this by running config.sh"
end
if !ENV.has_key?("BITBUCKETPASS")
raise "Please specify the `BITBUCKETPASS` environment variable - you can do this by running config.sh"
end
的LOCALUSER加薪被称为和puts "Current user is #{ENV['LOCALUSER']}"
收益Current user is
所以它绝对不会采取。我不得不使用单线格式来做它?有没有办法做到这一点不使用这种格式?
批注。答案是正确的,但这里的任何帮助将是非常赞赏
完美!谢谢。我正在用各种令人费解的方式挣扎,但这看起来像 – iwayneo 2014-10-29 11:32:18
看起来这不起作用 - 我已经更新我的q – iwayneo 2014-10-30 09:14:40
我(希望)在我编辑的答案中解决你的问题。 – tmatilai 2014-10-30 13:04:07