[chef] Re: RE: Including other recipes ... why the alternate format/method?


Chronological Thread 
  • From: Lamont Granquist < >
  • To:
  • Cc: Justin Witrick < >
  • Subject: [chef] Re: RE: Including other recipes ... why the alternate format/method?
  • Date: Wed, 12 Mar 2014 10:20:00 -0700


And I beleive you're in an instance of Chef::Recipe when you do that, and you want to add the methods to the class as instance variables, that way you can use the methods in all Chef::Recipe instances. So you're sending the "include Opscode::OpenSSL::Password" message to the Chef::Recipe class in order to do that. Its just some necessary pure-ruby in order to do what you want to make methods directly available in your cookbook recipes.

On Wed Mar 12 09:52:33 2014, Justin Witrick wrote:
So in this case they are not including a recipe named 'Password' they
are including a module named 'Password'

The module is defined
in: 
https://github.com/opscode-cookbooks/openssl/blob/master/libraries/secure_password.rb

-----Original Message-----
From: 

Sent: Wednesday, March 12, 2014 12:17pm
To: 

Subject: [chef] Including other recipes ... why the alternate
format/method?

Greetings,

I am looking at a recipe for installing tomcat and happened across
this line
(with associated comment):

# required for the secure_password method from the openssl cookbook
::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)

I was wondering why the author would choose to use this alternate way of
including a recipe. Why would they not just do something like:
include_recipe
'X::Password'.

Is this not doing exactly that, simply including another recipe? If
so, then
why choose the more difficult to read/maintain/etc way of doing it?

Thanks in advance for the insight!






Archive powered by MHonArc 2.6.16.

§