#192: Configure Time Synchronization Across Servers Using Puppet - Rmhibbert/oe2-group-c GitHub Wiki
link to ticket: https://rt.dataraster.com/Ticket/Display.html?id=192
Step by step
Module setup
Description: change directory to /etc/puppetlabs/code/modules
Command: cd /etc/puppetlabs/code/modules
Description: create the modules directory
Command: sudo mkdir -p ntp_service/files ntp_service/templates ntp_service/manifests
Description: Create an init.pp in the manifests subdirectory
Command: cd ntp_service/manifests then sudo touch init.pp
NTP Module Manifest
Description: Edit innit.pp file
Command: sudo nano init.pp
Description: Enter the following code
Command:
class ntp_service { include ntp_service::install, ntp_service::config, ntp_service::service }
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 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, } }
Templates
Description: Create a ntp.conf.erb file in templates
Command: cd templates then sudo touch ntp.conf.erb
Description: Edit the content of the file
Command: sudo nano ntp.conf.erb and enter the following code from this file https://github.com/OlayinkaOP/OE2/blob/main/ntp.conf.erb
Applying the Module
Description: Apply the module to each line in node definitions
Command: sudo nano /etc/puppetlabs/code/environments/production/manifests/site.pp then include ntp_service
Description: Run the puppet agent on each machine
Command: sudo puppet agent --server=mgmt-c --no-daemonize --verbose --onetime
Testing the NTP Configuration
Description: Check if ntp service is running on servers
Command: sudo systemctl status ntp
Description: check synchronization of severs
Command:
ntpq -p
ntpstat