We have multiple cookbooks which reference the same files and templates and were wondering if there is a reasonable way to ensure all of these are the same file to ensure that none go out of date. Is it possible to have a single file/template referenced by multiple recipes/cookbooks? I thought about using symlinks, however this will not work for us as Git does not support them.
The cookbook_file and template resources support a "cookbook" parameter that specifies which cookbook contains the source file. Then you could create a "commons" cookbook where those files live as a single entity. For example:
Suppose you have two cookbooks, thing1 and thing2, and they both use these. The recipes might be:
However, I would ask why do you have duplication between different kinds of functionality in your cookbooks? That is, would this kind of thing be suitable for a custom lightweight resource/provider that you use?