我正在使用应用程序cookbook配方来部署java war文件。我想做的是从外部位置加载WAR md5(在本例中是我们的本地nexus存储库)。使用chef从外部位置加载值(比如运行一些将输出字符串的bash输出到STDOUT并将该值用于chef变量)。
像这样的东西bash:
export CHEF_VARIABLE = `wget -O - $/URL/WHICH/RETURNS/TEXT/STRING`
答案 0 :(得分:1)
使用ruby的open-uri。例如,我在用于安装VirtualBox的食谱中这样做。 VirtualBox下载站点有一个带校验和的文本文件(sha256sum)。
require 'open-uri'
sha256sum = "" # retrieve the sha256sums from the virtualbox mirror
open("#{node['virtualbox']['urlbase']}/SHA256SUMS").each do |line|
sha256sum = line.split(" ")[0] if line =~ /#{distfile}/
end
您可以在source on github中查看整个食谱。我可能会将该值设置为应用程序cookbook的配方之外的配方中的属性,然后在节点的运行列表中。