[chef] Re: Re: Using cookbook_name method in cookbooks


Chronological Thread 
  • From: Cliff Pracht < >
  • To: " " < >
  • Subject: [chef] Re: Re: Using cookbook_name method in cookbooks
  • Date: Wed, 18 Mar 2015 12:34:46 +0000
  • Accept-language: en-US

Yes true, good point  -  the attributes (that you want to change) in wrappers would be a different cookbook name. It wouldn’t make sense to use the method in that case. 

From: Jeff Byrnes
Reply-To: " "> "
Date: Wednesday, March 18, 2015 at 8:26 AM
To: " "> "
Subject: [chef] Re: Using cookbook_name method in cookbooks

Speculation on my part, but in the context of wrapping a cookbook, wouldn’t the cookbook_name variable become the name of the wrapper cookbook, not the cookbook that the attribute(s) belong to?

-- 
Jeff Byrnes
@thejeffbyrnes
Lead DevOps Engineer
704.516.4628

On March 18, 2015 at 8:23:21 AM, Cliff Pracht ( "> ) wrote:

Hi all,

I’ve noticed in a lot of cookbook code when needing the cookbook name, folks have been using the hard coded string name.

Eg. In the apache cookbook a defined attribute looks something like this where ‘apache’ is listed 100s of times:

#default apache run directory 
 default['apache']['run_dir'] = '/var/run/httpd'

Instead of this:

#default apache run directory 
 default[cookbook_name]['run_dir']  = '/var/run/httpd

Obviously, changing a cookbook name is not an everyday thing.   However we have a strict naming convention at our shop for cookbooks to clarify the purpose of cookbook (eg. whether the cookbook is a library, wrapper, policy, operating system, etc.).  And have had to change the name frequently initially to get right. 

Any thoughts on doing this?  Are there drawbacks with this?

Thanks,

Cliff







Archive powered by MHonArc 2.6.16.

§