On Apr 15, 4:44 pm, Jesse <[email protected]> wrote:

> case $operatingsystem {
>     centos, redhat: { $ntp = "ntp" }
>     debain, ubuntu: { $ntp = "ntpd" }

This is backwards; centos/redhat should be 'ntpd' and debian/ubuntu
should be 'ntp'.

> if $ntp == 'ntp' {
>   service { 'ntp':
>     name       => $ntp,
>     ensure     => running,
>     enable     => true,
>     hasrestart => true,
>     hasstatus  => true,
>   }}
>
> else {
>     service { 'ntpd':
>       name       => $ntp,
>       ensure     => running,
>       enable     => true,
>       hasstatus  => true,
>       hasrestart => true,
>     }
>   }

This conditional is redundant. I think it's better to use one resource
name and change the "name" attribute with the variable as you have
done (although I would a more explicit variable name like
'$ntp_service'):

service { 'ntp':
  name => $ntp_service,
  ...
}


> err: /Stage[main]//Service[ntp]/ensure: change from stopped to running
> failed: Could not start Service[ntp]: Execution of '/sbin/service ntp
> start' returned 1:  at /root/learning-manifests/ntp.pp:24

This is because of the reversal I mentioned above; it should be 'ntpd'
on CentOS, not 'ntp'.

> When I run the vanilla script, everything configures correctly and
> ntp(d) is started. Why is my second script using /sbin when it seems
> that it should be using /etc/init.d/?

Have you tried 'man service'? '/sbin/service' is a way of running init
scripts with a sanitized environment and is the preferred way of
running init scripts rather than doing so directly.

http://linux.die.net/man/8/service

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to