[chef] Re: Sharing Variables across Recipies


Chronological Thread 
  • From: Ranjib Dey < >
  • To: " " < >
  • Cc:
  • Subject: [chef] Re: Sharing Variables across Recipies
  • Date: Sat, 25 Oct 2014 10:18:19 -0700

instance variables are shared across recipes, as each of the recipe is a separate object. you can use node.run_state as small cross recipe storage place. careful with this approach though, it might break why_run mode,
you can also use a dedicated module which exposes some common storage place, as well as wraps reusable code, i prefer that, as its clean and i can change the shared storage logic transparently,
regards
ranjib

On Sat, Oct 25, 2014 at 4:29 AM, Kamesh Sampath < " target="_blank"> > wrote:

I have situation in my cookbook where i extract some values form data_bags and put them onto local variables on recipes after some manipulation of them.  I am running on to a situation where i need to repeat this logic across many cookbooks as i see that when i do it in “default.rb” and then use them in include_recipe’s I see chef complaining that the variable is undefined, am not sure why so ideally when if I understand correctly all the recipes are compiled on to a single class by chef during converge so conceptually they should be visible.

Is there a way how i can share the variables declared in a recipe?

-Kamesh




Archive powered by MHonArc 2.6.16.

§