厨师,找不到模板

时间:2014-04-15 05:25:24

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

我正在尝试使用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)

这是我的目录结构
Screenshot of directory

1 个答案:

答案 0 :(得分:6)

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

查看http://docs.chef.io/templates.html#file-specificity,详细了解您可能希望放置模板的位置。