[chef] Re: application + library pattern question


Chronological Thread 
  • From: Tucker < >
  • To:
  • Subject: [chef] Re: application + library pattern question
  • Date: Wed, 22 Jan 2014 12:32:42 -0800

Are you trying to override a resource?  If so, there's a pattern for that.  This is an example I used for overriding a template in the gitlab::default recipe with a template from my own (personal-gitlab::default).

include_recipe 'gitlab'
begin
  r = resources(template: "#{node['gitlab']['shell']['home']}/config.yml")
  r.source 'oauth-config.yml.erb'
  r.cookbook 'personal-gitlab'
rescue Chef::Exceptions::ResourceNotFound
  Chef::Log.warn 'Could not find template to override.'
end
You can override any attributes of the resource with "r.<attribute>" in your block.  If you're trying to prevent the external recipe from overwriting the file, you should be able to do "r.action :nothing" and effectively stop it from running and presumably also prevent the notification to the service.  You may have to play with it a bit to get it to work correctly.

On Wed, Jan 22, 2014 at 12:09 PM, Thorsten Sideboard < " target="_blank"> > wrote:
hello there,
first time poster here.

I've been following the application + library pattern, using my own application cookbooks to override settings in library cookbooks. I have an application cookbook for installing Tomcat and overriding a number of settings in template for /etc/default/tomcat

My problem is that one every chef run, it updates that file on each run, and then subsequently restarts Tomcat, even though in fact, the file contents haven't changed, they just differ from the contents of the original tomcat library cookbook file.

Any advice on how best to stop this or override in my own application cookbook?

thanks!
thor



--

--tucker



Archive powered by MHonArc 2.6.16.

§