Debian services enable on every run


#1

I was trying to kill spurious resource updating, and noticed that on ubuntu the nginx cookbook will re-enable the nginx resource on every run.

So far as I can tell, everything comes down to this line in Chef::Provider::Service::Debian#action_enable: https://github.com/opscode/chef/blob/master/lib/chef/provider/service/debian.rb#L116

The trick is that it not only verifies that the service is enabled (duh) but that the desired priority matches the current priority.

But looking at the service resource’s initializer: https://github.com/opscode/chef/blob/master/lib/chef/resource/service.rb#L44
and #priority:
https://github.com/opscode/chef/blob/master/lib/chef/resource/service.rb#L153

You can see that the default @new_resource.priority will be nil, whereas the default @current_resource.priority for a sane enabled service will be something like:
{
0 => :stop,
1 => :stop,
2 => :start,
3 => :start,
4 => :start,
5 => :start,
6 => :stop
}

What’s the reasonable thing to do? Have init-style services explicitly define their priorities (not-newb-friendly)? Only check if the service is enabled (that is, enabled in any of run levels 2-5)? Set a non-nil default priority for init services? Something else?

~j


#2

Is this the same problem as https://tickets.opscode.com/browse/CHEF-4782 ?

  • Julian

On Tue, Dec 17, 2013 at 10:38 PM, Joseph Holsten
joseph@josephholsten.com wrote:

I was trying to kill spurious resource updating, and noticed that on ubuntu the nginx cookbook will re-enable the nginx resource on every run.

So far as I can tell, everything comes down to this line in Chef::Provider::Service::Debian#action_enable: https://github.com/opscode/chef/blob/master/lib/chef/provider/service/debian.rb#L116

The trick is that it not only verifies that the service is enabled (duh) but that the desired priority matches the current priority.

But looking at the service resource’s initializer: https://github.com/opscode/chef/blob/master/lib/chef/resource/service.rb#L44
and #priority:
https://github.com/opscode/chef/blob/master/lib/chef/resource/service.rb#L153

You can see that the default @new_resource.priority will be nil, whereas the default @current_resource.priority for a sane enabled service will be something like:
{
0 => :stop,
1 => :stop,
2 => :start,
3 => :start,
4 => :start,
5 => :start,
6 => :stop
}

What’s the reasonable thing to do? Have init-style services explicitly define their priorities (not-newb-friendly)? Only check if the service is enabled (that is, enabled in any of run levels 2-5)? Set a non-nil default priority for init services? Something else?

~j


[ Julian C. Dunn jdunn@aquezada.com * Sorry, I’m ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]