[chef] Re: Re: Re: Re: Re: Supervisor missing templates


Chronological Thread 
  • From: Benjamin Bytheway < >
  • To: " " < >
  • Subject: [chef] Re: Re: Re: Re: Re: Supervisor missing templates
  • Date: Mon, 21 Jul 2014 22:25:02 -0600

I guess I'm getting different behavior then.  I was able to reproduce my missing template problem. 

It happens when you have a render in a template that is part of an lwrp called from another cookbook. 

Here's the stack trace (all custom cookbooks, this isn't the community apache cookbook). Notice the template and the render specify the cookbook explicitly. this is using chef-client 11.12.8 and open source chef server 11.1.3 on RHEL 6.

================================================================================
Error executing action `create_if_missing` on resource 'template[/usr/local/common/apache2/confs/ben_ssl/httpd.conf]'
================================================================================


Chef::Mixin::Template::TemplateError
------------------------------------
Cookbook 'use_template' (0.4.0) does not contain a file at any of these locations:
  templates/redhat-6.5/httpd_ssl.conf.erb
  templates/redhat/httpd_ssl.conf.erb
  templates/default/httpd_ssl.conf.erb


Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/apache/providers/instance.rb

177:   template "/usr/local/common/apache2/confs/#{flavor}/httpd.conf" do
178:     source 'httpd.conf.erb'
179:     variables(
180:         server_name:   node[:fqdn],
181:         server_port:   (ssl?(flavor) ? 443 : 80),
182:         vhost_name:    vhost_name,
183:         vhost_aliases: vhost_aliases,
184:         ssl_enabled:   ssl?(flavor),
185:     )
186:     owner 'root'
187:     group group_name
188:     mode  '0644'
189:     cookbook 'apache'
190:     action :create_if_missing
191:   end
192:



Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/apache/providers/instance.rb:177:in `config_files'

template("/usr/local/common/apache2/confs/ben_ssl/httpd.conf") do
  provider Chef::Provider::Template
  action [:create_if_missing]
  retries 0
  retry_delay 2
  guard_interpreter :default
  path "/usr/local/common/apache2/confs/ben_ssl/httpd.conf"
  backup 5
  atomic_update true
  source "httpd.conf.erb"
  cookbook "apache"
  variables {:server_name=>"hostname", :server_port=>443, :vhost_name=>"hostname", :vhost_aliases=>["hostname"], :ssl_enabled=>true}
  cookbook_name "use_template"
  owner "root"
  group "webadmin"
  mode "0644"
end



Template Context:
-----------------
on line #195
193:
194: <% if @ssl_enabled %>
195:    <%= render "httpd_ssl.conf.erb", variables: { vhost_name: @vhost_name }, coobook: 'apache' %>
196: <% end %>
197:


On Mon, Jul 21, 2014 at 8:32 PM, AJ Christensen < " target="_blank"> > wrote:
The stack-trace in OP is not a template resource.

"Supervisor service job_activity_search cannot be restarted because it
does not exist"

Perhaps :create needs to be called before :enable/:restart. I'm not
familiar with the supervisor cookbook.

111:     action [:enable, :restart]

One might anticipate :enable to call :create, but  would have to dig
into the supervisor (L|H)WRP itself, to find out!

Cheers,

AJ

On Tue, Jul 22, 2014 at 2:30 PM, Ben Bytheway < "> > wrote:
> Yes, the chef run fails with an error that the template cannot be found, even when specifying the cookbook where the template is located in the resource call.
>
>> On Jul 21, 2014, at 8:09 PM, Daniel DeLeo < "> > wrote:
>>
>>> On Monday, July 21, 2014 at 6:59 PM, Ben Bytheway wrote:
>>> I have also seen this behavior, but haven't gotten to the bottom of it. If I knife download my cookbook, the template is there, but chef-client doesn't get it. Isn't in /var/chef/cache at all.
>>
>>
>> Templates are downloaded on demand, as they are used by resources. If you never use them, then chef doesn’t download them. If I remember correctly, there might also be a small bug where templates that are used can be removed at the end of a chef-client run (but they’re downloaded the next time so it’s just wasting a bit of IO). Have you seen a cookbook fail to execute for this reason?
>>
>> Also, if you just don’t like this behavior, you can configure `no_lazy_load true` to make chef-client fetch all templates (and cookbook files, which have the same behavior) eagerly.
>>
>> FWIW, eager load will be the default in Chef 12 since the URLs to fetch the files are time-limited and on long chef-client runs (an hour or more), the URLs expire and cause errors.
>>
>> --
>> Daniel DeLeo
>>




Archive powered by MHonArc 2.6.16.

§