[chef] Re: Re: Re: notifies :before


Chronological Thread 
  • From: Seth Vargo < >
  • To: Andrew Gross < >,
  • Subject: [chef] Re: Re: Re: notifies :before
  • Date: Fri, 22 Nov 2013 11:41:40 -0800

Chef rewind is actually just a wrapper around something that’s already easy to do:


I wrote a nice Recipe DSL-like syntax for doing this in chef-sugar:

before 'service[apache2]' do
  log 'I am before the apache 2 service fires!'
end

There’s also an `after` and `compile_time` filter.

Thanks,
Seth Vargo
Solutions Engineer, Opscode

From: Andrew Gross ">Andrew Gross
Reply:  ">
Date: November 22, 2013 at 8:18:43 AM
To: chef ">
Subject:  [chef] Re: Re: notifies :before
Check out chef-rewind[1] if you want to see some code that mucks around with the ordering of a run_context.  Be forewarned, it can get a little hairy if it is your first dive in.

[1] https://github.com/bryanwb/chef-rewind


On Thu, Nov 21, 2013 at 5:25 PM, Steven De Coeyer < " target="_blank"> > wrote:
Sounds like a nice challenge to get more familiar with the internals of Chef.
Might actually look into this.

Thank you.

Kr,
Steven




On Thursday, November 21, 2013 at 6:20 AM, Steven De Coeyer wrote:

Thank you for your reply. I understand how notifies work, I was just wondering if there was an elegant way to notify resources _before_ running current resource.

I know you could do it with chaining resources through notify, but that smells a bit.

I found an issue asking the same question:
This would certainly be useful. The canonical use case is if you’re managing a service that needs to be stopped before it’s upgraded, which is common for some kinds of web app.

Unfortunately, the way most Chef providers are written now, there’s no reasonable way to implement this as a before notification. One possible avenue we haven’t explored yet is to run an individual resource in why-run mode to see if it would make a change, which might look like this in the DSL:

    service “my-web-app” do
      action :stop
      # means “only if the resource deploy[my-web-app] would make changes when running the :deploy action"
      test_resource “deploy[my-web-app]”, :deploy
    end

The implementation would still be pretty complicated, but much less so than the things we’ve tried before. Someone outside of opscode would need to take this on because I don’t think we can fit it in our priorities for quite a while.


-- 
Daniel DeLeo






Archive powered by MHonArc 2.6.16.

§