[chef] Re: Re: Using resources in a library?

Chronological Thread 
  • From: Nate Meyer < >
  • To:
  • Subject: [chef] Re: Re: Using resources in a library?
  • Date: Wed, 07 Oct 2015 00:32:25 +0000

Well that certainly was easy :) Thanks Joe!

On Tue, Oct 6, 2015 at 5:21 PM Jos Backus < "> > wrote:
Pass an empty run_context into the ChefGem.new call, created like this?

run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)

From: Nate Meyer
Reply-To: " " target="_blank"> "
Date: Tuesday, October 6, 2015 at 5:05 PM
To: " " target="_blank"> "
Subject: [chef] Using resources in a library?

Hi everyone,

I'm trying to add a gem dependency to a library. I found a couple conversations talking about using resources in libraries in my travels:

In both, the most reasonable advice is to create an instance of the resource's class and call #run_action(:whatever) to get it to execute immediately. From my testing, this doesn't work, with the problem specifically being this code snippet and error: https://gist.github.com/notnmeyer/04bc1c0be0e41504cd62

My first thought was to pass it run_context... But there's no run_context at this point for me to pass to the resource's constructor.

To demonstrate in further detail, I put together a quick cookbook with a Test Kitchen suite: https://github.com/notnmeyer/gem-dep

Any thoughts? What's the proper way to immediately execute a resource during compile time?


Archive powered by MHonArc 2.6.16.