Feature #2481
Override commands in redhat service provider
| Status: | Closed | Start date: | 08/02/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | service | |||
| Target version: | 0.25.0 | |||
| Affected Puppet version: | 0.24.8 | Branch: | ||
| Keywords: | ||||
| Votes: | 0 |
Description
Using puppet 0.24.8 from epel on CentOS 5.3
I want to override the status command for a service with provider => ‘redhat’, but it doesn’t seem to be possible.
If I change the provider to ‘init’ or ‘base’ I can specify the status command, but I don’t get the chkconfig integration that comes with the redhat service provider.
This is my service definition that doesn’t work:
service { "service-redhat-httpd":
enable => "false",
ensure => "stopped",
hasrestart => "true",
hasstatus => "true",
name => "httpd",
status => "pgrep httpd -P 1",
require => Package[httpd],
}
This definiition does work but has no chkconfig integration:
service { "service-redhat-httpd":
ensure => stopped,
hasstatus => true,
name => "httpd",
start => '/sbin/service start httpd',
stop => '/sbin/service stop httpd',
status => "pgrep httpd -P 1",
provider => 'base',
require => Package[httpd],
}
So, basically, I’d like to have the command-override capability added to the redhat provider.
I’ve added a patch that seems to fix my specific issue.
R.
Related issues
History
Updated by Luke Kanies over 2 years ago
- Status changed from Unreviewed to Accepted
- Target version set to 2.6.0
Looks like this is really similar to #2026, but we didn’t fix it for the status command. Stupid of us.
Or am I reading this wrong?
Updated by James Turnbull over 2 years ago
- Status changed from Accepted to In Topic Branch Pending Review
Can you try the following patch:
diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service
index 63a545d..e39058e 100755
--- a/lib/puppet/provider/service/redhat.rb
+++ b/lib/puppet/provider/service/redhat.rb
@@ -60,10 +60,10 @@ Puppet::Type.type(:service).provide :redhat, :parent => :ini
end
end
- def status
+ def statuscmd
if @resource[:hasstatus] == :true
begin
- service(@resource[:name], "status")
+ [command(:service), @resource[:name], "status"]
return :running
rescue
return :stopped
Updated by Robin Bowes over 2 years ago
Updated by Robin Bowes over 2 years ago
James Turnbull wrote:
Can you try the following patch:
[…]
That’s subtly different to my patch. I decided that if the definition specified a status command then we should use it, rather than requiring “hasstatus” to be true as well.
Other than that, it works.
While you’re at it, it looks like the restart command can’t be overridden either – it calls “service foo” regardless.
Updated by James Turnbull over 2 years ago
diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service
index 63a545d..fe2c98b 100755
--- a/lib/puppet/provider/service/redhat.rb
+++ b/lib/puppet/provider/service/redhat.rb
@@ -52,18 +52,18 @@ Puppet::Type.type(:service).provide :redhat, :parent => :ini
end
end
- def restart
+ def restartcmd
if @resource[:hasrestart] == :true
- service(@resource[:name], "restart")
+ [command(:service), @resource[:name], "restart"]
else
super
end
end
- def status
+ def statuscmd
if @resource[:hasstatus] == :true
begin
- service(@resource[:name], "status")
+ [command(:service), @resource[:name], "status"]
return :running
rescue
return :stopped
Updated by James Turnbull over 2 years ago
- Status changed from In Topic Branch Pending Review to Closed
- Target version changed from 2.6.0 to 0.25.0
Pushed in commit:967eb9f52938d8849b99686bf2c0b9da9a183399 in branch master.
Updated by James Turnbull over 2 years ago
Pushed update in commit:b611c34de2ff9fe35633ca2154bc64c6c793af7d in branch master. After some more testing it appears original status patch works better. :)