I'd like to implement a basic 'onlyif' property, as existing in 'exec'
type, to 'service' type. Rather than patching the original puppet code,
I think I could use the custom type mechanism, and implement my own
'conditional_service' type. However, in order to keep the benefit of
existing providers, I think renaming the type isn't the best solution.
So, would it possible to either inherit the original type definition,
and just add the new property, or distributing a modified type copy as
part of a module would also replace original type definition for this
module ?
BTW, the exact intent is to allow to test the configuration file syntax
before reloading a service, and avoid reloading it with an invalid
state. Something as:
file { "/etc/openldap/slapd.conf":
content => template("slapd.conf.erb"),
notify => Service["slapd"]
}
service { "slapd":
ensure => "running",
onlyif => "/usr/sbin/slaptest"
}
--
BOFH excuse #362:
Plasma conduit breach
Personally, I think this should be taken care of in the init script.
But if you really want to do it from puppet I suppose you could override
the start parameter of the service type...
To fail the resource if slaptest fails...
service { "slapd":
ensure => "running",
start => "/usr/sbin/slaptest && service slapd start",
}
To continue silently but not start slapd....
service { "slapd":
ensure => "running",
start => "( /usr/sbin/slaptest && service slapd start) || /bin/true",
}
But, IMO, a service init script should take care of its own pre-req's...
HTH
Craig
--
Craig Dunn | http://www.craigdunn.org
Yahoo/Skype: craigrdunn | Twitter: @crayfishX
> But, IMO, a service init script should take care of its own pre-req's...
Well, I see at least two reasons not to do it.
First, I'd actually like to make more than just 'restart only if
correct', rather something as 'if correct then reload, else notify'. In
order to use arbitrary notification mechanism (nagios, in our case, with
a mail fallback), I'd rather manage this out of init script.
The second is to avoid interfering with something wich is part of the
distribution. If I'm forking redhat iniscript, I have to follow any
fix/evolution/whatever, which is painful. BTW, redhat initscript already
support this kind of check, but only at start stage, meaning restart
action will do 'stop, check, and refuse to start' :(
--
BOFH excuse #230:
Lusers learning curve appears to be fractal
I don't want to interfere with native distribution initscripts, mainly
for maintenance reasons. However, using a custom wrapper could be the
solution here.
--
BOFH excuse #297:
Too many interrupts