Knife/ohai


#1

Is it possible to use data from Ohai in a knife.rb file? Ive been
looking for a way to use platform_family? but not sure if this can be
called directly or is in some hash if its even available.

Thanks,


#2

you mean the remote node data stored in chef server ? or the local
machine’s data?

ohai can be invoked directly as:
o = Ohai::System.new ; o.all_plugins ; o[:attr] .

but this will slow down knife loading ,
for the nodes in chef server, it may be wiser to do that logic on a plugin.
Chef::Node.load(‘foo’)[:attr1] ,
as this requires rest/http stuff , which in turn requires chef to to be
configured (i.e. knife.rb)… you may be able to do this with sufficient
hacks… but it might be worth discussing what exactly you are trying to do
instead, and check if theres a cleaner way to do so

best
ranjib

On Thu, Apr 3, 2014 at 12:11 PM, Julio Lajara ju2wheels@gmail.com wrote:

Is it possible to use data from Ohai in a knife.rb file? Ive been looking
for a way to use platform_family? but not sure if this can be called
directly or is in some hash if its even available.

Thanks,


#3

Im looking for local machine data on which knife is actually being run.
If I cant get it from Ohai directly ill try host_os from rbconfig but
was looking for Ohai first.

Thanks,

On 04/03/2014 03:31 PM, Ranjib Dey wrote:

you mean the remote node data stored in chef server ? or the local
machine’s data?

ohai can be invoked directly as:
o = Ohai::System.new ; o.all_plugins ; o[:attr] .

but this will slow down knife loading ,
for the nodes in chef server, it may be wiser to do that logic on a
plugin.
Chef::Node.load(‘foo’)[:attr1] ,
as this requires rest/http stuff , which in turn requires chef to to
be configured (i.e. knife.rb)… you may be able to do this with
sufficient hacks… but it might be worth discussing what exactly you
are trying to do instead, and check if theres a cleaner way to do so

best
ranjib

On Thu, Apr 3, 2014 at 12:11 PM, Julio Lajara <ju2wheels@gmail.com
mailto:ju2wheels@gmail.com> wrote:

Is it possible to use data from Ohai in a knife.rb file? Ive been
looking for a way to use platform_family? but not sure if this can
be called directly or is in some hash if its even available.

Thanks,