简体   繁体   English

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

[英]chef 12 script on AWS opsworks failing to install jenkins

I have the following chef 12 script which I am running on aws opsworks to install jenkins. 我有以下厨师12脚本,我正在aws opsworks上运行以安装jenkins。 I sourced it from the following site: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu When I run it, it fails with the following error: 我从以下站点获得它: 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

When I run execute recipes on a c4.4xlarge image running ubuntu 14.04, I get the following errors 当我在运行ubuntu 14.04的c4.4xlarge图像上运行执行配方时,出现以下错误

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) ...

and

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'

I am not sure why jenkins is failing to start. 我不确定詹金斯为什么无法开始。 When I run the recipe twice on the same instance it succeeds the second time. 当我在同一实例上运行两次配方时,它第二次成功。 Any help is much appreciated, as this is my first Chef script. 非常感谢您的帮助,因为这是我的第一个Chef脚本。

It turns out the answer was in the chef stacktrace file. 事实证明答案在Chef stacktrace文件中。 The apt-get process runs twice and could not access the lockfile in dpkg in the install package step. apt-get进程运行两次,并且在安装软件包步骤中无法访问dpkg中的锁定文件。 Changing 更改

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


package 'install Jenkins' do
    package_name "jenkins"
end

to

apt_update 'all platforms' do
    action :update
end

apt_package 'jenkins' do
  action :install
end

solved the issue. 解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM