# Ohai Plugins Available when evaluating attributes.rb?

**URL:** <https://discourse.chef.io/t/ohai-plugins-available-when-evaluating-attributes-rb/6236>\
**Category:** Chef Infra (archive)\
**Created:** [January 29, 2015, 10:04pm UTC](https://discourse.chef.io/t/ohai-plugins-available-when-evaluating-attributes-rb/6236 "2015-01-29T22:04:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Douglas\_Garstang](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@Douglas\_Garstang](https://discourse.chef.io/u/Douglas_Garstang)\
**Post date:** [January 29, 2015, 10:04pm UTC](https://discourse.chef.io/t/ohai-plugins-available-when-evaluating-attributes-rb/6236/1 "2015-01-29T22:04:23Z")

</div>

Is the data returned from custom ohai plugins going to be available when  
evaluating stuff in attributes.rb? I have a plugin which tells me if I am  
running inside an EC2 VPC. I’d like to use that in my attributes.rb with  
some ‘when’ logic to set some attributes. Yes? No?

Doug

---

<div class="post-metadata">

**Author:** ![Ranjib](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ranjib/32/1040_2.png) [@Ranjib](https://discourse.chef.io/u/Ranjib)\
**Post date:** [January 30, 2015, 2:19am UTC](https://discourse.chef.io/t/ohai-plugins-available-when-evaluating-attributes-rb/6236/2 "2015-01-30T02:19:29Z")

</div>

yes, if its a ohai plugins it will be evaluated in the node build stage,  
which happens before cookbook compilation,

[1][https://github.com/chef/chef/blob/master/lib/chef/client.rb#L436](https://github.com/chef/chef/blob/master/lib/chef/client.rb#L436)

On Thu, Jan 29, 2015 at 2:04 PM, Douglas Garstang [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
wrote:

> Is the data returned from custom ohai plugins going to be available when  
> evaluating stuff in attributes.rb? I have a plugin which tells me if I am  
> running inside an EC2 VPC. I'd like to use that in my attributes.rb with  
> some 'when' logic to set some attributes. Yes? No?
> 
> Doug

---

<div class="post-metadata">

**Author:** ![Douglas\_Garstang](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@Douglas\_Garstang](https://discourse.chef.io/u/Douglas_Garstang)\
**Post date:** [January 30, 2015, 9:33pm UTC](https://discourse.chef.io/t/ohai-plugins-available-when-evaluating-attributes-rb/6236/3 "2015-01-30T21:33:46Z")

</div>

That's not the behaviour I saw. I was putting a 'puts' in the  
attributes/default.rb file and doing a chef-client run. Stuff set from core  
ohai was showing up. Stuff set from custom ohai plugins was not. The stuff  
from custom ohai plugins is available in recipes though.

Doug.

On Thu, Jan 29, 2015 at 6:19 PM, Ranjib Dey [dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com) wrote:

> yes, if its a ohai plugins it will be evaluated in the node build stage,  
> which happens before cookbook compilation,
> 
> [1][https://github.com/chef/chef/blob/master/lib/chef/client.rb#L436](https://github.com/chef/chef/blob/master/lib/chef/client.rb#L436)
> 
> On Thu, Jan 29, 2015 at 2:04 PM, Douglas Garstang \<[doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)
> 
> > wrote:
> 
> > Is the data returned from custom ohai plugins going to be available when  
> > evaluating stuff in attributes.rb? I have a plugin which tells me if I am  
> > running inside an EC2 VPC. I'd like to use that in my attributes.rb with  
> > some 'when' logic to set some attributes. Yes? No?
> > 
> > Doug

--  
Regards,

Douglas Garstang  
[http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
Cell: +1-805-340-5627

---

<div class="post-metadata">

**Author:** ![ssd](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@ssd](https://discourse.chef.io/u/ssd)\
**Post date:** [February 2, 2015, 12:51pm UTC](https://discourse.chef.io/t/ohai-plugins-available-when-evaluating-attributes-rb/6236/4 "2015-02-02T12:51:54Z")

</div>

Hi Douglas,

Provided that the plugin is in Ohai's load path, it should get loaded  
along side all of the built-in plugins. The one exception is the very  
first run of chef-client on a node. Since many people depend on a  
cookbook to put the custom ohai plugin in place. If you are putting  
the ohai plugin in place in a recipe and reloading ohai (even if you  
move those resources into the compile phase), then your attribute will  
be available in the recipes but not in the attribute files since the  
recipes are evaluated after attribute files inside the compile phase.

One option to get around this would be to make sure that _required_  
custom plugins get put on disk during your bootstrap process.

Sincerely,

Steven

On Fri, Jan 30, 2015 at 9:33 PM, Douglas Garstang  
[doug.garstang@gmail.com](mailto:doug.garstang@gmail.com) wrote:

> That's not the behaviour I saw. I was putting a 'puts' in the  
> attributes/default.rb file and doing a chef-client run. Stuff set from core  
> ohai was showing up. Stuff set from custom ohai plugins was not. The stuff  
> from custom ohai plugins is available in recipes though.
> 
> Doug.
> 
> On Thu, Jan 29, 2015 at 6:19 PM, Ranjib Dey [dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com) wrote:
> 
> > yes, if its a ohai plugins it will be evaluated in the node build stage,  
> > which happens before cookbook compilation,
> > 
> > [1][https://github.com/chef/chef/blob/master/lib/chef/client.rb#L436](https://github.com/chef/chef/blob/master/lib/chef/client.rb#L436)
> > 
> > On Thu, Jan 29, 2015 at 2:04 PM, Douglas Garstang  
> > [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com) wrote:
> > 
> > > Is the data returned from custom ohai plugins going to be available when  
> > > evaluating stuff in attributes.rb? I have a plugin which tells me if I am  
> > > running inside an EC2 VPC. I'd like to use that in my attributes.rb with  
> > > some 'when' logic to set some attributes. Yes? No?
> > > 
> > > Doug
> 
> --  
> Regards,
> 
> Douglas Garstang  
> [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
> Cell: +1-805-340-5627
