[chef] Re: passing attributes to recipes


Chronological Thread 
  • From: Brad Montgomery < >
  • To:
  • Subject: [chef] Re: passing attributes to recipes
  • Date: Thu, 9 Feb 2012 12:08:12 -0600

Hi Steffen,

I'm also fairly new to Chef, but I've been doing this with data bags. You might create a data bag called "build_info", and it might contain an item called "build01".  That item would then list the file names or build numbers that you want.

Then, in your Role, create an attribute that lists the data bag items you want to use in your recipe:  

default_attributes(
  "build_items" => ['build01']
)

Then you can write your recipe to search for those data bags and read your information from there.  Then, in the future, you just create new data bags and roles for nodes that need different info.

In your recipe:

node['build_items].each do |item_name|
  search(:build_info, "id:#{item_name}") do |build|
    # Depending on what your data bag looks like you might
    # reference something like build["filename"] or build["number"]
  end
end


Hope that helps.


On Thu, Feb 9, 2012 at 11:41 AM, Steffen Fricke < "> > wrote:

Hello,

 

 

I’m relatively new to chef and I try to figure out, how to pass variable attributes like build file names or build numbers to chef recipes. So the best would be if I could add/overwrite a given attribute in a role/environment by it to knife via command line like: knife environment edit [env_name] “attribute_key=attribute_value”.

 

Is there a recommended way of doing that?

 

Thanks in advance,

Steffen

 

Description: adobe_logo_web

Steffen Fricke
Software QE Developer


Adobe Systems Engineering GmbH

49.40.3063.6454

" target="_blank">

Grosse Elbstr. 27
22767 Hamburg, Germany

www.adobe.com

 

 

Registergericht: Hamburg HRB 745 37

Geschäftsführer: Michael D. Jamrosy, Thomas Mührke, Joseph J. Nemeth Jr., Richard T. Rowley

 

 

 

 





Archive powered by MHonArc 2.6.16.

§