【问题标题】:Chef, cannot find template厨师,找不到模板
【发布时间】:2014-05-29 07:24:40
【问题描述】:

我正在尝试将 chef 与 aws opsworks 一起使用。

但是它似乎没有加载我的模板。

这是相关配方的一部分,位于 /api/recipes/configure.rb

  # write out our applications site configurations
  template "/etc/httpd/sites-available/#{application}.conf" do
    source 'site-config.erb'
    owner 'root'
    group 'root'
    mode 0644
    variables(
        :docroot => "#{deploy[:deploy_to]}/public"
    )
  end

这是堆栈跟踪

[2014-04-15T05:08:03+00:00] INFO: Processing template[/etc/httpd/sites-available/testing_app.conf] action create (api::configure line 33)

================================================================================
Error executing action `create` on resource 'template[/etc/httpd/sites-available/testing_app.conf]'
================================================================================


Chef::Exceptions::FileNotFound
------------------------------
Cookbook 'api' (0.1.0) does not contain a file at any of these locations:
templates/amazon-2013.09/site-config.erb
templates/amazon/site-config.erb
templates/default/site-config.erb


Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache/cookbooks/api/recipes/configure.rb

33:   template "/etc/httpd/sites-available/#{application}.conf" do
34:     source 'site-config.erb'
35:     owner 'root'
36:     group 'root'
37:     mode 0644
38:     variables(
39:         :docroot => "#{deploy[:deploy_to]}/public"
40:     )
41:   end
42: 



Compiled Resource:
------------------
# Declared in /var/lib/aws/opsworks/cache/cookbooks/api/recipes/configure.rb:33:in `block in from_file'

template("/etc/httpd/sites-available/testing_app.conf") do
provider Chef::Provider::Template
action "create"
retries 0
retry_delay 2
path "/etc/httpd/sites-available/testing_app.conf"
backup 5
atomic_update true
source "site-config.erb"
variables {:docroot=>"/srv/www/testing_app/public"}
cookbook_name "api"
recipe_name "configure"
owner "root"
group "root"
mode 420
end



[2014-04-15T05:08:03+00:00] INFO: Running queued delayed notifications before re-raising exception
[2014-04-15T05:08:03+00:00] ERROR: Running exception handlers
[2014-04-15T05:08:03+00:00] ERROR: Exception handlers complete
[2014-04-15T05:08:03+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache/chef-stacktrace.out
[2014-04-15T05:08:03+00:00] ERROR: template[/etc/httpd/sites-available/testing_app.conf] (api::configure line 33) had an error: Chef::Exceptions::FileNotFound: Cookbook 'api' (0.1.0) does not contain a file at any of these locations:
templates/amazon-2013.09/site-config.erb
templates/amazon/site-config.erb
templates/default/site-config.erb
[2014-04-15T05:08:04+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

这是我的目录结构

【问题讨论】:

    标签: amazon-web-services chef-infra chef-recipe aws-opsworks


    【解决方案1】:

    您需要将模板放入以下目录之一:api/templates/defaultapi/templates/amazonapi/templates/amazon-2013.09。如果您希望相同的模板文件在任何平台上工作,请将模板放在api/templates/default 目录中。

    查看http://docs.chef.io/templates.html#file-specificity,了解有关您可能希望将模板放置在何处的更多详细信息。

    【讨论】:

      猜你喜欢
      • 2017-05-07
      • 2015-03-20
      • 2015-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多