Added modules

This commit is contained in:
Ciaby 2014-07-11 13:30:23 -05:00
parent c53c931217
commit 59ec520742
646 changed files with 35182 additions and 0 deletions

177
modules/ntp/CHANGELOG.md Normal file
View file

@ -0,0 +1,177 @@
##2014-06-06 - Release 3.1.1
###Summary
This is a bugfix release to get around dependency issues in PMT 3.6. This
version has a dependency on puppetlabs-stdlib >= 4 so PE3.2.x is no longer
supported.
####Bugfixes
- Remove deprecated Modulefile as it was causing duplicate dependencies with PMT.
##2014-05-14 - Release 3.1.0
###Summary
This release adds `disable_monitor` so you can disable the monitor functionality
of NTP, which was recently used in NTP amplification attacks. It also adds
support for RHEL7 and Ubuntu 14.04.
####Features
- Add `disable_monitor`
####Bugfixes
#####Known Bugs
* No known bugs
##2014-04-09 - Supported Release 3.0.4
###Summary
This is a supported release.
The only functional change in this release is to split up the restrict
defaults to be per operating system so that we can provide safer defaults
for AIX, to resolve cases where IPv6 are disabled.
####Features
- Rework restrict defaults.
####Bugfixes
- Fix up a comment.
- Fix a test to work better on PE.
#####Known Bugs
* No known bugs
##2014-03-04 - Supported Release 3.0.3
###Summary
This is a supported release. Correct stdlib compatibility
####Bugfixes
- Remove `dirname()` call for correct stdlib compatibility.
- Improved tests
####Known Bugs
* No known bugs
## 2014-02-13 - Release 3.0.2
###Summary
No functional changes: Update the README and allow custom gem sources.
## 2013-12-17 - Release 3.0.1
### Summary
Work around a packaging bug with symlinks, no other functional changes.
## 2013-12-13 - Release 3.0.0
### Summary
Final release of 3.0, enjoy!
## 2013-10-14 - Version 3.0.0-rc1
###Summary
This release changes the behavior of restrict and adds AIX osfamily support.
####Backwards-incompatible Changes:
`restrict` no longer requires you to pass in parameters as:
restrict => [ 'restrict x', 'restrict y' ]
but just as:
restrict => [ 'x', 'y' ]
As the template now prefixes each line with restrict.
####Features
- Change the behavior of `restrict` so you no longer need the restrict
keyword.
- Add `udlc` parameter to enable undisciplined local clock regardless of the
machines status as a virtual machine.
- Add AIX support.
####Fixes
- Use class{} instead of including and then anchoring. (style)
- Extend Gentoo coverage to Facter 1.7.
---
##2013-09-05 - Version 2.0.1
###Summary
Correct the LICENSE file.
####Bugfixes
- Add in the appropriate year and name in LICENSE.
##2013-07-31 - Version 2.0.0
###Summary
The 2.0 release focuses on merging all the distro specific
templates into a single reusable template across all platforms.
To aid in that goal we now allow you to change the driftfile,
ntp keys, and perferred_servers.
####Backwards-incompatible changes
As all the distro specific templates have been removed and a
unified one created you may be missing functionality you
previously relied on. Please test carefully before rolling
out globally.
Configuration directives that might possibly be affected:
- `filegen`
- `fudge` (for virtual machines)
- `keys`
- `logfile`
- `restrict`
- `restrictkey`
- `statistics`
- `trustedkey`
####Features:
- All templates merged into a single template.
- NTP Keys support added.
- Add preferred servers support.
- Parameters in `ntp` class:
- `driftfile`: path for the ntp driftfile.
- `keys_enable`: Enable NTP keys feature.
- `keys_file`: Path for the NTP keys file.
- `keys_trusted`: Which keys to trust.
- `keys_controlkey`: Which key to use for the control key.
- `keys_requestkey`: Which key to use for the request key.
- `preferred_servers`: Array of servers to prefer.
- `restrict`: Array of restriction options to apply.
---
###2013-07-15 - Version 1.0.1
####Bugfixes
- Fix deprecated warning in `autoupdate` parameter.
- Correctly quote is_virtual fact.
##2013-07-08 - Version 1.0.0
####Features
- Completely refactored to split across several classes.
- rspec-puppet tests rewritten to cover more options.
- rspec-system tests added.
- ArchLinux handled via osfamily instead of special casing.
- parameters in `ntp` class:
- `autoupdate`: deprecated in favor of directly setting package_ensure.
- `panic`: set to false if you wish to allow large clock skews.
---
##2011-11-10 Dan Bode <dan@puppetlabs.com> - 0.0.4
* Add Amazon Linux as a supported platform
* Add unit tests
##2011-06-16 Jeff McCune <jeff@puppetlabs.com> - 0.0.3
* Initial release under puppetlabs

View file

@ -0,0 +1,9 @@
Puppet Labs modules on the Puppet Forge are open projects, and community contributions
are essential for keeping them great. We cant access the huge number of platforms and
myriad of hardware, software, and deployment configurations that Puppet is intended to serve.
We want to keep it as easy as possible to contribute changes so that our modules work
in your environment. There are a few guidelines that we need contributors to follow so
that we can have a chance of keeping on top of things.
You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing)

19
modules/ntp/Gemfile Normal file
View file

@ -0,0 +1,19 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"
group :development, :test do
gem 'rake', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', :require => false
gem 'serverspec', :require => false
gem 'beaker', :require => false
gem 'beaker-rspec', :require => false
gem 'specinfra', '>=0.7.0'
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
# vim:ft=ruby

144
modules/ntp/Gemfile.lock Normal file
View file

@ -0,0 +1,144 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.2.7)
addressable (2.3.6)
autoparse (0.3.3)
addressable (>= 2.3.1)
extlib (>= 0.9.15)
multi_json (>= 1.0.0)
aws-sdk (1.39.0)
json (~> 1.4)
nokogiri (>= 1.4.4)
beaker (1.10.0)
aws-sdk (~> 1.38)
blimpy (~> 0.6)
fission (~> 0.4)
google-api-client (~> 0.6.4)
inifile (~> 2.0)
json (~> 1.8)
mime-types (~> 1.25)
net-scp (~> 1.1)
net-ssh (~> 2.6)
nokogiri (= 1.5.10)
rbvmomi (= 1.8.1)
unf (~> 0.1)
beaker-rspec (2.2.3)
beaker (~> 1.10.0)
rspec (~> 2.14)
serverspec (~> 1.0.0)
specinfra (~> 1.0.0)
blimpy (0.6.7)
fog
minitar
thor
builder (3.2.2)
diff-lcs (1.2.5)
excon (0.31.0)
extlib (0.9.16)
facter (2.0.1)
CFPropertyList (~> 2.2.6)
faraday (0.8.9)
multipart-post (~> 1.2.0)
fission (0.5.0)
CFPropertyList (~> 2.2)
fog (1.19.0)
builder
excon (~> 0.31.0)
formatador (~> 0.2.0)
mime-types
multi_json (~> 1.0)
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
nokogiri (~> 1.5)
ruby-hmac
formatador (0.2.4)
google-api-client (0.6.4)
addressable (>= 2.3.2)
autoparse (>= 0.3.3)
extlib (>= 0.9.15)
faraday (~> 0.8.4)
jwt (>= 0.1.5)
launchy (>= 2.1.1)
multi_json (>= 1.0.0)
signet (~> 0.4.5)
uuidtools (>= 2.1.0)
hiera (1.3.2)
json_pure
highline (1.6.21)
inifile (2.0.2)
json (1.8.1)
json_pure (1.8.1)
jwt (0.1.11)
multi_json (>= 1.5)
launchy (2.4.2)
addressable (~> 2.3)
metaclass (0.0.4)
mime-types (1.25.1)
minitar (0.5.4)
mocha (1.0.0)
metaclass (~> 0.0.1)
multi_json (1.9.3)
multipart-post (1.2.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.0)
nokogiri (1.5.10)
puppet (3.5.1)
facter (> 1.6, < 3)
hiera (~> 1.0)
json_pure
rgen (~> 0.6.5)
puppet-lint (0.3.2)
puppetlabs_spec_helper (0.4.1)
mocha (>= 0.10.5)
rake
rspec (>= 2.9.0)
rspec-puppet (>= 0.1.1)
rake (10.3.1)
rbvmomi (1.8.1)
builder
nokogiri (>= 1.4.1)
trollop
rgen (0.6.6)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-puppet (1.0.1)
rspec
ruby-hmac (0.4.0)
serverspec (1.0.0)
highline
net-ssh
rspec (~> 2.13)
specinfra (>= 1.0.0)
signet (0.4.5)
addressable (>= 2.2.3)
faraday (~> 0.8.1)
jwt (>= 0.1.5)
multi_json (>= 1.0.0)
specinfra (1.0.5)
thor (0.19.1)
trollop (2.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.6)
uuidtools (2.1.4)
PLATFORMS
ruby
DEPENDENCIES
beaker
beaker-rspec
puppet
puppet-lint
puppetlabs_spec_helper
rake
serverspec
specinfra (>= 0.7.0)

202
modules/ntp/LICENSE Normal file
View file

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [2013] [Puppet Labs]
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.

231
modules/ntp/README.markdown Normal file
View file

@ -0,0 +1,231 @@
#ntp
####Table of Contents
1. [Overview](#overview)
2. [Module Description - What the module does and why it is useful](#module-description)
3. [Setup - The basics of getting started with ntp](#setup)
* [What ntp affects](#what-ntp-affects)
* [Setup requirements](#setup-requirements)
* [Beginning with ntp](#beginning-with-ntp)
4. [Usage - Configuration options and additional functionality](#usage)
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
5. [Limitations - OS compatibility, etc.](#limitations)
6. [Development - Guide for contributing to the module](#development)
##Overview
The ntp module installs, configures, and manages the NTP service.
##Module Description
The ntp module handles installing, configuring, and running NTP across a range of operating systems and distributions.
##Setup
###What ntp affects
* ntp package.
* ntp configuration file.
* ntp service.
###Beginning with ntp
`include '::ntp'` is enough to get you up and running. If you wish to pass in
parameters specifying which servers to use, then:
```puppet
class { '::ntp':
servers => [ 'ntp1.corp.com', 'ntp2.corp.com' ],
}
```
##Usage
All interaction with the ntp module can do be done through the main ntp class.
This means you can simply toggle the options in `::ntp` to have full functionality of the module.
###I just want NTP, what's the minimum I need?
```puppet
include '::ntp'
```
###I just want to tweak the servers, nothing else.
```puppet
class { '::ntp':
servers => [ 'ntp1.corp.com', 'ntp2.corp.com' ],
}
```
###I'd like to make sure I restrict who can connect as well.
```puppet
class { '::ntp':
servers => [ 'ntp1.corp.com', 'ntp2.corp.com' ],
restrict => ['127.0.0.1'],
}
```
###I'd like to opt out of having the service controlled; we use another tool for that.
```puppet
class { '::ntp':
servers => [ 'ntp1.corp.com', 'ntp2.corp.com' ],
restrict => ['127.0.0.1'],
service_manage => false,
}
```
###Looks great! But I'd like a different template; we need to do something unique here.
```puppet
class { '::ntp':
servers => [ 'ntp1.corp.com', 'ntp2.corp.com' ],
restrict => ['127.0.0.1'],
service_manage => false,
config_template => 'different/module/custom.template.erb',
}
```
##Reference
###Classes
####Public Classes
* ntp: Main class, includes all other classes.
####Private Classes
* ntp::install: Handles the packages.
* ntp::config: Handles the configuration file.
* ntp::service: Handles the service.
###Parameters
The following parameters are available in the ntp module:
####`autoupdate`
**Deprecated:** This parameter determined whether the ntp module should be
automatically updated to the latest version available. Replaced by `package_ensure`.
####`config`
Sets the file that ntp configuration is written into.
####`config_template`
Determines which template Puppet should use for the ntp configuration.
####`disable_monitor`
Disables monitoring of ntp.
####`driftfile`
Sets the location of the drift file for ntp.
####`keys_controlkey`
The key to use as the control key.
####`keys_enable`
Whether the ntp keys functionality is enabled.
####`keys_file`
Location of the keys file.
####`keys_requestkey`
Which of the keys is the request key.
#### `keys_trusted`
Array of trusted keys.
####`package_ensure`
Sets the ntp package to be installed. Can be set to 'present', 'latest', or a specific version.
####`package_name`
Determines the name of the package to install.
####`panic`
Determines if ntp should 'panic' in the event of a very large clock skew.
This defaults to false for virtual machines, as they don't do a great job with keeping time.
####`preferred_servers`
List of ntp servers to prefer. Will append 'prefer' for any server in this list
that also appears in the servers list.
####`restrict`
Sets the restrict options in the ntp configuration. The lines are
prefixed with 'restrict', so you just need to list the rest of the restriction.
####`servers`
Selects the servers to use for ntp peers.
####`service_enable`
Determines if the service should be enabled at boot.
####`service_ensure`
Determines if the service should be running or not.
####`service_manage`
Selects whether Puppet should manage the service.
####`service_name`
Selects the name of the ntp service for Puppet to manage.
####`udlc`
Enables configs for undisciplined local clock, regardless of
status as a virtual machine.
##Limitations
This module has been built on and tested against Puppet 2.7 and higher.
The module has been tested on:
* RedHat Enterprise Linux 5/6
* Debian 6/7
* CentOS 5/6
* Ubuntu 12.04
* Gentoo
* Arch Linux
* FreeBSD
Testing on other platforms has been light and cannot be guaranteed.
##Development
Puppet Labs modules on the Puppet Forge are open projects, and community
contributions are essential for keeping them great. We cant access the
huge number of platforms and myriad of hardware, software, and deployment
configurations that Puppet is intended to serve.
We want to keep it as easy as possible to contribute changes so that our
modules work in your environment. There are a few guidelines that we need
contributors to follow so that we can have a chance of keeping on top of things.
You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing)
###Contributors
The list of contributors can be found at: [https://github.com/puppetlabs/puppetlabs-ntp/graphs/contributors](https://github.com/puppetlabs/puppetlabs-ntp/graphs/contributors)

1
modules/ntp/Rakefile Normal file
View file

@ -0,0 +1 @@
require 'puppetlabs_spec_helper/rake_tasks'

View file

@ -0,0 +1,41 @@
{
"CHANGELOG.md": "43274ffb7445185b6efe8e6d4d181068",
"CONTRIBUTING.md": "2ef1d6f4417dde9af6c7f46f5c8a864b",
"Gemfile": "bbc819d69940a071a13963659787748a",
"Gemfile.lock": "86b33786b77d2497e910ed2b10cdfd58",
"LICENSE": "f0b6fdc310531526f257378d7bad0044",
"README.markdown": "29d76544eaf8c6669c5a3c1ea9137b89",
"Rakefile": "0254db5d3fc38c67a2c160d7296a24f8",
"manifests/config.pp": "8d9afb6e4327277c96c5617ad687043a",
"manifests/init.pp": "81c730134da0066aecb0e0048c7e15ba",
"manifests/install.pp": "ac33c5733f4321a9af7a4735265c1986",
"manifests/params.pp": "8570440dcda436999ce22514c2bd9dd7",
"manifests/service.pp": "350238b50e9cb896d270a2c76a64334f",
"metadata.json": "dc2dd0958bd17d382d0bed52693c06e9",
"spec/acceptance/class_spec.rb": "5c23f02ba486f3efd0cab3933ae35027",
"spec/acceptance/disable_monitoring_spec.rb": "059972f633098dbc5d20739c28733847",
"spec/acceptance/nodesets/centos-64-x64-pe.yml": "ec075d95760df3d4702abea1ce0a829b",
"spec/acceptance/nodesets/centos-64-x64.yml": "092dd2c588a9f87fa1fb12997c0723ef",
"spec/acceptance/nodesets/centos-65-x64.yml": "3e5c36e6aa5a690229e720f4048bb8af",
"spec/acceptance/nodesets/default.yml": "092dd2c588a9f87fa1fb12997c0723ef",
"spec/acceptance/nodesets/fedora-18-x64.yml": "80e41b1ee16ea489f53164bfdae58855",
"spec/acceptance/nodesets/sles-11-x64.yml": "44e4c6c15c018333bfa9840a5e702f66",
"spec/acceptance/nodesets/ubuntu-server-10044-x64.yml": "75e86400b7889888dc0781c0ae1a1297",
"spec/acceptance/nodesets/ubuntu-server-12042-x64.yml": "d30d73e34cd50b043c7d14e305955269",
"spec/acceptance/ntp_config_spec.rb": "3f8cac3f5ed32aab916567125f758bea",
"spec/acceptance/ntp_install_spec.rb": "dd2d6705eb13303fdcf84044bc36fd7c",
"spec/acceptance/ntp_parameters_spec.rb": "ed410a9251fb4eb28fd60c5b86b0d4d3",
"spec/acceptance/ntp_service_spec.rb": "8dc705e7e0cdc97d6f7f0c2735a74ffa",
"spec/acceptance/preferred_servers_spec.rb": "598861b69ac517785f85ad86a00b7e51",
"spec/acceptance/restrict_spec.rb": "e987b3c98857a9389ef9627aa72d23e7",
"spec/acceptance/unsupported_spec.rb": "46473b42539794169b7d5c6a0b10f089",
"spec/classes/ntp_spec.rb": "b93bd5752fa06a5074ee5b5df6a82a7c",
"spec/fixtures/modules/my_ntp/templates/ntp.conf.erb": "566e373728e9b13eda516115ff0a9fb0",
"spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c",
"spec/spec_helper.rb": "0db89c9a486df193c0e40095422e19dc",
"spec/spec_helper_acceptance.rb": "fa2d2f453059310a815d3fb46112af1c",
"spec/unit/puppet/provider/README.markdown": "e52668944ee6af2fb5d5b9e798342645",
"spec/unit/puppet/type/README.markdown": "de26a7643813abd6c2e7e28071b1ef94",
"templates/ntp.conf.erb": "8ca9b49cee58ebd2676e7864a7348628",
"tests/init.pp": "d398e7687ec1d893ef23d1b7d2afc094"
}

View file

@ -0,0 +1,23 @@
#
class ntp::config inherits ntp {
if $keys_enable {
$directory = dirname($keys_file)
file { $directory:
ensure => directory,
owner => 0,
group => 0,
mode => '0755',
recurse => true,
}
}
file { $config:
ensure => file,
owner => 0,
group => 0,
mode => '0644',
content => template($config_template),
}
}

View file

@ -0,0 +1,60 @@
class ntp (
$autoupdate = $ntp::params::autoupdate,
$config = $ntp::params::config,
$config_template = $ntp::params::config_template,
$disable_monitor = $ntp::params::disable_monitor,
$driftfile = $ntp::params::driftfile,
$logfile = $ntp::params::logfile,
$keys_enable = $ntp::params::keys_enable,
$keys_file = $ntp::params::keys_file,
$keys_controlkey = $ntp::params::keys_controlkey,
$keys_requestkey = $ntp::params::keys_requestkey,
$keys_trusted = $ntp::params::keys_trusted,
$package_ensure = $ntp::params::package_ensure,
$package_name = $ntp::params::package_name,
$panic = $ntp::params::panic,
$preferred_servers = $ntp::params::preferred_servers,
$restrict = $ntp::params::restrict,
$servers = $ntp::params::servers,
$service_enable = $ntp::params::service_enable,
$service_ensure = $ntp::params::service_ensure,
$service_manage = $ntp::params::service_manage,
$service_name = $ntp::params::service_name,
$udlc = $ntp::params::udlc
) inherits ntp::params {
validate_absolute_path($config)
validate_string($config_template)
validate_bool($disable_monitor)
validate_absolute_path($driftfile)
if $logfile { validate_absolute_path($logfile) }
validate_bool($keys_enable)
validate_re($keys_controlkey, ['^\d+$', ''])
validate_re($keys_requestkey, ['^\d+$', ''])
validate_array($keys_trusted)
validate_string($package_ensure)
validate_array($package_name)
validate_bool($panic)
validate_array($preferred_servers)
validate_array($restrict)
validate_array($servers)
validate_bool($service_enable)
validate_string($service_ensure)
validate_bool($service_manage)
validate_string($service_name)
validate_bool($udlc)
if $autoupdate {
notice('autoupdate parameter has been deprecated and replaced with package_ensure. Set this to latest for the same behavior as autoupdate => true.')
}
# Anchor this as per #8040 - this ensures that classes won't float off and
# mess everything up. You can read about this at:
# http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html#known-issues
anchor { 'ntp::begin': } ->
class { '::ntp::install': } ->
class { '::ntp::config': } ~>
class { '::ntp::service': } ->
anchor { 'ntp::end': }
}

View file

@ -0,0 +1,9 @@
#
class ntp::install inherits ntp {
package { 'ntp':
ensure => $package_ensure,
name => $package_name,
}
}

View file

@ -0,0 +1,182 @@
class ntp::params {
$autoupdate = false
$config_template = 'ntp/ntp.conf.erb'
$disable_monitor = false
$keys_enable = false
$keys_controlkey = ''
$keys_requestkey = ''
$keys_trusted = []
$package_ensure = 'present'
$preferred_servers = []
$service_enable = true
$service_ensure = 'running'
$service_manage = true
$udlc = false
# On virtual machines allow large clock skews.
$panic = str2bool($::is_virtual) ? {
true => false,
default => true,
}
$default_config = '/etc/ntp.conf'
$default_keys_file = '/etc/ntp/keys'
$default_driftfile = '/var/lib/ntp/drift'
$default_package_name = ['ntp']
$default_service_name = 'ntpd'
case $::osfamily {
'AIX': {
$keys_file = '/etc/ntp.keys'
$driftfile = '/etc/ntp.drift'
$package_name = [ 'bos.net.tcp.client' ]
$restrict = [
'default nomodify notrap nopeer noquery',
'127.0.0.1',
]
$service_name = 'xntpd'
$servers = [
'0.debian.pool.ntp.org iburst',
'1.debian.pool.ntp.org iburst',
'2.debian.pool.ntp.org iburst',
'3.debian.pool.ntp.org iburst',
]
}
'Debian': {
$restrict = [
'default kod nomodify notrap nopeer noquery',
'-6 default kod nomodify notrap nopeer noquery',
'127.0.0.1',
'-6 ::1',
]
$service_name = 'ntp'
$servers = [
'0.debian.pool.ntp.org iburst',
'1.debian.pool.ntp.org iburst',
'2.debian.pool.ntp.org iburst',
'3.debian.pool.ntp.org iburst',
]
}
'RedHat': {
$restrict = [
'default kod nomodify notrap nopeer noquery',
'-6 default kod nomodify notrap nopeer noquery',
'127.0.0.1',
'-6 ::1',
]
$servers = [
'0.centos.pool.ntp.org',
'1.centos.pool.ntp.org',
'2.centos.pool.ntp.org',
]
}
'SuSE': {
$driftfile = '/var/lib/ntp/drift/ntp.drift'
$restrict = [
'default kod nomodify notrap nopeer noquery',
'-6 default kod nomodify notrap nopeer noquery',
'127.0.0.1',
'-6 ::1',
]
$service_name = 'ntp'
$servers = [
'0.opensuse.pool.ntp.org',
'1.opensuse.pool.ntp.org',
'2.opensuse.pool.ntp.org',
'3.opensuse.pool.ntp.org',
]
}
'FreeBSD': {
$driftfile = '/var/db/ntpd.drift'
$package_name = ['net/ntp']
$restrict = [
'default kod nomodify notrap nopeer noquery',
'-6 default kod nomodify notrap nopeer noquery',
'127.0.0.1',
'-6 ::1',
]
$servers = [
'0.freebsd.pool.ntp.org iburst maxpoll 9',
'1.freebsd.pool.ntp.org iburst maxpoll 9',
'2.freebsd.pool.ntp.org iburst maxpoll 9',
'3.freebsd.pool.ntp.org iburst maxpoll 9',
]
}
'Archlinux': {
$restrict = [
'default kod nomodify notrap nopeer noquery',
'-6 default kod nomodify notrap nopeer noquery',
'127.0.0.1',
'-6 ::1',
]
$servers = [
'0.pool.ntp.org',
'1.pool.ntp.org',
'2.pool.ntp.org',
]
}
# Gentoo was added as its own $::osfamily in Facter 1.7.0
'Gentoo': {
$package_name = ['net-misc/ntp']
$restrict = [
'default kod nomodify notrap nopeer noquery',
'-6 default kod nomodify notrap nopeer noquery',
'127.0.0.1',
'-6 ::1',
]
$servers = [
'0.gentoo.pool.ntp.org',
'1.gentoo.pool.ntp.org',
'2.gentoo.pool.ntp.org',
'3.gentoo.pool.ntp.org',
]
}
'Linux': {
# Account for distributions that don't have $::osfamily specific settings.
# Before Facter 1.7.0 Gentoo did not have its own $::osfamily
case $::operatingsystem {
'Gentoo': {
$package_name = ['net-misc/ntp']
$restrict = [
'default kod nomodify notrap nopeer noquery',
'-6 default kod nomodify notrap nopeer noquery',
'127.0.0.1',
'-6 ::1',
]
$servers = [
'0.gentoo.pool.ntp.org',
'1.gentoo.pool.ntp.org',
'2.gentoo.pool.ntp.org',
'3.gentoo.pool.ntp.org',
]
}
default: {
fail("The ${module_name} module is not supported on an ${::operatingsystem} distribution.")
}
}
}
default: {
fail("The ${module_name} module is not supported on an ${::osfamily} based system.")
}
}
if $config == undef {
$config = $default_config
}
if $keys_file == undef {
$keys_file = $default_keys_file
}
if $drfitfile == undef {
$driftfile = $default_driftfile
}
if $package_name == undef {
$package_name = $default_package_name
}
if $service_name == undef {
$service_name = $default_service_name
}
}

View file

@ -0,0 +1,18 @@
#
class ntp::service inherits ntp {
if ! ($service_ensure in [ 'running', 'stopped' ]) {
fail('service_ensure parameter must be running or stopped')
}
if $service_manage == true {
service { 'ntp':
ensure => $service_ensure,
enable => $service_enable,
name => $service_name,
hasstatus => true,
hasrestart => true,
}
}
}

87
modules/ntp/metadata.json Normal file
View file

@ -0,0 +1,87 @@
{
"name": "puppetlabs-ntp",
"version": "3.1.1",
"author": "Puppet Labs",
"summary": "NTP Module",
"license": "Apache Version 2.0",
"source": "git://github.com/puppetlabs/puppetlabs-ntp",
"project_page": "http://github.com/puppetlabs/puppetlabs-ntp",
"issues_url": "https://github.com/puppetlabs/puppetlabs-ntp/issues",
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6"
]
},
{
"operatingsystem": "SLES",
"operatingsystemrelease": [
"11 SP1"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"10.04",
"12.04",
"14.04"
]
},
{
"operatingsystem": "AIX",
"operatingsystemrelease": [
"5.3",
"6.1",
"7.1"
]
}
],
"requirements": [
{
"name": "pe",
"version_requirement": "3.3.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"description": "NTP Module for Debian, Ubuntu, CentOS, RHEL, OEL, Fedora, FreeBSD, ArchLinux and Gentoo.",
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.0.0"
}
]
}

View file

@ -0,0 +1,37 @@
require 'spec_helper_acceptance'
describe 'ntp class:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'should run successfully' do
pp = "class { 'ntp': }"
# Apply twice to ensure no errors the second time.
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stderr).not_to match(/error/i)
end
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stderr).not_to eq(/error/i)
expect(r.exit_code).to be_zero
end
end
context 'service_ensure => stopped:' do
it 'runs successfully' do
pp = "class { 'ntp': service_ensure => stopped }"
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stderr).not_to match(/error/i)
end
end
end
context 'service_ensure => running:' do
it 'runs successfully' do
pp = "class { 'ntp': service_ensure => running }"
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stderr).not_to match(/error/i)
end
end
end
end

View file

@ -0,0 +1,30 @@
require 'spec_helper_acceptance'
describe "ntp class with disable_monitor:", :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
context 'should run successfully' do
pp = "class { 'ntp': disable_monitor => true }"
it 'runs twice' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file('/etc/ntp.conf') do
it { should contain('disable monitor') }
end
end
context 'should run successfully' do
pp = "class { 'ntp': disable_monitor => false }"
it 'runs twice' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file('/etc/ntp.conf') do
it { should_not contain('disable monitor') }
end
end
end

View file

@ -0,0 +1,12 @@
HOSTS:
centos-64-x64:
roles:
- master
- database
- dashboard
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: pe

View file

@ -0,0 +1,10 @@
HOSTS:
centos-64-x64:
roles:
- master
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
centos-65-x64:
roles:
- master
platform: el-6-x86_64
box : centos-65-x64-vbox436-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
centos-64-x64:
roles:
- master
platform: el-6-x86_64
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
fedora-18-x64:
roles:
- master
platform: fedora-18-x86_64
box : fedora-18-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
sles-11-x64.local:
roles:
- master
platform: sles-11-x64
box : sles-11sp1-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
ubuntu-server-10044-x64:
roles:
- master
platform: ubuntu-10.04-amd64
box : ubuntu-server-10044-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,10 @@
HOSTS:
ubuntu-server-12042-x64:
roles:
- master
platform: ubuntu-12.04-amd64
box : ubuntu-server-12042-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View file

@ -0,0 +1,36 @@
require 'spec_helper_acceptance'
case fact('osfamily')
when 'FreeBSD'
line = '0.freebsd.pool.ntp.org iburst maxpoll 9'
when 'Debian'
line = '0.debian.pool.ntp.org iburst'
when 'RedHat'
line = '0.centos.pool.ntp.org'
when 'SuSE'
line = '0.opensuse.pool.ntp.org'
when 'Gentoo'
line = '0.gentoo.pool.ntp.org'
when 'Linux'
case fact('operatingsystem')
when 'ArchLinux'
line = '0.pool.ntp.org'
when 'Gentoo'
line = '0.gentoo.pool.ntp.org'
end
when 'AIX'
line = '0.debian.pool.ntp.org iburst'
end
describe 'ntp::config class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'sets up ntp.conf' do
apply_manifest(%{
class { 'ntp': }
}, :catch_failures => true)
end
describe file('/etc/ntp.conf') do
it { should be_file }
it { should contain line }
end
end

View file

@ -0,0 +1,31 @@
require 'spec_helper_acceptance'
case fact('osfamily')
when 'FreeBSD'
packagename = 'net/ntp'
when 'Gentoo'
packagename = 'net-misc/ntp'
when 'Linux'
case fact('operatingsystem')
when 'ArchLinux'
packagename = 'ntp'
when 'Gentoo'
packagename = 'net-misc/ntp'
end
when 'AIX'
packagename = 'bos.net.tcp.client'
else
packagename = 'ntp'
end
describe 'ntp::install class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'installs the package' do
apply_manifest(%{
class { 'ntp': }
}, :catch_failures => true)
end
describe package(packagename) do
it { should be_installed }
end
end

View file

@ -0,0 +1,165 @@
require 'spec_helper_acceptance'
case fact('osfamily')
when 'FreeBSD'
packagename = 'net/ntp'
when 'Gentoo'
packagename = 'net-misc/ntp'
when 'Linux'
case fact('operatingsystem')
when 'ArchLinux'
packagename = 'ntp'
when 'Gentoo'
packagename = 'net-misc/ntp'
end
when 'AIX'
packagename = 'bos.net.tcp.client'
else
packagename = 'ntp'
end
describe "ntp class:", :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'applies successfully' do
pp = "class { 'ntp': }"
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stderr).not_to match(/error/i)
end
end
describe 'autoconfig' do
it 'raises a deprecation warning' do
pp = "class { 'ntp': autoupdate => true }"
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/autoupdate parameter has been deprecated and replaced with package_ensure/)
end
end
end
describe 'config' do
it 'sets the ntp.conf location' do
pp = "class { 'ntp': config => '/etc/antp.conf' }"
apply_manifest(pp, :catch_failures => true)
end
describe file('/etc/antp.conf') do
it { should be_file }
end
end
describe 'config_template' do
it 'sets up template' do
modulepath = default['distmoduledir']
shell("mkdir -p #{modulepath}/test/templates")
shell("echo 'testcontent' >> #{modulepath}/test/templates/ntp.conf")
end
it 'sets the ntp.conf location' do
pp = "class { 'ntp': config_template => 'test/ntp.conf' }"
apply_manifest(pp, :catch_failures => true)
end
describe file('/etc/ntp.conf') do
it { should be_file }
it { should contain 'testcontent' }
end
end
describe 'driftfile' do
it 'sets the driftfile location' do
pp = "class { 'ntp': driftfile => '/tmp/driftfile' }"
apply_manifest(pp, :catch_failures => true)
end
describe file('/etc/ntp.conf') do
it { should be_file }
it { should contain 'driftfile /tmp/driftfile' }
end
end
describe 'keys' do
it 'enables the key parameters' do
pp = <<-EOS
class { 'ntp':
keys_enable => true,
keys_file => '/etc/ntp/keys',
keys_controlkey => '/etc/ntp/controlkey',
keys_requestkey => '1',
keys_trusted => [ '1', '2' ],
}
EOS
# Rely on a shell command instead of a file{} here to avoid loops
# within puppet when it tries to manage /etc/ntp/keys before /etc/ntp.
shell("mkdir -p /etc/ntp && echo '1 M AAAABBBB' >> /etc/ntp/keys")
apply_manifest(pp, :catch_failures => true)
end
describe file('/etc/ntp.conf') do
it { should be_file }
it { should contain 'keys /etc/ntp/keys' }
it { should contain 'controlkey /etc/ntp/controlkey' }
it { should contain 'requestkey 1' }
it { should contain 'trustedkey 1 2' }
end
end
describe 'package' do
it 'installs the right package' do
pp = <<-EOS
class { 'ntp':
package_ensure => present,
package_name => ['#{packagename}'],
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe package(packagename) do
it { should be_installed }
end
end
describe 'panic => false' do
it 'enables the tinker panic setting' do
pp = <<-EOS
class { 'ntp':
panic => false,
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe file('/etc/ntp.conf') do
it { should contain 'tinker panic' }
end
end
describe 'panic => true' do
it 'disables the tinker panic setting' do
pp = <<-EOS
class { 'ntp':
panic => true,
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe file('/etc/ntp.conf') do
it { should_not contain 'tinker panic 0' }
end
end
describe 'udlc' do
it 'adds a udlc' do
pp = "class { 'ntp': udlc => true }"
apply_manifest(pp, :catch_failures => true)
end
describe file('/etc/ntp.conf') do
it { should be_file }
it { should contain '127.127.1.0' }
end
end
end

View file

@ -0,0 +1,63 @@
require 'spec_helper_acceptance'
case fact('osfamily')
when 'RedHat', 'FreeBSD', 'Linux', 'Gentoo'
servicename = 'ntpd'
when 'AIX'
servicename = 'xntpd'
else
servicename = 'ntp'
end
describe 'ntp::service class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
describe 'basic test' do
it 'sets up the service' do
apply_manifest(%{
class { 'ntp': }
}, :catch_failures => true)
end
describe service(servicename) do
it { should be_enabled }
it { should be_running }
end
end
describe 'service parameters' do
it 'starts the service' do
pp = <<-EOS
class { 'ntp':
service_enable => true,
service_ensure => running,
service_manage => true,
service_name => '#{servicename}'
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe service(servicename) do
it { should be_running }
it { should be_enabled }
end
end
describe 'service is unmanaged' do
it 'shouldnt stop the service' do
pp = <<-EOS
class { 'ntp':
service_enable => false,
service_ensure => stopped,
service_manage => false,
service_name => '#{servicename}'
}
EOS
apply_manifest(pp, :catch_failures => true)
end
describe service(servicename) do
it { should be_running }
it { should be_enabled }
end
end
end

View file

@ -0,0 +1,24 @@
require 'spec_helper_acceptance'
describe 'preferred servers', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
pp = <<-EOS
class { '::ntp':
servers => ['a', 'b', 'c', 'd'],
preferred_servers => ['c', 'd'],
}
EOS
it 'applies cleanly' do
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stderr).not_to match(/error/i)
end
end
describe file('/etc/ntp.conf') do
it { should be_file }
it { should contain 'server a' }
it { should contain 'server b' }
it { should contain 'server c prefer' }
it { should contain 'server d prefer' }
end
end

View file

@ -0,0 +1,20 @@
require 'spec_helper_acceptance'
describe "ntp class with restrict:", :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
context 'should run successfully' do
pp = "class { 'ntp': restrict => ['test restrict']}"
it 'runs twice' do
2.times do
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stderr).not_to match(/error/i)
end
end
end
end
describe file('/etc/ntp.conf') do
it { should contain('test restrict') }
end
end

View file

@ -0,0 +1,10 @@
require 'spec_helper_acceptance'
describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'should fail' do
pp = <<-EOS
class { 'ntp': }
EOS
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/is not supported on an/i)
end
end

View file

@ -0,0 +1,272 @@
require 'spec_helper'
describe 'ntp' do
['Debian', 'RedHat','SuSE', 'FreeBSD', 'Archlinux', 'Gentoo', 'Gentoo (Facter < 1.7)'].each do |system|
if system == 'Gentoo (Facter < 1.7)'
let(:facts) {{ :osfamily => 'Linux', :operatingsystem => 'Gentoo' }}
else
let(:facts) {{ :osfamily => system }}
end
it { should contain_class('ntp::install') }
it { should contain_class('ntp::config') }
it { should contain_class('ntp::service') }
describe "ntp::config on #{system}" do
it { should contain_file('/etc/ntp.conf').with_owner('0') }
it { should contain_file('/etc/ntp.conf').with_group('0') }
it { should contain_file('/etc/ntp.conf').with_mode('0644') }
describe 'allows template to be overridden' do
let(:params) {{ :config_template => 'my_ntp/ntp.conf.erb' }}
it { should contain_file('/etc/ntp.conf').with({
'content' => /server foobar/})
}
end
describe "keys for osfamily #{system}" do
context "when enabled" do
let(:params) {{
:keys_enable => true,
:keys_file => '/etc/ntp/ntp.keys',
:keys_trusted => ['1', '2', '3'],
:keys_controlkey => '2',
:keys_requestkey => '3',
}}
it { should contain_file('/etc/ntp').with({
'ensure' => 'directory'})
}
it { should contain_file('/etc/ntp.conf').with({
'content' => /trustedkey 1 2 3/})
}
it { should contain_file('/etc/ntp.conf').with({
'content' => /controlkey 2/})
}
it { should contain_file('/etc/ntp.conf').with({
'content' => /requestkey 3/})
}
end
end
context "when disabled" do
let(:params) {{
:keys_enable => false,
:keys_file => '/etc/ntp/ntp.keys',
:keys_trusted => ['1', '2', '3'],
:keys_controlkey => '2',
:keys_requestkey => '3',
}}
it { should_not contain_file('/etc/ntp').with({
'ensure' => 'directory'})
}
it { should_not contain_file('/etc/ntp.conf').with({
'content' => /trustedkey 1 2 3/})
}
it { should_not contain_file('/etc/ntp.conf').with({
'content' => /controlkey 2/})
}
it { should_not contain_file('/etc/ntp.conf').with({
'content' => /requestkey 3/})
}
end
describe 'preferred servers' do
context "when set" do
let(:params) {{
:servers => ['a', 'b', 'c', 'd'],
:preferred_servers => ['a', 'b']
}}
it { should contain_file('/etc/ntp.conf').with({
'content' => /server a prefer\nserver b prefer\nserver c\nserver d/})
}
end
context "when not set" do
let(:params) {{
:servers => ['a', 'b', 'c', 'd'],
:preferred_servers => []
}}
it { should_not contain_file('/etc/ntp.conf').with({
'content' => /server a prefer/})
}
end
end
describe "ntp::install on #{system}" do
let(:params) {{ :package_ensure => 'present', :package_name => ['ntp'], }}
it { should contain_package('ntp').with(
:ensure => 'present',
:name => 'ntp'
)}
describe 'should allow package ensure to be overridden' do
let(:params) {{ :package_ensure => 'latest', :package_name => ['ntp'] }}
it { should contain_package('ntp').with_ensure('latest') }
end
describe 'should allow the package name to be overridden' do
let(:params) {{ :package_ensure => 'present', :package_name => ['hambaby'] }}
it { should contain_package('ntp').with_name('hambaby') }
end
end
describe 'ntp::service' do
let(:params) {{
:service_manage => true,
:service_enable => true,
:service_ensure => 'running',
:service_name => 'ntp'
}}
describe 'with defaults' do
it { should contain_service('ntp').with(
:enable => true,
:ensure => 'running',
:name => 'ntp'
)}
end
describe 'service_ensure' do
describe 'when overridden' do
let(:params) {{ :service_name => 'ntp', :service_ensure => 'stopped' }}
it { should contain_service('ntp').with_ensure('stopped') }
end
end
describe 'service_manage' do
let(:params) {{
:service_manage => false,
:service_enable => true,
:service_ensure => 'running',
:service_name => 'ntpd',
}}
it 'when set to false' do
should_not contain_service('ntp').with({
'enable' => true,
'ensure' => 'running',
'name' => 'ntpd'
})
end
end
end
end
context 'ntp::config' do
describe "for operating system Gentoo (Facter < 1.7)" do
let(:facts) {{ :operatingsystem => 'Gentoo',
:osfamily => 'Linux' }}
it 'uses the NTP pool servers by default' do
should contain_file('/etc/ntp.conf').with({
'content' => /server \d.gentoo.pool.ntp.org/,
})
end
end
describe "on osfamily Gentoo" do
let(:facts) {{ :osfamily => 'Gentoo' }}
it 'uses the NTP pool servers by default' do
should contain_file('/etc/ntp.conf').with({
'content' => /server \d.gentoo.pool.ntp.org/,
})
end
end
describe "on osfamily Debian" do
let(:facts) {{ :osfamily => 'debian' }}
it 'uses the debian ntp servers by default' do
should contain_file('/etc/ntp.conf').with({
'content' => /server \d.debian.pool.ntp.org iburst/,
})
end
end
describe "on osfamily RedHat" do
let(:facts) {{ :osfamily => 'RedHat' }}
it 'uses the redhat ntp servers by default' do
should contain_file('/etc/ntp.conf').with({
'content' => /server \d.centos.pool.ntp.org/,
})
end
end
describe "on osfamily SuSE" do
let(:facts) {{ :osfamily => 'SuSE' }}
it 'uses the opensuse ntp servers by default' do
should contain_file('/etc/ntp.conf').with({
'content' => /server \d.opensuse.pool.ntp.org/,
})
end
end
describe "on osfamily FreeBSD" do
let(:facts) {{ :osfamily => 'FreeBSD' }}
it 'uses the freebsd ntp servers by default' do
should contain_file('/etc/ntp.conf').with({
'content' => /server \d.freebsd.pool.ntp.org iburst maxpoll 9/,
})
end
end
describe "on osfamily ArchLinux" do
let(:facts) {{ :osfamily => 'ArchLinux' }}
it 'uses the NTP pool servers by default' do
should contain_file('/etc/ntp.conf').with({
'content' => /server \d.pool.ntp.org/,
})
end
end
describe "for operating system family unsupported" do
let(:facts) {{
:osfamily => 'unsupported',
}}
it { expect{ subject }.to raise_error(
/^The ntp module is not supported on an unsupported based system./
)}
end
end
describe 'for virtual machines' do
let(:facts) {{ :osfamily => 'Archlinux',
:is_virtual => 'true' }}
it 'should not use local clock as a time source' do
should_not contain_file('/etc/ntp.conf').with({
'content' => /server.*127.127.1.0.*fudge.*127.127.1.0 stratum 10/,
})
end
it 'allows large clock skews' do
should contain_file('/etc/ntp.conf').with({
'content' => /tinker panic 0/,
})
end
end
describe 'for physical machines' do
let(:facts) {{ :osfamily => 'Archlinux',
:is_virtual => 'false' }}
it 'disallows large clock skews' do
should_not contain_file('/etc/ntp.conf').with({
'content' => /tinker panic 0/,
})
end
end
end
end

View file

@ -0,0 +1,4 @@
#my uber ntp config
#
server foobar

View file

@ -0,0 +1,6 @@
--format
s
--colour
--loadby
mtime
--backtrace

View file

@ -0,0 +1 @@
require 'puppetlabs_spec_helper/module_spec_helper'

View file

@ -0,0 +1,32 @@
require 'beaker-rspec'
UNSUPPORTED_PLATFORMS = [ 'windows', 'Solaris' ]
unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
if hosts.first.is_pe?
install_pe
else
install_puppet
end
hosts.each do |host|
on hosts, "mkdir -p #{host['distmoduledir']}"
end
end
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Readable test descriptions
c.formatter = :documentation
# Configure all nodes in nodeset
c.before :suite do
# Install module and dependencies
puppet_module_install(:source => proj_root, :module_name => 'ntp')
hosts.each do |host|
shell("/bin/touch #{default['puppetpath']}/hiera.yaml")
shell('puppet module install puppetlabs-stdlib', :acceptable_exit_codes => [0,1])
end
end
end

View file

@ -0,0 +1,4 @@
Provider Specs
==============
Define specs for your providers under this directory.

View file

@ -0,0 +1,4 @@
Resource Type Specs
===================
Define specs for your resource types in this directory.

View file

@ -0,0 +1,53 @@
# ntp.conf: Managed by puppet.
#
<% if @panic == false -%>
# Keep ntpd from panicking in the event of a large clock skew
# when a VM guest is suspended and resumed.
tinker panic 0
<% end -%>
<% if @disable_monitor == true -%>
disable monitor
<% end -%>
<% if @restrict != [] -%>
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
<% @restrict.flatten.each do |restrict| -%>
restrict <%= restrict %>
<% end %>
<% end -%>
<% [@servers].flatten.each do |server| -%>
server <%= server %><% if @preferred_servers.include?(server) -%> prefer<% end %>
<% end -%>
<% if scope.lookupvar('::is_virtual') == "false" or @udlc -%>
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0
fudge 127.127.1.0 stratum 10
restrict 127.127.1.0
<% end -%>
# Driftfile.
driftfile <%= @driftfile %>
<% unless @logfile.nil? %>
# Logfile
logfile = <%= @logfile %>
<% end %>
<% if @keys_enable -%>
keys <%= @keys_file %>
<% unless @keys_trusted.empty? -%>
trustedkey <%= @keys_trusted.join(' ') %>
<% end -%>
<% if @keys_requestkey != '' -%>
requestkey <%= @keys_requestkey %>
<% end -%>
<% if @keys_controlkey != '' -%>
controlkey <%= @keys_controlkey %>
<% end -%>
<% end -%>

11
modules/ntp/tests/init.pp Normal file
View file

@ -0,0 +1,11 @@
node default {
notify { 'enduser-before': }
notify { 'enduser-after': }
class { 'ntp':
require => Notify['enduser-before'],
before => Notify['enduser-after'],
}
}