Application + library pattern question

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

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." 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 <
thorsten.sideb0ard@gmail.com> 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

awesome, thanks, that works perfectly.

cheers!
thor

On Wed, Jan 22, 2014 at 12:32 PM, Tucker junk@gmail.com wrote:

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." 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 <
thorsten.sideb0ard@gmail.com> 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

This might be even easier with chef-rewind:

HTH, Torben

On Wed, Jan 22, 2014 at 10:24 PM, Thorsten Sideboard <
thorsten.sideb0ard@gmail.com> wrote:

awesome, thanks, that works perfectly.

cheers!
thor

On Wed, Jan 22, 2014 at 12:32 PM, Tucker junk@gmail.com wrote:

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." 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 <
thorsten.sideb0ard@gmail.com> 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