NTP Cookbook

Installs and configures ntp. On Windows systems it uses the Meinberg port of the standard NTPd client to Windows.

About Testing

In addition to providing interfaces to the ntp time service, this recipe is also designed to provide a simple community cookbook with broad cross-platform support to serve as a testing documentation reference. This cookbook utilizes Foodcritic, Test-Kitchen, Vagrant, Chefspec, bats, Rubocop, and Travis-CI to provide a comprehensive suite of automated test coverage.

More information on the testing strategy used in this cookbook is available in the TESTING.md file, along with information on how to use this type of testing in your own cookbooks.

Requirements

Supported Operating Systems

Debian-family Linux Distributions

RedHat-family Linux Distributions

Gentoo Linux

FreeBSD

Windows

Cookbooks

When running on Windows based systems, the node must include the Windows cookbook. This cookbook suggests the Windows cookbook in the metadata so as to not force inclusion of the Windows cookbook on *nix systems. Change 'suggests' to 'depends' if you require Windows platform support.

Attributes

Recommended tunables

ntp['servers'] - (applies to NTP Servers and Clients)

Array, should be a list of upstream NTP servers that will be considered authoritative by the local NTP daemon. The local NTP daemon will act as a client, adjusting local time to match time data retrieved from the upstream NTP servers.

The NTP protocol works best with at least 4 servers. The ntp daemon will disregard any server after the 10th listed, but will continue monitoring all listed servers. For more information, see Upstream Server Time Quantity at support.ntp.org.

Array, should be a list of restrict lines to define access to NTP clients on your LAN.

ntp['sync_clock'] (applies to NTP Servers and Clients)

Boolean. Defaults to false. Forces the ntp daemon to be halted, an ntp -q command to be issued, and the ntp daemon to be restarted again on every Chef-client run. Will have no effect if drift is over 1000 seconds.

ntp['sync_hw_clock'] (applies to NTP Servers and Clients)

Boolean. Defaults to false. On *nix-based systems, forces the 'hwclock --systohc' command to be issued on every Chef-client run. This will sync the hardware clock to the system clock.

Not available on Windows.

ntp["listen_network"] / ntp["listen"]

String, optional attribute. Default is for NTP to listen on all addresses.

ntp["listen_network"] should be set to 'primary' to listen on the node's primary IP address as determined by ohai, or set to a CIDR (eg: '192.168.4.0/24') to listen on the last node address on that CIDR.

ntp["listen"] can be set to a specific address (eg: '192.168.4.10') instead of ntp["listen_network"] to force listening on a specific address.

If both ntp["listen"] and ntp["listen_network"] are set then ntp["listen"] will always win.

The timeX.int.example.org used in these roles should be the names or IP addresses of internal NTP servers. Then simply add ntp, or ntp::default to your run_list to apply the ntp daemon's configuration.

undo recipe

If for some reason you need to stop and remove the ntp daemon, you can apply this recipe by adding ntp::undo to your run_list. The undo recipe is not supported on Windows at the moment.

windows_client recipe

Windows only. Apply on a Windows host to install the Meinberg NTPd client.

Development

This section details "quick development" steps. For a detailed explanation, see [[Contributing.md]].

Clone this repository from GitHub:

$ git clone git@github.com:opscode-cookbooks/ntp.git

Create a git branch

$ git checkout -b my_bug_fix

Install dependencies:

$ bundle install

Write tests

Make your changes/patches/fixes, committing appropriately

Run the tests:

bundle exec rake

bundle exec rake kitchen

In detail:
- Foodcritic will catch any Chef-specific style errors
- RSpec will run the unit tests
- Rubocop will check for Ruby-specific style errors
- Test Kitchen will run and converge the recipes

Copyright 2009-2013, Opscode, Inc.
Copyright 2012, Eric G. Wolfe
Copyright 2012, Fletcher Nichol
Copyright 2012, Webtrends, Inc.
Copyright 2013, Limelight Networks, Inc.
Copyright 2013, Brad Knowles
Copyright 2013, Brad Beam
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.