[chef] Re: Trigger an ohai update within a recipe?

Chronological Thread 
  • From: "Leinartas, Michael" < >
  • To: " " < >
  • Subject: [chef] Re: Trigger an ohai update within a recipe?
  • Date: Sun, 25 Jul 2010 01:38:41 -0500
  • Accept-language: en-US
  • Acceptlanguage: en-US

Title: Re: [chef] Trigger an ohai update within a recipe?
Well here's one way I found, though I'm hoping there's something cleaner than this out there:

ruby_block "reload_ohai" do
  block do
    ohai = Ohai::System.new
    node.automatic_attrs = ohai.data

I tried having this executed by a notify but it doesnt work, I think because notify appears to be non-blocking and ohai takes a few seconds to collect the data. By the time that happens, the template resource has already been called.  Kindof sucks because it means this ohai reload will take place every time the script is run, not just when the user is created on the first run.

From: "Leinartas, Michael" < "> >
Reply-To: " "> " < "> >
Date: Sat, 24 Jul 2010 20:34:26 -0500
To: " "> " < "> >
Subject: [chef] Trigger an ohai update within a recipe?

I'm running into a problem with a recipe. This seems like a common case so I'm hoping there's a simple solution.

I have a recipe that configures a daemon (maradns fwiw) which drops root privileges to a uid/gid configured in the daemon's config file which is generated by a template.  The recipe first runs the User resource to create the user if necessary.

So the problem is, in the template I refer to node[:etc][:passwd][:maradns][:uid] and node[:etc][:group][:maradns][:gid] but at that point ohai hasn't picked up those values and cached them so the template generation fails.  On a subsequent run, the template is generated successfully.

So is there some way for me to trigger an update of ohai within the recipe? If not, I'll file a bug for a feature request as, again, this seems like a relatively common case.

Archive powered by MHonArc 2.6.16.