Issues for Puppet Module - KeegMitch/Operations-Engineering-group-c GitHub Wiki
Issues we've faced
-
Permission errors with the sudo module (solved: see Puppet module page)
-
On the NTP module, when testing it comes up with this error:
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
- When notifying the user it wrongly outputs that NTP is not running when it is running:
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)
Changed permissions for the NTP module template (didn't work)
tried puppet parser validate (which checks any syntax errors) for init.pp:
puppet parser validate ntp.conf.erb
Trying the puppet-lint package to figure out if there are indentation errors on init.pp:
Reference: https://www.puppet.com/docs/puppet/5.5/man/parser
editing the erb file:
changing indentation to the init.pp to be consistent with the lab:
Solution that works!
Use This command to get error messages
sudo less /var/log/puppetlabs/puppetserver/puppetserver.log
- 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:
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
This worked:
Changed the notify class code to this:
Now it runs