- From: "John E. Vincent (lusis)" <
>
- To:
- Subject: [chef] Re: including recipes vs normal ruby require/include
- Date: Thu, 16 Feb 2012 11:26:20 -0500
On Thu, Feb 16, 2012 at 10:09 AM,
<
>
wrote:
>
>
Chef folks,
>
>
I have a question about code reuse in Chef.
>
>
I know it’s not unusual for a recipe to include another recipe using the
>
“include recipe” construct. But why is this better than using the normal
>
Ruby mechanisms for code reuse? Couldn’t I organize my reusable bits of
>
Chef
>
code into ordinary Ruby modules, and then use the ordinary Ruby require and
>
include tools to pull in the reusable bits as needed? My prejudice is to
>
stick
>
to the normal Ruby way unless there's a compelling reason not to.
>
>
Jeff
Jeff,
You're probably going to want to investigate LWRPs if you haven't
already. That's really the code reuse mechanism in Chef.
You don't even have to use the resources part of it. You can just
package stuff up in a library and distribute it as a required
cookbook. See the openssl cookbook:
https://github.com/opscode/cookbooks/tree/master/openssl
as an example.
John E. Vincent
http://about.me/lusis
Archive powered by MHonArc 2.6.16.