Passing values from one Chef resource to another


#1

Ohai, Chefs!

I have a ruby_block that calculates a value which I then want to use in
another, say ‘mount’, resource. Is there a documented way or best practice
on how to do this?
I could not find anything documented anywhere, so I wrote something up:

Thoughts? Suggestions? Criticisms?

Cheers!

-Cary P


#2

You can simplify run_context.resource_collection.lookup(“log[update_target]”) to resources(‘log[update_target]’). You can also combine steps 2 and 3 unless there is a pressing reason not to.

–Noah

On May 30, 2013, at 5:49 PM, Cary Penniman cary@rightscale.com wrote:

Ohai, Chefs!

I have a ruby_block that calculates a value which I then want to use in another, say ‘mount’, resource. Is there a documented way or best practice on how to do this?

I could not find anything documented anywhere, so I wrote something up:

http://cpenniman.blogspot.com/2013/05/passing-values-from-one-chef-resource.html

Thoughts? Suggestions? Criticisms?

Cheers!

-Cary P


#3

Cary,

Somebody else had the same problem and someone pointed out about the lazy attribute feature that is coming up in Chef 11.6 (which was formerly delayed_evaluator as a POC).

http://tickets.opscode.com/browse/CHEF-3731

On May 30, 2013, at 5:49 PM, Cary Penniman cary@rightscale.com wrote:

Ohai, Chefs!

I have a ruby_block that calculates a value which I then want to use in another, say ‘mount’, resource. Is there a documented way or best practice on how to do this?

I could not find anything documented anywhere, so I wrote something up:

http://cpenniman.blogspot.com/2013/05/passing-values-from-one-chef-resource.html

Thoughts? Suggestions? Criticisms?

Cheers!

-Cary P


#4

Thanks to Noah and Kannan for the review and the feedback.

I am excited to see that the delayed attribute feature [1] will be
available in 0.10.28!

Chef rocks!

-Cary P

[1] - http://tickets.opscode.com/browse/CHEF-3731

On Thu, May 30, 2013 at 6:26 PM, Kannan Manickam kannan@rightscale.comwrote:

Cary,

Somebody else had the same problem and someone pointed out about the lazy
attribute feature that is coming up in Chef 11.6 (which was formerly
delayed_evaluator as a POC).

http://tickets.opscode.com/**browse/CHEF-3731http://tickets.opscode.com/browse/CHEF-3731

On May 30, 2013, at 5:49 PM, Cary Penniman cary@rightscale.com wrote:

Ohai, Chefs!

I have a ruby_block that calculates a value which I then want to use in
another, say ‘mount’, resource. Is there a documented way or best practice
on how to do this?
I could not find anything documented anywhere, so I wrote something up:

http://cpenniman.blogspot.com/2013/05/passing-values-from-one-chef-resource.html

Thoughts? Suggestions? Criticisms?

Cheers!

-Cary P


Cary Penniman
Sr. Software Developer
www.RightScale.com http://www.rightscale.com/

Phone: (805) 243-0222
Email: cary@rightscale.com
Skype: carypenniman