Run chef_gem library methods lazily


Hi All,

When chef_gems are used in a cookbook, is it possible to run the methods lazily?

For context, I’m working with the chef-consul cookbook, and node.first_service(name) appears to be run at compile-time, so it fails if consul is not already live and well on the host (the install is also handled by Chef).

If I comment out the block with node.first_service(name), Consul gets installed, and the cookbook runs fine thereafter with that block uncommented.

I understand I can wrap things in a ruby_block in my cookbook, but is there a way to defer that upstream?

Relevant method: