AWS opsworks 上的 chef 12 脚本无法安装 jenkins

chef 12 script on AWS opsworks failing to install jenkins

我有以下 chef 12 脚本,我正在 运行 在 aws opsworks 上安装 jenkins。我从以下站点获取它:https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu 当我 运行 它时,它失败并出现以下错误:

execute 'add jenkins source to apt' do
    command "wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -"
end


file '/etc/apt/sources.list.d/jenkins.list' do
    content 'deb http://pkg.jenkins.io/debian-stable binary/'
end

execute 'update apt-get' do
    command 'apt-get update'
end


package 'install Jenkins' do
    package_name "jenkins"
end

package 'install nginx' do
    package_name 'nginx'
end

file '/etc/nginx/sites-enabled/default' do
    action :delete
end

cookbook_file '/etc/nginx/sites-available/jenkins' do
    source 'jenkins'
end

link '/etc/nginx/sites-enabled/jenkins' do
    to '/etc/nginx/sites-available/jenkins'
    link_type :symbolic
end

service 'nginx' do
    action :restart
end

service 'jenkins' do
    action :restart
end

当我 运行 在 c4.4xlarge 图像 运行ning ubuntu 14.04 上执行食谱时,出现以下错误

Setting up jenkins (2.32.1) ...
* Starting Jenkins Continuous Integration Server jenkins
...fail!
Setting up libnss3-nssdb (2:3.26.2-0ubuntu0.14.04.3) ...

STDERR: invoke-rc.d: initscript jenkins, action "start" failed.
dpkg: error processing package jenkins (--configure):
subprocess installed post-installation script returned error exit status 7
Errors were encountered while processing:
jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)
---- End output of apt-get -q -y install jenkins=2.32.1 ----
Ran apt-get -q -y install jenkins=2.32.1 returned 100

Resource Declaration:
---------------------
# In /var/chef/runs/55bf900b-16e6-4573-9948-8571284d80e7/local-mode-cache/cache/cookbooks/jenkins/recipes/default.rb

16: package 'install Jenkins' do
17:     package_name "jenkins"
18: end
19: 

Compiled Resource:
------------------
# Declared in /var/chef/runs/55bf900b-16e6-4573-9948-8571284d80e7/local-mode-cache/cache/cookbooks/jenkins/recipes/default.rb:16:in `from_file'

apt_package("install Jenkins") do
package_name "jenkins"
action [:install]
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :package
cookbook_name "jenkins"
recipe_name "default"
end

Platform:
---------
x86_64-linux

[2017-02-01T03:10:08+00:00] INFO: Running queued delayed notifications before re-raising exception
[2017-02-01T03:10:08+00:00] ERROR: Running exception handlers
[2017-02-01T03:10:08+00:00] ERROR: Exception handlers complete
[2017-02-01T03:10:08+00:00] FATAL: Stacktrace dumped to /var/chef/runs/55bf900b-16e6-4573-9948-8571284d80e7/local-mode-cache/cache/chef-stacktrace.out
[2017-02-01T03:10:08+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-02-01T03:10:08+00:00] ERROR: apt_package[install Jenkins] (jenkins::default line 16) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '100'

我不确定为什么 jenkins 无法启动。当我 运行 食谱在同一个实例上两次时,它第二次成功了。非常感谢任何帮助,因为这是我的第一个 Chef 脚本。

事实证明答案在 chef 堆栈跟踪文件中。 apt-get 进程运行了两次,无法访问安装包步骤中 dpkg 中的锁定文件。改变

execute 'update apt-get' do
    command 'apt-get update'
end


package 'install Jenkins' do
    package_name "jenkins"
end

apt_update 'all platforms' do
    action :update
end

apt_package 'jenkins' do
  action :install
end

解决了问题。