[Pkg-puppet-devel] Bug#775795: Patch to use /usr/sbin/service in Debian service provider

Gaudenz Steinlin gaudenz at debian.org
Thu Feb 5 10:12:22 UTC 2015


Stephen Gran <sgran at debian.org> writes:

> Hi,
>
> This one time, at band camp, Stig Sandbeck Mathisen said:
>> 
>> Hello,
>> 
>> Thanks for the patch.  It looks like it has the correct solution, using
>> the Debian abstraction layer over the alternative init systems.
>> 
>> However, I've found a problem with it using the "puppet resource"
>> command. Could you see if you find what causes it?

The idea in my patch is to add the service_cmd definition to ensure that
this provider is only choosen if the service command is available. But
you can't use this command because of the way the provider works. The
problem is that startcmd, stopcmd, etc. should return an array with the
command and it's argument.

The problem is probably that I replaced the hardcoded /usr/sbin/service
by a variable after testing the patch and screwed that up somehow. I'm
right now looking into this and will send a new patch as soon as it's
fixed.

If I understand Stephens patch correctly it directly executes the
service comamnd during the call to XXXcmd. As far as I can see this is
not the way things should work (looking at provider/service/base.rb).

Gaudenz

>> 
>> With puppet 3.7.22-1:
>> 
>> ,----
>> | root at dagon:~# puppet resource service apache2
>> | service { 'apache2':
>> |   ensure => 'stopped',
>> |   enable => 'true',
>> | }
>> `----
>> 
>> With your patch:
>> 
>> ,----
>> | root at dagon:~# puppet resource service apache2
>> | Error: Could not run: undefined local variable or method `service' for #<Puppet::Type::Service::ProviderDebian:0x000000029b9d88>
>> `----
>
> Try this (lightly tested) one instead.  The problem is in the definition
> and use of the service command in the first patch.
>
> Cheers,
> -- 
>  -----------------------------------------------------------------
> |   ,''`.                                            Stephen Gran |
> |  : :' :                                        sgran at debian.org |
> |  `. `'                        Debian user, admin, and developer |
> |    `-                                     http://www.debian.org |
>  -----------------------------------------------------------------
> From 2eae3a2a71de50889535f0e917ac6f4ecaeb8975 Mon Sep 17 00:00:00 2001
> From: Gaudenz Steinlin <gaudenz at soziologie.ch>
> Date: Sat, 31 Jan 2015 16:09:08 +0100
> Subject: [PATCH] Use /usr/sbin/service in Debian service provider
>
> Closes: #775795
> ---
>  .../0004-debian-service-provider-use-service.patch | 56 ++++++++++++++++++++++
>  debian/patches/series                              |  1 +
>  2 files changed, 57 insertions(+)
>  create mode 100644 debian/patches/0004-debian-service-provider-use-service.patch
>
> diff --git a/debian/patches/0004-debian-service-provider-use-service.patch b/debian/patches/0004-debian-service-provider-use-service.patch
> new file mode 100644
> index 0000000..29a4277
> --- /dev/null
> +++ b/debian/patches/0004-debian-service-provider-use-service.patch
> @@ -0,0 +1,56 @@
> +From: Gaudenz Steinlin <gaudenz at debian.org>
> +Subject: Use /usr/sbin/service for service management on Debian
> +
> +In Debian jessie systemd will be the default init system. But the old system V
> +and other alternative init systems are still supported. /usr/sbin/service
> +provides an abstraction layer which is able to start, stop and restart
> +services independent of the init system used.
> +
> +Bug: https://tickets.puppetlabs.com/browse/PUP-2023
> +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=775795
> +---
> +Index: puppet/lib/puppet/provider/service/debian.rb
> +===================================================================
> +--- puppet.orig/lib/puppet/provider/service/debian.rb	2015-01-31 17:30:09.000000000 +0100
> ++++ puppet/lib/puppet/provider/service/debian.rb	2015-01-31 23:05:10.477108925 +0100
> +@@ -16,6 +16,11 @@
> +   # is resolved.
> +-   commands :invoke_rc => "/usr/sbin/invoke-rc.d"
> ++   commands :invoke_rc => "/usr/sbin/invoke-rc.d", :service => "service"
> + 
> +   defaultfor :operatingsystem => :debian
> + 
> +   # Remove the symlinks
> +@@ -61,4 +66,28 @@
> +     update_rc "-f", @resource[:name], "remove"
> +     update_rc @resource[:name], "defaults"
> +   end
> ++
> ++  # The start, stop, restart and status command use service
> ++  # this makes sure that these commands work with whatever init
> ++  # system is installed
> ++  def startcmd
> ++    service @resource[:name], "start"
> ++  end
> ++
> ++  # The stop command is just the init script with 'stop'.
> ++  def stopcmd
> ++    service @resource[:name], "stop"
> ++  end
> ++
> ++  def restartcmd
> ++    (@resource[:hasrestart] == :true) && service @resource[:name], "restart"
> ++  end
> ++
> ++  # If it was specified that the init script has a 'status' command, then
> ++  # we just return that; otherwise, we return false, which causes it to
> ++  # fallback to other mechanisms.
> ++  def statuscmd
> ++    (@resource[:hasstatus] == :true) && service @resource[:name], "status"
> ++  end
> ++
> + end
> diff --git a/debian/patches/series b/debian/patches/series
> index 471a23b..6543a01 100644
> --- a/debian/patches/series
> +++ b/debian/patches/series
> @@ -1,3 +1,4 @@
>  0001-Do-not-require-rubygems.patch
>  0002-Set-passenger-puppet-master-document-root.patch
>  0003-fix-puppet-master-logcheck-rule.patch
> +0004-debian-service-provider-use-service.patch
> -- 
> 2.1.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 810 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-puppet-devel/attachments/20150205/2d574c5e/attachment.sig>


More information about the Pkg-puppet-devel mailing list