Chef execution order

Hi all, im having problems with getting a method to run at convergence
instead of at cookbook compilation time.

I have a library consisting of a set a of methods (helper methods and
then one that uses the helpers to trigger a few resources) (used the
following as reference:


).

I then include the module in a recipe and call the necessary wrapper
function:
##############
class Chef::Recipe
include MyModule
end

mymodule_method
##############

What I am seeing is that the remote_file resource used in
mymodule_method isnt running but code that comes after it expecting it
to have worked then fails. Im assuming this is because the method is
running during cookbook compilation based on the output. Is there a way
I can prevent this from happening and only run at convergence?

Thanks,

On Mon, May 5, 2014 at 12:53 AM, Julio Lajara ju2wheels@gmail.com wrote:

Hi all, im having problems with getting a method to run at convergence
instead of at cookbook compilation time.

I have a library consisting of a set a of methods (helper methods and then
one that uses the helpers to trigger a few resources) (used the following as
reference:
https://github.com/stackforge/cookbook-openstack-common/tree/master/libraries
).

I then include the module in a recipe and call the necessary wrapper
function:
##############
class Chef::Recipe
include MyModule
end

mymodule_method
##############

What I am seeing is that the remote_file resource used in mymodule_method
isnt running but code that comes after it expecting it to have worked then
fails. Im assuming this is because the method is running during cookbook
compilation based on the output. Is there a way I can prevent this from
happening and only run at convergence?

Run mymodule_method inside a ruby_block resource, because the contents
of the block are run at converge-time.

Example: https://github.com/juliandunn/oracle-instantclient/blob/master/recipes/sqlplus.rb#L52-L57

  • Julian

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: Julian Dunn's Blog - Commentary on media, technology, and everything in between. * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]