Maintain object state in chef run


#1

Hi,

I have created a class for one of my cookbooks (in the library directory). When
I tested it in a recipe, everything worked fine.
When I wanted to use a method from my object (the already initialized object,
not a new one) in a recipe from a different cookbook, later on in the same run,
the object wasn’t available.
Is there any way that I could keep the object state for the whole chef-run? Or
even for the whole execute phase or compile phase?

Thanks!!


#2

On Thursday, November 8, 2012 at 9:55 AM, jfotop wrote:

Hi,

I have created a class for one of my cookbooks (in the library directory). When
I tested it in a recipe, everything worked fine.
When I wanted to use a method from my object (the already initialized object,
not a new one) in a recipe from a different cookbook, later on in the same run,
the object wasn’t available.
Is there any way that I could keep the object state for the whole chef-run? Or
even for the whole execute phase or compile phase?

Thanks!!
The node has a run_state hash where you can keep things for the duration of a chef run.

node.run_state[:my_thing] = some_object


Daniel DeLeo