我有以下主厨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
当我在运行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) ...
和
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'
我不确定为什么詹金斯未能开始。当我在同一个实例上运行两次配方时,它第二次成功。非常感谢任何帮助,因为这是我的第一个Chef脚本。
答案 0 :(得分:0)
事实证明答案是在厨师堆栈跟踪文件中。 apt-get进程运行两次,无法在安装包步骤中访问dpkg中的lockfile。改变
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
解决了这个问题。