apache2厨师食谱开始失败

时间:2014-03-04 18:25:09

标签: apache2 chef recipe cookbook

我正在尝试使用Chef创建一个本地虚拟主机,为此我在我的运行列表中添加了“recipe [apache2]”配方,它运行良好,直到我在运行列表中添加了另一个包含默认值的配方apache2食谱。现在,即使我从运行列表中删除新配方,“启动”失败也会出现以下错误。谁知道这是什么原因?

================================================================================
Error executing action `start` on resource 'service[apache2]'
================================================================================


Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /etc/init.d/apache2 start ----
STDOUT: * Starting web server apache2
Action 'start' failed.
The Apache error log may have more information.
   ...fail!
STDERR: Syntax error on line 2 of /etc/apache2/sites-enabled/example.conf:
ServerName takes one argument, The hostname and port of the server
---- End output of /etc/init.d/apache2 start ----
Ran /etc/init.d/apache2 start returned 1


Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/apache2/recipes/default.rb

210: service 'apache2' do
211:   action :start
212: end



Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/apache2/recipes/default.rb:210:in `from_file'

service("apache2") do
  action [:start]
  supports {:restart=>true, :reload=>true, :status=>true}
  retries 0
  retry_delay 2
  service_name "apache2"
  pattern "apache2"
  restart_command "/usr/sbin/invoke-rc.d apache2 restart && sleep 1"
  reload_command "/usr/sbin/invoke-rc.d apache2 reload && sleep 1"
  cookbook_name "apache2"
  recipe_name "default"
end



[2014-03-04T17:52:20+00:00] INFO: Running queued delayed notifications before         re-raising exception
[2014-03-04T17:52:20+00:00] ERROR: Running exception handlers
[2014-03-04T17:52:20+00:00] ERROR: Exception handlers complete
[2014-03-04T17:52:20+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-03-04T17:52:20+00:00] INFO: Sending resource update report (run-id: 3d91fc5b-cf02-4788-bb56-f03ebe274702)
[2014-03-04T17:52:21+00:00] ERROR: service[apache2] (apache2::default line 210) had an  error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /etc/init.d/apache2 start ----
STDOUT: * Starting web server apache2
Action 'start' failed.
The Apache error log may have more information.
   ...fail!
STDERR: Syntax error on line 2 of /etc/apache2/sites-enabled/example.conf:
ServerName takes one argument, The hostname and port of the server
---- End output of /etc/init.d/apache2 start ----
Ran /etc/init.d/apache2 start returned 1
[2014-03-04T17:52:21+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

1 个答案:

答案 0 :(得分:1)

查看/etc/apache2/sites-enabled/example.conf:输出显示

  

ServerName接受一个参数,即服务器的主机名和端口

显然,您没有传递sever_name属性 - 请查看README和使用过的template

web_app "my_site" do
  server_name node['hostname']
  server_aliases [node['fqdn'], "my-site.example.com"]
  docroot "/srv/www/my_site"
end

如果这样做无效,请编辑您的帖子并添加如何定义示例网站的代码。