Ohai Plugins Available when evaluating attributes.rb?


#1

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


#2

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

On Thu, Jan 29, 2015 at 2:04 PM, Douglas Garstang 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


#3

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 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

On Thu, Jan 29, 2015 at 2:04 PM, Douglas Garstang <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
Email: doug.garstang@gmail.com
Cell: +1-805-340-5627


#4

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 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 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

On Thu, Jan 29, 2015 at 2:04 PM, Douglas Garstang
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
Email: doug.garstang@gmail.com
Cell: +1-805-340-5627