Ticket ID #190 ‐ Configure Time Synchronization Across Servers Using Puppet - GriffinKat/group-a GitHub Wiki
Configure Time Synchronization Across Servers Using Puppet
Create a Puppet module structure in the /etc/puppetlabs/code/modules directory like this
Using these commands
cd /etc/puppetlabs/code/modules
This moves you into the modules directory
sudo mkdir ntp_service
This creates the ntp_service directory
Here is one I prepared earlier
Change into the ntp_service directory
cd ntp_service
Then create the subdirectories 'manifests, files and templates' using these commands
sudo mkdir manifests
sudo mkdir files
sudo mkdir templates
Change into the manifests directory
cd manifests
Create the init.pp files using
sudo touch init.pp
Then edit the file using
sudo nano init.pp
In the init.pp file put this code
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-a" {
$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-a 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,
}
}
Initially I forgot to edit the line in the file from 'mgmt-x' to 'mgmt a'
I attempted to check the status of ntp but the service could not be found, I needed to restart the puppetserver using this command
sudo systemctl restart puppetserver
Then I could check the status of ntp
sudo systemctl status ntp
sudo /opt/puppetlabs/bin/puppet agent --test
After that, this command worked to check the status of ntp on the server and the clients
sudo systemctl status ntp
Then with the command
ntpq -p
We can check the synchronization
When initially attempting to check the synchronization I encountered an error, the ntpstat command was not found I needed to install it.
To do this I entered the command
sudo apt install ntpstat
I needed to restart the dbus service, on this screen I hit 'Tab' to get to 'OK' and hit enter
Then the command
ntpstat
Was able to show the puppets were synchronized with the mgmt server
This configuration is continued in Wiki page 'Ticket #195'