# Selective inclusion of attribute files

**URL:** <https://discourse.chef.io/t/selective-inclusion-of-attribute-files/1856>\
**Category:** Chef Infra (archive)\
**Created:** [May 25, 2011, 11:56pm UTC](https://discourse.chef.io/t/selective-inclusion-of-attribute-files/1856 "2011-05-25T23:56:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasonjwwilliams](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jasonjwwilliams/32/101_2.png) [@jasonjwwilliams](https://discourse.chef.io/u/jasonjwwilliams)\
**Post date:** [May 25, 2011, 11:56pm UTC](https://discourse.chef.io/t/selective-inclusion-of-attribute-files/1856/1 "2011-05-25T23:56:07Z")

</div>

If I have two attribute files (server\_type\_a.rb and server\_type\_b.rb)  
how can I ensure that recipes/default.rb only uses  
attributes/server\_type\_a.rb and recipes/server\_b.rb only uses  
attributes/server\_type\_b.rb?

-J

---

<div class="post-metadata">

**Author:** ![Adam\_Jacob](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/adam_jacob/32/292_2.png) [@Adam\_Jacob](https://discourse.chef.io/u/Adam_Jacob)\
**Post date:** [May 26, 2011, 4:06am UTC](https://discourse.chef.io/t/selective-inclusion-of-attribute-files/1856/2 "2011-05-26T04:06:39Z")

</div>

On May 25, 2011, at 4:56 PM, Jason J. W. Williams wrote:

> If I have two attribute files (server\_type\_a.rb and server\_type\_b.rb)  
> how can I ensure that recipes/default.rb only uses  
> attributes/server\_type\_a.rb and recipes/server\_b.rb only uses  
> attributes/server\_type\_b.rb?

If you really want this, you can check to see if the current node has a role/recipe/tag applied inside the attribute files.

A better way, though, would be to use a role for this - have a single attribute file that sets a sane default, and a role for server\_type\_a and server\_type\_b.

Best,  
Adam

---

<div class="post-metadata">

**Author:** ![jasonjwwilliams](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jasonjwwilliams/32/101_2.png) [@jasonjwwilliams](https://discourse.chef.io/u/jasonjwwilliams)\
**Post date:** [May 26, 2011, 5:51am UTC](https://discourse.chef.io/t/selective-inclusion-of-attribute-files/1856/3 "2011-05-26T05:51:32Z")

</div>

This is a specialized MySQL install (special binary for various reasons). Was hoping to just make it a variant of our main MySQL cookbook. Sounds like the better option is making it it's own cookbook. Since its more than just attribute customization. Thank you for your help.

-J

Sent via iPhone

Is your email Premiere?

On May 25, 2011, at 22:06, Adam Jacob [adam@opscode.com](mailto:adam@opscode.com) wrote:

> On May 25, 2011, at 4:56 PM, Jason J. W. Williams wrote:
> 
> > If I have two attribute files (server\_type\_a.rb and server\_type\_b.rb)  
> > how can I ensure that recipes/default.rb only uses  
> > attributes/server\_type\_a.rb and recipes/server\_b.rb only uses  
> > attributes/server\_type\_b.rb?
> 
> If you really want this, you can check to see if the current node has a role/recipe/tag applied inside the attribute files.
> 
> A better way, though, would be to use a role for this - have a single attribute file that sets a sane default, and a role for server\_type\_a and server\_type\_b.
> 
> Best,  
> Adam

---

<div class="post-metadata">

**Author:** ![vaibha.5](https://avatars.discourse-cdn.com/v4/letter/v/e56c9b/32.png) [@vaibha.5](https://discourse.chef.io/u/vaibha.5)\
**Post date:** [November 17, 2017, 12:34pm UTC](https://discourse.chef.io/t/selective-inclusion-of-attribute-files/1856/4 "2017-11-17T12:34:52Z")

</div>

is there any way to use databag item or json file value in my attribute file in .rb file iam able to read these value directly in my recipes by using syntax data\_bag\_item(‘test’,‘ix1csqlwin1’)[‘instance\_name’] but in the same way i want to use the json file item in my attribute value and use it further

check= data\_bag\_item(‘test’,‘ix1csqlwin1’)[‘instance\_name’]

default[‘sqlserver’][‘instance\_name’] = check

if there’s any way than kindly suggest
