Issues for Puppet Module - KeegMitch/Operations-Engineering-group-c GitHub Wiki

Issues we've faced

  1. Permission errors with the sudo module (solved: see Puppet module page)

  2. On the NTP module, when testing it comes up with this error:

image

Giving me this error: Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Language validation logged 3 errors. Giving up (file: /etc/puppetlabs/code/modules/ntp_service/manifests/init.pp) on node mgmt-c.foo.org.nz

  1. When notifying the user it wrongly outputs that NTP is not running when it is running:

image

image

Potential Solutions (at least tried ones, none have worked so far)

  • Changed permissions for the sudo module

changing the place of code in the ntp.conf.erb (didn't work)

image

Changed permissions for the NTP module template (didn't work)

image

tried puppet parser validate (which checks any syntax errors) for init.pp:

image

puppet parser validate ntp.conf.erb

image

Trying the puppet-lint package to figure out if there are indentation errors on init.pp:

image

Reference: https://www.puppet.com/docs/puppet/5.5/man/parser

editing the erb file:

image

image

changing indentation to the init.pp to be consistent with the lab:

image

Solution that works!

Use This command to get error messages

sudo less /var/log/puppetlabs/puppetserver/puppetserver.log

image

  • Add namespaces to the classes in init.pp
class ntp_service {
  # Include the classes with separate names to avoid conflicts
  class { 'ntp_service::install': }
  class { 'ntp_service::config': }
  class { 'ntp_service::service': }
}

# Define the classes with separate names within the ntp_service module
class ntp_service::install {
  package { 'ntp':
    ensure => present,
  }
}

class ntp_service::config {
  if $hostname == 'mgmt-c' {
    $restrict = "restrict 10.25.0.0 mask 255.255.0.0 nomodify notrap"
    $server = "server 127.127.1.0"
    $fudge = "127.127.1.0 stratum 10"
  } else {
    $restrict = ''
    $server = "server mgmt-c.foo.org.nz prefer"
    $fudge = ''
  }

  file { '/etc/ntp.conf':
    ensure => present,
    owner => 'root',
    group => 'root',
    mode => '0444',
    content => template("ntp_service/ntp.conf.erb"),
  }
}

class ntp_service::service {
  service { 'ntp':
    ensure => running,
    enable => true,
  }
}

Outputs this:

image

Solving the NTP is not running error

So the NTP is running but the puppet code is not translating it:

Used the following commands:

  • /usr/sbin/service ntp status
  • systemctl is-active ntp

image

image

This worked:

Changed the notify class code to this:

image

Now it runs image