[chef] RE: Helper and Resource Order


Chronological Thread 
  • From: Alex Myasnikov < >
  • To: " " < >
  • Subject: [chef] RE: Helper and Resource Order
  • Date: Fri, 28 Aug 2015 20:37:42 +0000
  • Accept-language: en-US
  • Authentication-results: spf=none (sender IP is ) ; lists.opscode.com; dkim=none (message not signed) header.d=none;lists.opscode.com; dmarc=none action=none header.from=practicefusion.com;
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:23

You can try putting it inside a ruby_block to delay running it until converge time:

 

file '/tmp/foo' do

end

 

ruby_block 'Call_helper' do

  block do

::Chef::Recipe.send(:include, Helpers)

func()

  end

end

 

HTH

 

From: Douglas Garstang [mailto:
Sent: Friday, August 28, 2015 1:27 PM
To:
Subject: [chef] Helper and Resource Order

 

I have a default recipe with this:

file '/tmp/foo' do
end
::Chef::Recipe.send(:include, Helpers)
func()



and a helper function in libaries/ with this:

module Helpers
  def func()
    Chef::Log.info("I am here")
  end
end

My chef run in vagrant shows this:

==> node1: [2015-08-28T20:24:53+00:00] INFO: I am here
==> node1: [2015-08-28T20:24:53+00:00] INFO: file[/tmp/foo] created file /tmp/foo

Obviously, the helper function func() is being called and executed before the file resource, even though the order dictates the file resource should run first. How can I ensure a specific order?

Thanks,

Douglas

The contents of this message, together with any attachments, are intended only for the use of the individual or entity to which they are addressed and may contain information that is legally privileged, confidential and exempt from disclosure. If you are not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this message, or any attachment, is strictly prohibited. If you have received this message in error, please notify the original sender or contact Practice Fusion at 415.346.7700 ext 4 immediately by telephone or by return E-mail and delete this message, along with any attachments, from your computer. Thank you



Archive powered by MHonArc 2.6.16.

§