Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #60 from continuuity/feature/ntp-cookbook
Browse files Browse the repository at this point in the history
Import ntp version 1.6.2
  • Loading branch information
wolf31o2 committed Apr 9, 2014
2 parents 09b0a3c + 9c5868a commit 22823ad
Show file tree
Hide file tree
Showing 16 changed files with 1,200 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
ntp Cookbook CHANGELOG
======================
This file is used to list changes made in each version of the ntp cookbook.

v1.6.2 (2014-03-19)
-------------------
- [COOK-4162] - change "No NTP servers specified" message to :debug


v1.6.0 (2014-02-21)
-------------------
### Improvement
- **[COOK-4346](https://tickets.opscode.com/browse/COOK-4346)** - Solaris 11 support for ntp
- **[COOK-4339](https://tickets.opscode.com/browse/COOK-4339)** - Disable Monitoring by Default
- **[COOK-3604](https://tickets.opscode.com/browse/COOK-3604)** - Enable listening on specific interfaces

### Bug
- **[COOK-4106](https://tickets.opscode.com/browse/COOK-4106)** - Check for default content in ntp.conf
- **[COOK-4087](https://tickets.opscode.com/browse/COOK-4087)** - quote option in readme
- **[COOK-3797](https://tickets.opscode.com/browse/COOK-3797)** - Cookbook fails to upload due to 1.9.x syntax
- **[COOK-3023](https://tickets.opscode.com/browse/COOK-3023)** - NTP leapseconds file denied by Ubuntu apparmor profile


v1.5.4 (2013-12-29)
-------------------
[COOK-4007]- update to 3612902400


v1.5.2
------
### Bug
- **[COOK-3797](https://tickets.opscode.com/browse/COOK-3797)** - Add /spec to Chefignore

v1.5.0
------
### Improvement
- **[COOK-3651](https://tickets.opscode.com/browse/COOK-3651)** - Refactor and clean up
- **[COOK-3630](https://tickets.opscode.com/browse/COOK-3630)** - Switch NTP cookbook linting from Tailor to Rubocop
- **[COOK-3273](https://tickets.opscode.com/browse/COOK-3273)** - Add tests

### New Feature
- **[COOK-3636](https://tickets.opscode.com/browse/COOK-3636)** - Allow ntp cookbook to update clock to ntp servers

### Bug
- **[COOK-3410](https://tickets.opscode.com/browse/COOK-3410)** - Remove redundant ntpdate/disable recipes
- **[COOK-1170](https://tickets.opscode.com/browse/COOK-1170)** - Allow redefining NTP servers in a role


v1.4.0
------
### Improvement
- **[COOK-3365](https://tickets.opscode.com/browse/COOK-3365)** - Update ntp leapseconds file to version 3597177600
- **[COOK-1674](https://tickets.opscode.com/browse/COOK-1674)** - Add Windows support

v1.3.2
------
- [COOK-2024] - update leapfile for IERS Bulletin C

v1.3.0
------
- [COOK-1404] - add leapfile for handling leap seconds

v1.2.0
------
- [COOK-1184] - Add recipe to disable NTP completely
- [COOK-1298] - Refactor into a reference cookbook for testing

v1.1.8
------
- [COOK-1158] - RHEL family >= 6 has ntpdate package

v1.1.6
------
- Related to changes in COOK-1124, fix group for freebsd and else

v1.1.4
------
- [COOK-1124] - parameterised driftfile and statsdir to be configurable by platform

v1.1.2
------
- [COOK-952] - freebsd support
- [COOK-949] - check for any virtual system not just vmware

v1.1.0
------
- Fixes COOK-376 (use LAN peers, iburst option, LAN restriction attribute)

v1.0.1
------
- Support scientific linux
- Use service name attribute in resource (fixes EL derivatives)
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
NTP Cookbook
============
[![Build Status](https://secure.travis-ci.org/opscode-cookbooks/ntp.png?branch=master)](http://travis-ci.org/opscode-cookbooks/ntp)

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](http://acrmp.github.io/foodcritic/), [Test-Kitchen](https://github.com/opscode/test-kitchen), [Vagrant](http://www.vagrantup.com), [Chefspec](http://acrmp.github.io/chefspec/), [bats](https://github.com/sstephenson/bats), [Rubocop](https://github.com/bbatsov/rubocop), and [Travis-CI](https://travis-ci.org) 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
- 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](http://support.ntp.org/bin/view/Support/SelectingOffsiteNTPServers#Section_5.3.3.) at [support.ntp.org](http://support.ntp.org).

* `ntp['peers']` - (applies to NTP Servers ONLY)
- Array, should be a list of local NTP peers. For more information, see [Designing Your NTP Network](http://support.ntp.org/bin/view/Support/DesigningYourNTPNetwork) at [support.ntp.org](http://support.ntp.org).

* `ntp['restrictions']` - (applies to NTP Servers only)
- 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.

### Platform specific

* `ntp['packages']`
- Array, the packages to install
- Default, ntp for everything, ntpdate depending on platform. Not applicable for
Windows nodes

* `ntp['service']`
- String, the service to act on
- Default, ntp, NTP, or ntpd, depending on platform

* `ntp['varlibdir']`
- String, the path to /var/lib files such as the driftfile.
- Default, platform-specific location. Not applicable for Windows nodes

* `ntp['driftfile']`
- String, the path to the frequency file.
- Default, platform-specific location.

* `ntp['conffile']`
- String, the path to the ntp configuration file.
- Default, platform-specific location.

* `ntp['statsdir']`
- String, the directory path for files created by the statistics facility.
- Default, platform-specific location. Not applicable for Windows nodes

* `ntp['conf_owner'] and ntp['conf_group']`
- String, the owner and group of the sysconf directory files, such as /etc/ntp.conf.
- Default, platform-specific root:root or root:wheel.

* `ntp['var_owner'] and ntp['var_group']`
- String, the owner and group of the /var/lib directory files, such as /var/lib/ntp.
- Default, platform-specific ntp:ntp or root:wheel. Not applicable for Windows nodes

* `ntp['leapfile']`
- String, the path to the ntp leapfile.
- Default, /etc/ntp.leapseconds.

* `ntp['package_url']`
- String, the URL to the the Meinberg NTPd client installation package.
- Default, Meinberg site download URL
- Windows platform only

* `ntp['vs_runtime_url']`
- String, the URL to the the Visual Studio C++ 2008 runtime libraries that are required
for the Meinberg NTP client.
- Default, Microsoft site download URL
- Windows platform only

* `ntp['vs_runtime_productname']`
- String, the installation name of the Visual Studio C++ Runtimes file.
- Default, "Microsoft Visual C++ 2008 Redistributable - x86 9.0.21022"
- Windows platform only

* `ntp['sync_hw_clock']`
- Boolean, determines if the ntpdate command is issued to sync the hardware clock
- Default, false
- Not applicable for Windows nodes

* `ntp['apparmor_enabled']`
- Boolean, enables configuration of apparmor if set to true
- Defaults to false and will make no provisions for apparmor. If a
platform is apparmor enabled by default, (currently Ubuntu)
default will be true.


Usage
-----
### default recipe

Set up the ntp attributes in a role. For example in a base.rb role applied to all nodes:

```ruby
name 'base'
description 'Role applied to all systems'
default_attributes(
'ntp' => {
'servers' => ['time0.int.example.org', 'time1.int.example.org']
}
)
```

Then in an ntpserver.rb role that is applied to NTP servers (e.g., time.int.example.org):

```ruby
name 'ntp_server'
description 'Role applied to the system that should be an NTP server.'
default_attributes(
'ntp' => {
'is_server' => 'true',
'servers' => ['0.pool.ntp.org', '1.pool.ntp.org'],
'peers' => ['time0.int.example.org', 'time1.int.example.org'],
'restrictions' => ['10.0.0.0 mask 255.0.0.0 nomodify notrap']
}
)
```

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]].

1. Clone this repository from GitHub:

$ git clone [email protected]:opscode-cookbooks/ntp.git

2. Create a git branch

$ git checkout -b my_bug_fix

3. Install dependencies:

$ bundle install

4. **Write tests**
5. Make your changes/patches/fixes, committing appropriately
6. Run the tests:
- `bundle exec foodcritic -f any .`
- `bundle exec rspec`
- `bundle exec rubocop`
- `bundle exec kitchen test`

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


License & Authors
-----------------
- Author:: Joshua Timberman (<[email protected]>)
- Contributor:: Eric G. Wolfe (<[email protected]>)
- Contributor:: Fletcher Nichol (<[email protected]>)
- Contributor:: Tim Smith (<[email protected]>)
- Contributor:: Charles Johnson (<[email protected]>)
- Contributor:: Brad Knowles (<[email protected]>)

```text
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.
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#
# Cookbook Name:: ntp
# Attributes:: default
#
# Author:: Joshua Timberman (<[email protected]>)
# Author:: Tim Smith (<[email protected]>)
# Author:: Charles Johnson (<[email protected]>)
#
# Copyright 2009-2013, Opscode, Inc.
#
# 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.
#

# default attributes for all platforms
default['ntp']['servers'] = [] # The default recipe sets a list of common NTP servers (COOK-1170)
default['ntp']['peers'] = []
default['ntp']['restrictions'] = []

# internal attributes
default['ntp']['packages'] = %w(ntp ntpdate)
default['ntp']['service'] = 'ntpd'
default['ntp']['varlibdir'] = '/var/lib/ntp'
default['ntp']['driftfile'] = "#{node['ntp']['varlibdir']}/ntp.drift"
default['ntp']['conffile'] = '/etc/ntp.conf'
default['ntp']['statsdir'] = '/var/log/ntpstats/'
default['ntp']['conf_owner'] = 'root'
default['ntp']['conf_group'] = 'root'
default['ntp']['var_owner'] = 'ntp'
default['ntp']['var_group'] = 'ntp'
default['ntp']['leapfile'] = '/etc/ntp.leapseconds'
default['ntp']['sync_clock'] = false
default['ntp']['sync_hw_clock'] = false
default['ntp']['listen'] = nil
default['ntp']['listen_network'] = nil
default['ntp']['apparmor_enabled'] = false
default['ntp']['monitor'] = false

# overrides on a platform-by-platform basis
case node['platform_family']
when 'debian'
default['ntp']['service'] = 'ntp'
default['ntp']['apparmor_enabled'] = true if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 8.04
when 'rhel'
default['ntp']['packages'] = %w(ntp) if node['platform_version'].to_i < 6
when 'windows'
default['ntp']['service'] = 'NTP'
default['ntp']['driftfile'] = 'C:\\NTP\\ntp.drift'
default['ntp']['conffile'] = 'C:\\NTP\\etc\\ntp.conf'
default['ntp']['conf_owner'] = 'Administrators'
default['ntp']['conf_group'] = 'Administrators'
default['ntp']['package_url'] = 'http://www.meinbergglobal.com/download/ntp/windows/[email protected]'
default['ntp']['vs_runtime_url'] = 'http://download.microsoft.com/download/1/1/1/1116b75a-9ec3-481a-a3c8-1777b5381140/vcredist_x86.exe'
default['ntp']['vs_runtime_productname'] = 'Microsoft Visual C++ 2008 Redistributable - x86 9.0.21022'
when 'freebsd'
default['ntp']['packages'] = %w(ntp)
default['ntp']['varlibdir'] = '/var/db'
default['ntp']['driftfile'] = "#{node['ntp']['varlibdir']}/ntpd.drift"
default['ntp']['statsdir'] = "#{node['ntp']['varlibdir']}/ntpstats"
default['ntp']['conf_group'] = 'wheel'
default['ntp']['var_group'] = 'wheel'
when 'solaris2'
default['ntp']['packages'] = %w(ntp)
default['ntp']['service'] = 'ntp'
default['ntp']['varlibdir'] = '/var/ntp'
default['ntp']['conffile'] = '/etc/inet/ntp.conf'
default['ntp']['statsdir'] = "#{node['ntp']['varlibdir']}/ntpstats/"
default['ntp']['conf_owner'] = 'root'
default['ntp']['conf_group'] = 'root'
default['ntp']['var_owner'] = 'root'
default['ntp']['var_group'] = 'sys'
default['ntp']['leapfile'] = '/etc/inet/ntp.leap'
end
Loading

0 comments on commit 22823ad

Please sign in to comment.