Yep - it is blocking, it is just two-phase (compile and execute.)
On Mon, Jul 26, 2010 at 12:02 PM, Alex Soto email@example.com wrote:
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
From: “Leinartas, Michael” MICHAEL.LEINARTAS@orbitz.com
Reply-To: "firstname.lastname@example.org" email@example.com
Date: Sat, 24 Jul 2010 20:34:26 -0500
To: "firstname.lastname@example.org" email@example.com
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
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.
Adam Jacob, CTO
T: (206) 508-7449 E: firstname.lastname@example.org