Pergunta

I am trying to use chef with aws opsworks.

however it doesn't seem to be loading my template.

Here is the part of the recipe concerned which is in /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

Here is the stack trace

[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)

And here is my directory structure
Screenshot of directory

Foi útil?

Solução

You will need to put the template into one of the following directories api/templates/default api/templates/amazon or api/templates/amazon-2013.09. If you want the same template files to work on any platform, then put the templates in the api/templates/default directory.

Check out http://docs.chef.io/templates.html#file-specificity for more details on where you might want to place your templates.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top