Chef - Recipe包找不到候选版本

时间:2017-05-25 15:03:28

标签: jenkins package chef chef-recipe

我正在使用Chef安装和配置一个非常基本的Jenkins安装。当我尝试运行以下配方时:

include_recipe "apt::default"

apt_repository "jenkins" do
  uri "http://pkg.jenkins-ci.org/debian"
  key "http://pkg.jenkins-ci.org/debian/jenkins-ci.org"
  components ["binary/"]
  action :add
end

package "jenkins" do
  version '2.62'
end


service "jenkins" do
  supports [:stop, :start, :restart]
  action [:start, :enable]
end

我收到以下错误(显示在终端中):

192.168.9.207 [2017-05-25T10:50:58-04:00] ERROR: Running exception handlers
192.168.9.207 Running handlers complete
192.168.9.207 [2017-05-25T10:50:58-04:00] ERROR: Exception handlers complete
192.168.9.207 Chef Client failed. 2 resources updated in 20 seconds
192.168.9.207 [2017-05-25T10:50:58-04:00] INFO: Sending resource update report (run-id: 2b59b80e-b787-4e93-805b-837b4d3264fb)
192.168.9.207 [2017-05-25T10:50:58-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
192.168.9.207 [2017-05-25T10:50:58-04:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
192.168.9.207 [2017-05-25T10:50:58-04:00] ERROR: apt_package[jenkins] (jenkins-installation::default line 21) had an error: Chef::Exceptions::Package: No candidate version available for jenkins
192.168.9.207 [2017-05-25T10:50:58-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

该错误解释了Jenkins没有可用的候选版本。运行失败后,如果我在受管节点上运行sudo apt-get update,则会收到以下错误:

Err http://pkg.jenkins-ci.org trusty/binary/ amd64 Packages                    
  404  Not Found
Err http://pkg.jenkins-ci.org trusty/binary/ i386 Packages           
  404  Not Found
Ign http://pkg.jenkins-ci.org trusty/binary/ Translation-en_US       
Ign http://pkg.jenkins-ci.org trusty/binary/ Translation-en
Fetched 5,976 kB in 3s (1,528 kB/s)             
W: Failed to fetch http://pkg.jenkins-ci.org/debian/dists/trusty/binary//binary-amd64/Packages  404  Not Found

W: Failed to fetch http://pkg.jenkins-ci.org/debian/dists/trusty/binary//binary-i386/Packages  404  Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.

我对Chef很新。此错误似乎与检索Jenkins包有关,但我不知道如何解决此错误。如果需要其他信息来解决此问题,请与我们联系。

提前感谢所有人提供的任何指导。我已经搜索了Chef文档,但除了指定包版本之外还没有看到太多:https://docs.chef.io/resource_package.html

1 个答案:

答案 0 :(得分:0)

指定distribution 'binary/'而不是components 'binary/'。这将修复因trusty/binary/而获得的404。

至少,这是我从"official" Jenkins cookbook看到的,我知道。建议使用。

编辑:结果将是:

apt_repository "jenkins" do
  uri "http://pkg.jenkins-ci.org/debian"
  key "http://pkg.jenkins-ci.org/debian/jenkins-ci.org"
  distribution "binary/"
end