Taking temporary downtime for a service

Hello,

It’s common to temporarily disable a service while performing certain
changes:

recipe[monit::default]

service :monit do

action [:enable, :start]
end

recipe[myapp::deploy]

service :monit do
action [:stop]
end

deploy happens …

service :monit do
action [:start]
end

I’d like to know if anybody has a good pattern for triggering start/stop
actions for a service without duplicating the resource within a recipe.
Alternative methods to achieve the same effect are welcome!

Thanks,


Jeremy Voorhis

is this a one off task? I am using a bunch of task that are one-offs using
knife-plugins and chef-apply . Tasks that does not fit very easily into
periodic chef runs / does not contribute to the overall convergence are a
good fit for this. knife+chef apply combo gives you the ability to interact
with chef server and also chef resource dsl. Do you want to start and stop
this service in every chef run ?

On Mon, Mar 18, 2013 at 4:46 PM, Jeremy Voorhis jvoorhis@gmail.com wrote:

Hello,

It's common to temporarily disable a service while performing certain
changes:

recipe[monit::default]

service :monit do

...

action [:enable, :start]
end

recipe[myapp::deploy]

service :monit do
action [:stop]
end

deploy happens ...

service :monit do
action [:start]
end

I'd like to know if anybody has a good pattern for triggering start/stop
actions for a service without duplicating the resource within a recipe.
Alternative methods to achieve the same effect are welcome!

Thanks,

--
Jeremy Voorhis

That's a good question. Ideally, there should be as few one-offs as
possible, and while it's common for this monit-watched application to be
deployed during a chef run, that is not always the case. I think what I'm
looking for is some way to wrap a resource's execution with before- and
after- notifications, but I don't know if it's worth the added complexity.

On Mon, Mar 18, 2013 at 4:54 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

is this a one off task? I am using a bunch of task that are one-offs using
knife-plugins and chef-apply . Tasks that does not fit very easily into
periodic chef runs / does not contribute to the overall convergence are a
good fit for this. knife+chef apply combo gives you the ability to interact
with chef server and also chef resource dsl. Do you want to start and stop
this service in every chef run ?

On Mon, Mar 18, 2013 at 4:46 PM, Jeremy Voorhis jvoorhis@gmail.comwrote:

Hello,

It's common to temporarily disable a service while performing certain
changes:

recipe[monit::default]

service :monit do

...

action [:enable, :start]
end

recipe[myapp::deploy]

service :monit do
action [:stop]
end

deploy happens ...

service :monit do
action [:start]
end

I'd like to know if anybody has a good pattern for triggering start/stop
actions for a service without duplicating the resource within a recipe.
Alternative methods to achieve the same effect are welcome!

Thanks,

--
Jeremy Voorhis

--
Jeremy Voorhis

I recently had a similar need, although for a very different use case. You can fairly easily wrap around an existing resource action by implementing a monkey patch similar to what I did here: https://github.com/kkeane/selinux/blob/master/libraries/monkeys.rb (the interesting bit starts around line 164).

There is a fundamental issue with wrapping the way you want it, though: you would have to predict the future when deciding whether or not to stop the service. You probably need to split the deploying into two separate parts:

  •      Decide whether to deploy
    
  •      Stop the service
    
  •      Deploy
    
  •      Start the service
    

From: Jeremy Voorhis [mailto:jvoorhis@gmail.com]
Sent: Monday, March 18, 2013 5:14 PM
To: chef@lists.opscode.com
Subject: [chef] Re: Re: Taking temporary downtime for a service

That’s a good question. Ideally, there should be as few one-offs as possible, and while it’s common for this monit-watched application to be deployed during a chef run, that is not always the case. I think what I’m looking for is some way to wrap a resource’s execution with before- and after- notifications, but I don’t know if it’s worth the added complexity.

On Mon, Mar 18, 2013 at 4:54 PM, Ranjib Dey <dey.ranjib@gmail.com mailto:dey.ranjib@gmail.com > wrote:

is this a one off task? I am using a bunch of task that are one-offs using knife-plugins and chef-apply . Tasks that does not fit very easily into periodic chef runs / does not contribute to the overall convergence are a good fit for this. knife+chef apply combo gives you the ability to interact with chef server and also chef resource dsl. Do you want to start and stop this service in every chef run ?

On Mon, Mar 18, 2013 at 4:46 PM, Jeremy Voorhis <jvoorhis@gmail.com mailto:jvoorhis@gmail.com > wrote:

Hello,

It’s common to temporarily disable a service while performing certain changes:

recipe[monit::default]

service :monit do

action [:enable, :start]

end

recipe[myapp::deploy]

service :monit do

action [:stop]

end

deploy happens …

service :monit do

action [:start]

end

I’d like to know if anybody has a good pattern for triggering start/stop actions for a service without duplicating the resource within a recipe. Alternative methods to achieve the same effect are welcome!

Thanks,

Jeremy Voorhis

Jeremy Voorhis