The problem is on Debian puppet is not able to handle the exit codes of
this custom init script the right way. This is a part of my manifest:
service { btsh:
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
#pattern => "/opt/BTsh/bin/btsh",
#restart => "/etc/init.d/btsh restart",
#stop => "/etc/init.d/btsh stop",
#start => "/etc/init.d/btsh start",
subscribe => File [ "/opt/BTsh/conf/btsh_config"
],
require => Exec [ "/bin/ln -s /usr/sbin/sshd
/opt/BTsh/bin/btsh" ],
#require => Service [ "sshd" ],
require => $os ? {
RedHat => Package ["openssh"],
Debian => Package ["ssh"]
},
}
The init script does exit with code 0 if the process is running and with
exit code 3 if the process is not running.
#> /etc/init.d/btsh status; echo $?
btsh is running.
0
But running puppetd -td shows me these lines:
debug: Service[btsh](provider=debian): Executing 'ps -ef'
debug: Service[btsh](provider=debian): PID is 24079
debug: Puppet::Type::Service::ProviderDebian: Executing
'/usr/sbin/update-rc.d -n -f btsh remove'
notice: //Node[defr1glvnms31]/ssh/Service[btsh]: Triggering 'refresh'
from 4 dependencies
debug: Service[btsh](provider=debian): Executing 'ps -ef'
debug: Service[btsh](provider=debian): PID is 24079
debug: Service[btsh](provider=debian): Executing '/etc/init.d/btsh
restart'
err: //Node[defr1glvnms31]/ssh/Service[btsh]: Failed to call refresh on
Service[btsh]: Could not restart Service[btsh]: Execution of
'/etc/init.d/btsh restart' returned 1: at
/pkg/nagios/puppet/manifests/classes/ssh.pp:74
If I enable hasstatus I get these messages:
debug: Service[btsh](provider=debian): Executing '/etc/init.d/btsh
status'
debug: Puppet::Type::Service::ProviderDebian: Executing
'/usr/sbin/update-rc.d -n -f btsh remove'
debug: //Node[defr1glvnms31]/ssh/Service[btsh]: Changing ensure
debug: //Node[defr1glvnms31]/ssh/Service[btsh]: 1 change(s)
debug: Service[btsh](provider=debian): Executing '/etc/init.d/btsh
start'
err: //Node[defr1glvnms31]/ssh/Service[btsh]/ensure: change from stopped
to running failed: Could not start Service[btsh]: Execution of
'/etc/init.d/btsh start' returned 1: at
/pkg/nagios/puppet/manifests/classes/ssh.pp:74
notice: //Node[defr1glvnms31]/ssh/Service[btsh]: Triggering 'refresh'
from 4 dependencies
debug: Service[btsh](provider=debian): Executing '/etc/init.d/btsh
status'
debug: //Node[defr1glvnms31]/ssh/Service[btsh]: Skipping restart;
service is not running
Does naybody know what is wrong with my init script? The original ssh
init script is working fine but I do not want to use this one because it
is Debian specific and I want one script on all operating systems.
Thank you for your help.
Regards,
Flo
What you should do is add some debugging code. I think echo debug stuff
>2 would be just enough, if not write in a separate file (for execs is
enough).
The most likely cause for the script to work on command line and not in
puppet is environment, so you should start by checking the environment
variable (especially path) and the current directory.
Other than there is a 99% chance that the script is at fault, and not
puppet.
Silviu
> Regards,err: //Node[defr1glvnms31]/ssh/Service[btsh]/ensure: change from stopped
Regards,
Florian