- From: Alex Soto <
- Subject: [chef] Re: Re: Trigger an ohai update within a recipe?
- Date: Mon, 26 Jul 2010 12:02:28 -0700
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:mime-version:content-type:subject:date:in-reply-to:to :references:message-id:x-mailer; b=Dhj1cHLMD1YssoQPvRRA8k+I6B9vpiZ/kU0b3IiPz9QEcQb0SEwLMFL/uYxJGyklIe J4eaQjNfy+KV/Ck/Xpp7R45ApL4jgs49quF7F3J1lb7Ahg8IwoWEgce0C1yMMB5cOaXo jVily0RApjdAksCX0c+uEgk/1v/nTYpZykKjE=
|Going off the top of my head, so dbl check the docs, but try:|
setting 'action :nothing' on the ruby block
then 'notifies :action, resources(:ruby_block => 'reload_ohai'), :immediate' in the resource you want to trigger the block
On Jul 24, 2010, at 11:38 PM, Leinartas, Michael wrote:
Well here's one way I found, though I'm hoping there's something cleaner than this out there:
ruby_block "reload_ohai" 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" <
Date: Sat, 24 Jul 2010 20:34:26 -0500
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.