使用流浪者,是否可以將從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