Use Custom Library files in wrapper cookbook

Can i use custom files to override library cookbook’s library files, template files etc in my wrapper cookbook?

It depends on the cookbook, you will need to look through the cookbooks lwrps/custom resources to determine this. An example is in the elasticsearch cookbook: https://github.com/elastic/cookbook-elasticsearch/blob/master/libraries/resource_configure.rb#L42-L43 . If the upstream cookbook does not support some way of overriding this you next best thing is to use chef rewind: https://github.com/thommay/chef-rewind

I have done the above template overriding for elasticsearch. Now im working with logstash cookbook(wrapper). i need to override the config files defined in the library section there “https://github.com/lusis/chef-logstash”. Need to try the chef rewind thing. Looks good.
Thanks.

Looks like you can do it here: https://github.com/lusis/chef-logstash/blob/master/resources/config.rb#L20 and https://github.com/lusis/chef-logstash/blob/master/resources/config.rb#L14 . Hope that helps.

@majormoses
Actually my requirement is i need to use my custom made file instead of this https://github.com/lusis/chef-logstash/blob/master/libraries/logstash_conf.rb. Kind of confused on that.

Gotcha, seems like the simple solution is to not call that resource in your recipe in your wrapper. Not sure if other resources rely on it so it might be a bit more work.

@majormoses
Okay. If i understand correctly , i should create a new resource in my wrapper cookbook’s my-cookbook/library files

and use that in resource in recipe?

Correct.

Cool. Let me try that. Thanks for quick replies and help
:slight_smile: