[chef] Re: Prevent resource from triggering multiple times in a single run


Chronological Thread 
  • From: Lamont Granquist < >
  • To:
  • Cc: Mark Selby < >
  • Subject: [chef] Re: Prevent resource from triggering multiple times in a single run
  • Date: Sun, 30 Aug 2015 18:24:38 -0700


If its really a remote_file resource then those support etags and last-modified-since so it won't be expensive to run multiple times.

Generally when you have a call-many-times-run-only-once pattern you're looking at include_recipe'ing the expensive thing so it only gets created once in the resource collection.

You can also use a definition to edit the resource collection and the definition can check and exit if the resource always exists.

On 08/29/2015 01:42 PM, Mark Selby wrote:
remote_file “/var/tmp/somefile” do
    source “http://binfiles/somefile”
    owner “root”
    group “root”
    mode “0644”
    action :create
end

Lets just suppose that this is a somewhat expensive operation that may need to get called multiple times during a converge depending on what recipes the node is running. I would like to say “do not execute this resource if it has already been triggered during this run”

I would also not like to use a marker file if I can avoid it.

I know we have delayed execution but that is not what I want. I need this to trigger on the first call and then not again. Can I use the run_status or run_context to accomplish this?

Thanks!




Archive powered by MHonArc 2.6.16.

§