On Tuesday, April 17, 2012 1:34:02 AM UTC-4, Wil Cooley wrote:
>
> 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'.
>
>
After spending over an hour trying to figure out my mistake, of course I
notice the errant "d" after I post to the group. Thanks for confirming!
> > 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,
> ...
> }
>
>
Thank you, I"ll use that idea in my next manifest.
>
> 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
I'll read up on this as well. I've created another manifest based on the
lesson plan, this time for an Apache install that is OS sensitive, with a
custom 404 and a generic landing page. I think this part is wrong:
file { '$webservice_name.conf':
path => "/etc/${webservice_name}/conf/${webservice_name}.conf",
Since in Debian/Ubuntu it would be
file { '$webservice_name.conf':
path => "/etc/${webservice_name}/${webservice_name}.conf",
but I'm not sure how to parse that out. Here's it in entirety (Debian side
commented out as per the Puppetlabs instructions to test only for EL/CentOS
or fail):
#init.pp
class httpd {
case $operatingsystem {
centos, redhat: {
$webservice_name = 'httpd'
$conf_file = '/etc/httpd/conf/httpd.conf'
$docu_root = '/var/www/html'
$404page = '404page.redhat.centos.html'
}
# debian, ubuntu {
# $webservice_name = 'apache2'
# $conf_file = '/etc/apache2/apache2.conf'
# $docu_root = /var/www/'
# $404page = '404page.debian.ubuntu.html'
#}
default: { fail("Uncrecognized operatingsystem for webserver")}
}
package { '$webservice_name'
ensure => installed,
}
file { '$webservice_name.conf':
path => "/etc/${webservice_name}/conf/${webservice_name}.conf",
source => "puppet:///modules/apache2/${conf_file}",
ensure => file,
require => Package['$service_name'],
}
service { 'ntp':
name => $service_name,
ensure => running,
enable => true,
subscribe => File['${webservice_name.conf}'],
}
file { '404page.html':
path => '$docu_root/404page.html
source => "puppet:///modules/apache2/${404page}",
ensure => file,
require => Package["$webservice_name"],
}
}
I figured I could start another topic, but I didn't want to clutter the
board.
Cheers!
Jesse
On Tuesday, April 17, 2012 1:34:02 AM UTC-4, Wil Cooley wrote:
>
> 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
On Tuesday, April 17, 2012 1:34:02 AM UTC-4, Wil Cooley wrote:
>
> 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
On Tuesday, April 17, 2012 1:34:02 AM UTC-4, Wil Cooley wrote:
>
> 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
On Tuesday, April 17, 2012 1:34:02 AM UTC-4, Wil Cooley wrote:
>
> 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
On Tuesday, April 17, 2012 1:34:02 AM UTC-4, Wil Cooley wrote:
>
> 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
On Tuesday, April 17, 2012 1:34:02 AM UTC-4, Wil Cooley wrote:
>
> 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
On Tuesday, April 17, 2012 1:34:02 AM UTC-4, Wil Cooley wrote:
>
> 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 view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/LoiCirfBCgkJ.
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.