Chef infra Opscode Chef:具有headers属性的提供程序远程\u文件

Chef infra Opscode Chef:具有headers属性的提供程序远程\u文件,chef-infra,recipe,Chef Infra,Recipe,根据此版本: 远程文件提供程序具有属性“headers” 我想这样使用它: remote_file "foo" do source "http://someurl" headers({"Cookies" => "Some cookie"}) end 然而,这并不像预期的那样工作,我的意思是,我想没有使用标题。 这是正确的sintax?这对我来说在Chef10和Chef11中都有效。事实上,这个特性并没有文档记录——至少,我必须深入研究Chef的源代码,以了解如何传递cooki

根据此版本:

远程文件提供程序具有属性“headers”

我想这样使用它:

remote_file "foo" do
   source "http://someurl"
   headers({"Cookies" => "Some cookie"})
end
然而,这并不像预期的那样工作,我的意思是,我想没有使用标题。
这是正确的sintax?

这对我来说在Chef10和Chef11中都有效。事实上,这个特性并没有文档记录——至少,我必须深入研究Chef的源代码,以了解如何传递cookies。远程文件不支持此操作。但是我们可以使用一些“隐藏的”厨师机制来设置cookies,以满足对特定域和端口的每个请求

ruby_block "Prepare cookies for download from http://someurl" do
  block do
    Chef::REST::CookieJar.instance["someurl:80"] = "Some cookie"
  end
end

remote_file "foo" do
   source "http://someurl"
end
其中[“someurl:80”]应该是具有端口的整个域。比如说,

Chef::REST::CookieJar.instance["download.oracle.com:80"] = Chef::REST::CookieJar.instance["edelivery.oracle.com:443"] = "oraclelicense=accept-securebackup-cookie"

这可以用于从oracle站点下载java,而无需手动接受许可协议。

这不是解决方案。。但这是一个解决办法

# install wget
windows_package "wget" do
   source "http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-setup.exe"
   action :install
end

# Java uninstall, download and install
windows_batch "jre-7 installation" do
  code <<-EOH
     WMIC product where "Name LIKE '%%Java 7%%'" call uninstall /nointeractive
     "C:/Program Files (x86)/GnuWin32/bin/wget.exe" -O C:/chef/cache/jre-7.exe --no-check-certificate  --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com;" http://download.oracle.com/otn-pub/java/jdk/7u25-b17/jdk-7u25-windows-x64.exe
      C:/chef/cache/jre-7.exe /s
 EOH
end
#安装wget
windows_软件包“wget”do
来源“http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-setup.exe"
操作:安装
结束
#Java卸载、下载和安装
windows_批量“jre-7安装”do
代码