# Passing values from one Chef resource to another

**URL:** <https://discourse.chef.io/t/passing-values-from-one-chef-resource-to-another/4041>\
**Category:** Chef Infra (archive)\
**Created:** [May 31, 2013, 12:49am UTC](https://discourse.chef.io/t/passing-values-from-one-chef-resource-to-another/4041 "2013-05-31T00:49:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cary\_Penniman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cary_penniman/32/366_2.png) [@Cary\_Penniman](https://discourse.chef.io/u/Cary_Penniman)\
**Post date:** [May 31, 2013, 12:49am UTC](https://discourse.chef.io/t/passing-values-from-one-chef-resource-to-another/4041/1 "2013-05-31T00:49:09Z")

</div>

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:

> **[Passing values from one Chef resource to another](http://cpenniman.blogspot.com/2013/05/passing-values-from-one-chef-resource.html)**
>
> Overview In a Chef recipe it is sometimes useful to set the value of an attribute in one resource , and then be able to use that value...

Thoughts? Suggestions? Criticisms?

Cheers!

-Cary P

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [May 31, 2013, 12:52am UTC](https://discourse.chef.io/t/passing-values-from-one-chef-resource-to-another/4041/2 "2013-05-31T00:52:19Z")

</div>

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](mailto: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:
> 
> [Adventures in the Clouds: Passing values from one Chef resource to another](http://cpenniman.blogspot.com/2013/05/passing-values-from-one-chef-resource.html)
> 
> Thoughts? Suggestions? Criticisms?
> 
> Cheers!
> 
> -Cary P

---

<div class="post-metadata">

**Author:** ![Kannan\_Manickam1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kannan_manickam1/32/522_2.png) [@Kannan\_Manickam1](https://discourse.chef.io/u/Kannan_Manickam1)\
**Post date:** [May 31, 2013, 1:26am UTC](https://discourse.chef.io/t/passing-values-from-one-chef-resource-to-another/4041/3 "2013-05-31T01:26:08Z")

</div>

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](http://tickets.opscode.com/browse/CHEF-3731)

On May 30, 2013, at 5:49 PM, Cary Penniman [cary@rightscale.com](mailto: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:
> 
> [Adventures in the Clouds: Passing values from one Chef resource to another](http://cpenniman.blogspot.com/2013/05/passing-values-from-one-chef-resource.html)
> 
> Thoughts? Suggestions? Criticisms?
> 
> Cheers!
> 
> -Cary P

---

<div class="post-metadata">

**Author:** ![Cary\_Penniman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cary_penniman/32/366_2.png) [@Cary\_Penniman](https://discourse.chef.io/u/Cary_Penniman)\
**Post date:** [May 31, 2013, 5:29pm UTC](https://discourse.chef.io/t/passing-values-from-one-chef-resource-to-another/4041/4 "2013-05-31T17:29:23Z")

</div>

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](http://tickets.opscode.com/browse/CHEF-3731)

On Thu, May 30, 2013 at 6:26 PM, Kannan Manickam [kannan@rightscale.com](mailto:kannan@rightscale.com)wrote:

> 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](http://tickets.opscode.com/**browse/CHEF-3731)[http://tickets.opscode.com/browse/CHEF-3731](http://tickets.opscode.com/browse/CHEF-3731)
> 
> On May 30, 2013, at 5:49 PM, Cary Penniman [cary@rightscale.com](mailto: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:
> 
> [Adventures in the Clouds: Passing values from one Chef resource to another](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) [http://www.rightscale.com/](http://www.rightscale.com/)

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