[chef] Re: Re: RE: Helper and Resource Order


Chronological Thread 
  • From: Lamont Granquist < >
  • To:
  • Subject: [chef] Re: Re: RE: Helper and Resource Order
  • Date: Fri, 28 Aug 2015 16:10:44 -0700


::Chef::Resource::RubyBlock.send(:include, Helpers)

On 08/28/2015 01:45 PM, Doug Garstang wrote:
" type="cite">
Unfortunately, that:

file '/tmp/foo' do
end

ruby_block 'Call_helper' do
  block do
    ::Chef::Recipe.send(:include, Helpers)
    func()
  end
end

yields:

==> node1: NoMethodError
==> node1: -------------
==> node1: undefined method `func' for Chef::Resource::RubyBlock

Douglas.



On Fri, Aug 28, 2015 at 1:37 PM, Alex Myasnikov < " target="_blank"> > wrote:

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: " target="_blank"> ]
Sent: Friday, August 28, 2015 1:27 PM
To: " target="_blank">
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.

§