1

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

这是我的目录结构
目录截图

4

1 回答 1

6

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

查看http://docs.chef.io/templates.html#file-specificity以获取有关您可能想要放置模板的位置的更多详细信息。

于 2014-04-15T05:33:41.893 回答