service resource type

33 views
Skip to first unread message

Rost

unread,
Aug 6, 2012, 2:45:01 PM8/6/12
to puppet...@googlegroups.com
Hi everbody !!!

I would like to know how to use the parameter start of the service resource type. Because i want to use my own script to start my service.
I have tried 2 cases and did'nt work.

Here are the cases :

service { 'myservice':
   start => '/root/myinit_script.sh'
}

service { 'myservice':
   start => "/root/myinit_script.sh"
}


Do you have any idea on how to use this parameter?

Thans very much for help.


Peter Bukowinski

unread,
Aug 6, 2012, 3:39:23 PM8/6/12
to puppet...@googlegroups.com
Rost,

Is what you pasted about the entire 'myservice' resource definition or did you leave our the 'ensure' lines for brevity? Make sure you have an 'ensure => running," line in the service definition if you want puppet to ensure that state. There might also be  a problem with your init script. Can you please post the contents of myinit_script.sh here?

-- 
Peter Bukowinski

Rost

unread,
Aug 6, 2012, 5:03:26 PM8/6/12
to puppet...@googlegroups.com
hi Peter,

Thanks for watching .
Actually that's all my service resource without the ensure => running. Should I use that parameter to have puppet launch my script?
Here is the content of myinit_script.sh.

#!/bin/sh
echo "Starting Apache2"
/opt/apache2/bin/apachectl -f /opt/apache2/conf/httpd -k start

Thanks a lot.

Peter Bukowinski

unread,
Aug 6, 2012, 5:17:37 PM8/6/12
to puppet...@googlegroups.com
Yes, you should have the ensure parameter in there:

service { 'myservice':
ensure => running,
start => '/root/myinit_script.sh',
}

Since you're using a custom start script, you may need to also specify custom status and restart scripts so that puppet can better control the process if the httpd config file ever changes and you want the service to restart automatically.

--
Peter
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/o_m0fn9FLnAJ.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

--
Peter

Rost

unread,
Aug 6, 2012, 5:57:42 PM8/6/12
to puppet...@googlegroups.com
Thank you very much Peter,
It's working, I just love Puppet.

> To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.

Denmat

unread,
Aug 7, 2012, 4:14:00 AM8/7/12
to puppet...@googlegroups.com
Hi,

Depending on your version latest docs are described here:

You should specify whether you want the service enabled or not and try to provide a status script so puppet can figure out if the service is already running or not. Also make sure you provide good exit codes on your scripts.

Cheers,
Den
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/W1dRjH4ugwoJ.

To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages