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? > > With puppet 3.7.22-1: > > ,---- > | root@dagon:~# puppet resource service apache2 > | service { 'apache2': > | ensure => 'stopped', > | enable => 'true', > | } > `---- > > With your patch: > > ,---- > | root@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 | | : :' : sg...@debian.org | | `. `' Debian user, admin, and developer | | `- http://www.debian.org | -----------------------------------------------------------------
From 2eae3a2a71de50889535f0e917ac6f4ecaeb8975 Mon Sep 17 00:00:00 2001 From: Gaudenz Steinlin <gaud...@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 <gaud...@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