You’ve just finished installing the puppetlabs-ntp module.
-
The next step is adding classes from the NTP module to the main manifest.
-
The NTP module contains several classes. Classes are named chunks of Puppet code and are the primary means by which Puppet configures nodes. The NTP module contains the following classes:
-
ntp: the main class, which includes all other NTP classes, including the classes in this list.
-
ntp::install: handles the installation packages.
-
ntp::config: handles the configuration file.
-
ntp::service: handles the service.
-
You’re going to add the ntp class to the default node in your main manifest. Depending on your needs or infrastructure, you might have a different group that you’ll assign NTP to, but you would take similar steps.
-
From the command line on the master, navigate to the directory that contains the main manifest:
cd /etc/puppetlabs/code/environments/production/manifests
node default {
class { 'ntp':
servers => ['nist-time-server.eoni.com','nist1-lv.ustiming.org','ntp-nist.ldsbc.edu']
}
}
puppet agent -t
puppet resource service ntpd
service { 'ntpd':
ensure => 'running',
enable => 'true',
}
-
If you want to configure the NTP service to run differently on different nodes, you can set up NTP on nodes other than default in the site.pp file.
-
In previous steps, you’ve been configuring the default node.
-
In the example below, two NTP servers (kermit and grover) are configured to talk to outside time servers. The other NTP servers (snuffie, bigbird, and hooper) use those two primary servers to sync their time.
-
One of the primary ntp servers, kermit, is very cautiously configured — it can’t afford outages, so it’s not allowed to automatically update its NTP server package without testing. The other servers are more permissively configured.
-
The site.pp looks like this:
node "kermit.example.com" {
class { "ntp":
servers => [ '0.us.pool.ntp.org iburst','1.us.pool.ntp.org iburst','2.us.pool.ntp.org iburst','3.us.pool.ntp.org iburst'],
autoupdate => false,
restrict => [],
enable => true,
}
}
node "grover.example.com" {
class { "ntp":
servers => [ 'kermit.example.com','0.us.pool.ntp.org iburst','1.us.pool.ntp.org iburst','2.us.pool.ntp.org iburst'],
autoupdate => true,
restrict => [],
enable => true,
}
}
node "snuffie.example.com", "bigbird.example.com", "hooper.example.com" {
class { "ntp":
servers => [ 'grover.example.com', 'kermit.example.com'],
autoupdate => true,
enable => true,
}
}
In this way, it is possible to configure NTP on multiple nodes to suit your needs.