<florian.engelmann@bt.com>
2010-Jan-14 09:17 UTC
[Puppet Users] custom init script and status exit codes
Hello, we are running a custom ssh server on another port than the original sshd on all of our hosts. We use puppet to roll out this configuration. It is just creating a symbolic link to the original sshd and does copy its custom config file and its own init script. This works on all our different operating systems (Solaris 8, 9, 10, Debian 4, 5 and Red Hat 4, 5). 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 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Silviu Paragina
2010-Jan-14 10:45 UTC
Re: [Puppet Users] custom init script and status exit codes
I''m guessing you did /etc/init.d/btsh start; echo $? and it works fine. (also for stop and restart) 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 florian.engelmann@bt.com wrote:> Hello, > we are running a custom ssh server on another port than the original > sshd on all of our hosts. We use puppet to roll out this configuration. > It is just creating a symbolic link to the original sshd and does copy > its custom config file and its own init script. This works on all our > different operating systems (Solaris 8, 9, 10, Debian 4, 5 and Red Hat > 4, 5). > > 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'' > Regards,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 > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
<florian.engelmann@bt.com>
2010-Jan-14 12:45 UTC
RE: [Puppet Users] custom init script and status exit codes
Hello Silviu, thank you for your fast answer. The problem is fixed now. The script was starting with some comment and not "#!/bin/sh". On Red Hat this was no problem but on Debian it did not work. Regards, Florian> -----Original Message----- > From: puppet-users@googlegroups.com[mailto:puppet-users@googlegroups.com]> On Behalf Of Silviu Paragina > Sent: Thursday, January 14, 2010 11:46 AM > To: puppet-users@googlegroups.com > Subject: Re: [Puppet Users] custom init script and status exit codes > > I''m guessing you did > /etc/init.d/btsh start; echo $? > and it works fine. (also for stop and restart) > > What you should do is add some debugging code. I think echo debugstuff> >2 would be just enough, if not write in a separate file (for execsis> enough). > The most likely cause for the script to work on command line and notin> 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 > > florian.engelmann@bt.com wrote: > > Hello, > > we are running a custom ssh server on another port than the original > > sshd on all of our hosts. We use puppet to roll out thisconfiguration.> > It is just creating a symbolic link to the original sshd and doescopy> > its custom config file and its own init script. This works on allour> > different operating systems (Solaris 8, 9, 10, Debian 4, 5 and RedHat> > 4, 5). > > > > The problem is on Debian puppet is not able to handle the exit codesof> > this custom init script the right way. This is a part of mymanifest:> > > > 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 andwith> > 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 refreshon> > 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'' > > Regards,err: //Node[defr1glvnms31]/ssh/Service[btsh]/ensure: changefrom> 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 originalssh> > init script is working fine but I do not want to use this onebecause it> > is Debian specific and I want one script on all operating systems. > > > > Thank you for your help. > > > > Regards, > > Flo > > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.