Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9696578
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
57 KB
Subscribers
None
View Options
diff --git a/.gitignore b/.gitignore
index d17e987..49bc2a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,23 +1,23 @@
.*.sw[op]
.metadata
.yardoc
.yardwarns
*.iml
/.bundle/
/.idea/
/.vagrant/
/coverage/
/bin/
/doc/
/Gemfile.local
/Gemfile.lock
/junit/
/log/
-/log/
/pkg/
/spec/fixtures/manifests/
/spec/fixtures/modules/
/tmp/
/vendor/
/convert_report.txt
-
+/update_report.txt
+.DS_Store
diff --git a/.gitignore b/.pdkignore
similarity index 88%
copy from .gitignore
copy to .pdkignore
index d17e987..49bc2a4 100644
--- a/.gitignore
+++ b/.pdkignore
@@ -1,23 +1,23 @@
.*.sw[op]
.metadata
.yardoc
.yardwarns
*.iml
/.bundle/
/.idea/
/.vagrant/
/coverage/
/bin/
/doc/
/Gemfile.local
/Gemfile.lock
/junit/
/log/
-/log/
/pkg/
/spec/fixtures/manifests/
/spec/fixtures/modules/
/tmp/
/vendor/
/convert_report.txt
-
+/update_report.txt
+.DS_Store
diff --git a/.rubocop.yml b/.rubocop.yml
index a658984..7ed6225 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,105 +1,115 @@
---
require: rubocop-rspec
AllCops:
DisplayCopNames: true
TargetRubyVersion: '2.1'
Include:
- "./**/*.rb"
Exclude:
- bin/*
- ".vendor/**/*"
- - Gemfile
- - Rakefile
+ - "**/Gemfile"
+ - "**/Rakefile"
- pkg/**/*
- spec/fixtures/**/*
- vendor/**/*
+ - "**/Puppetfile"
+ - "**/Vagrantfile"
+ - "**/Guardfile"
Metrics/LineLength:
Description: People have wide screens, use them.
Max: 200
RSpec/BeforeAfterAll:
Description: Beware of using after(:all) as it may cause state to leak between tests.
A necessary evil in acceptance testing.
Exclude:
- spec/acceptance/**/*.rb
RSpec/HookArgument:
Description: Prefer explicit :each argument, matching existing module's style
EnforcedStyle: each
Style/BlockDelimiters:
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
be consistent then.
EnforcedStyle: braces_for_chaining
Style/ClassAndModuleChildren:
Description: Compact style reduces the required amount of indentation.
EnforcedStyle: compact
Style/EmptyElse:
Description: Enforce against empty else clauses, but allow `nil` for clarity.
EnforcedStyle: empty
Style/FormatString:
Description: Following the main puppet project's style, prefer the % format format.
EnforcedStyle: percent
Style/FormatStringToken:
Description: Following the main puppet project's style, prefer the simpler template
tokens over annotated ones.
EnforcedStyle: template
Style/Lambda:
Description: Prefer the keyword for easier discoverability.
EnforcedStyle: literal
Style/RegexpLiteral:
Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
EnforcedStyle: percent_r
Style/TernaryParentheses:
Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
on complex expressions for better readability, but seriously consider breaking
it up.
EnforcedStyle: require_parentheses_when_complex
Style/TrailingCommaInArguments:
Description: Prefer always trailing comma on multiline argument lists. This makes
diffs, and re-ordering nicer.
EnforcedStyleForMultiline: comma
Style/TrailingCommaInLiteral:
Description: Prefer always trailing comma on multiline literals. This makes diffs,
and re-ordering nicer.
EnforcedStyleForMultiline: comma
Style/SymbolArray:
Description: Using percent style obscures symbolic intent of array's contents.
EnforcedStyle: brackets
+RSpec/MessageSpies:
+ EnforcedStyle: receive
+Style/Documentation:
+ Exclude:
+ - lib/puppet/parser/functions/**/*
+Style/WordArray:
+ EnforcedStyle: brackets
Style/CollectionMethods:
Enabled: true
Style/MethodCalledOnDoEndBlock:
Enabled: true
Style/StringMethods:
Enabled: true
Layout/EndOfLine:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
RSpec/DescribeClass:
Enabled: false
RSpec/ExampleLength:
Enabled: false
RSpec/MessageExpectation:
Enabled: false
RSpec/MultipleExpectations:
Enabled: false
RSpec/NestedGroups:
Enabled: false
Style/AsciiComments:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
Style/SymbolProc:
Enabled: false
diff --git a/.travis.yml b/.travis.yml
index 1428837..76b202c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,67 +1,61 @@
---
sudo: false
dist: trusty
language: ruby
cache: bundler
before_install:
- bundle -v
- rm -f Gemfile.lock
- gem update --system
- - gem update bundler
- gem --version
- bundle -v
script:
- 'bundle exec rake $CHECK'
bundler_args: --without system_tests
rvm:
- 2.4.1
env:
- - PUPPET_GEM_VERSION="~> 5.0" CHECK=spec
+ global:
+ - BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0"
matrix:
fast_finish: true
include:
-
bundler_args:
dist: trusty
- env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7
+ env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/centos-7
rvm: 2.4.1
script: bundle exec rake beaker
services: docker
sudo: required
-
bundler_args:
dist: trusty
- env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-14.04
+ env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/ubuntu-14.04
rvm: 2.4.1
script: bundle exec rake beaker
services: docker
sudo: required
-
- env: CHECK=rubocop
+ env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop"
-
- env: CHECK="syntax lint"
+ env: CHECK=parallel_spec
-
- env: CHECK=metadata_lint
- -
- env: CHECK=release_checks
- -
- env: CHECK=spec
- -
- env: PUPPET_GEM_VERSION="~> 4.0" CHECK=spec
+ env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec
rvm: 2.1.9
branches:
only:
- master
- /^v\d/
- release
notifications:
email: false
deploy:
provider: puppetforge
user: puppet
password:
secure: ""
on:
tags: true
all_branches: true
condition: "$DEPLOY_TO_FORGE = yes"
diff --git a/.yardopts b/.yardopts
new file mode 100644
index 0000000..29c933b
--- /dev/null
+++ b/.yardopts
@@ -0,0 +1 @@
+--markup markdown
diff --git a/Gemfile b/Gemfile
index 37597a3..a7ec820 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,136 +1,88 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
def location_for(place_or_version, fake_version = nil)
if place_or_version =~ %r{\A(git[:@][^#]*)#(.*)}
[fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact
elsif place_or_version =~ %r{\Afile:\/\/(.*)}
['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }]
else
[place_or_version, { require: false }]
end
end
def gem_type(place_or_version)
if place_or_version =~ %r{\Agit[:@]}
:git
elsif !place_or_version.nil? && place_or_version.start_with?('file:')
:file
else
:gem
end
end
ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
minor_version = ruby_version_segments[0..1].join('.')
group :development do
gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
+ gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4')
gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
- gem "puppet-blacksmith", '~> 3.4', require: false
+ gem "puppet-blacksmith", '~> 3.4', require: false, platforms: [:ruby]
end
group :system_tests do
gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-win-system-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 3.13')
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')
gem "beaker-pe", require: false
gem "beaker-hostgenerator"
gem "beaker-rspec"
end
puppet_version = ENV['PUPPET_GEM_VERSION']
puppet_type = gem_type(puppet_version)
facter_version = ENV['FACTER_GEM_VERSION']
hiera_version = ENV['HIERA_GEM_VERSION']
-def puppet_older_than?(version)
- puppet_version = ENV['PUPPET_GEM_VERSION']
- !puppet_version.nil? &&
- Gem::Version.correct?(puppet_version) &&
- Gem::Requirement.new("< #{version}").satisfied_by?(Gem::Version.new(puppet_version.dup))
-end
-
gems = {}
gems['puppet'] = location_for(puppet_version)
# If facter or hiera versions have been specified via the environment
-# variables, use those versions. If not, and if the puppet version is < 3.5.0,
-# use known good versions of both for puppet < 3.5.0.
-if facter_version
- gems['facter'] = location_for(facter_version)
-elsif puppet_type == :gem && puppet_older_than?('3.5.0')
- gems['facter'] = ['>= 1.6.11', '<= 1.7.5', require: false]
-end
-
-if hiera_version
- gems['hiera'] = location_for(ENV['HIERA_GEM_VERSION'])
-elsif puppet_type == :gem && puppet_older_than?('3.5.0')
- gems['hiera'] = ['>= 1.0.0', '<= 1.3.0', require: false]
-end
+# variables
-if Gem.win_platform? && (puppet_type != :gem || puppet_older_than?('3.5.0'))
- # For Puppet gems < 3.5.0 (tested as far back as 3.0.0) on Windows
- if puppet_type == :gem
- gems['ffi'] = ['1.9.0', require: false]
- gems['minitar'] = ['0.5.4', require: false]
- gems['win32-eventlog'] = ['0.5.3', '<= 0.6.5', require: false]
- gems['win32-process'] = ['0.6.5', '<= 0.7.5', require: false]
- gems['win32-security'] = ['~> 0.1.2', '<= 0.2.5', require: false]
- gems['win32-service'] = ['0.7.2', '<= 0.8.8', require: false]
- else
- gems['ffi'] = ['~> 1.9.0', require: false]
- gems['minitar'] = ['~> 0.5.4', require: false]
- gems['win32-eventlog'] = ['~> 0.5', '<= 0.6.5', require: false]
- gems['win32-process'] = ['~> 0.6', '<= 0.7.5', require: false]
- gems['win32-security'] = ['~> 0.1', '<= 0.2.5', require: false]
- gems['win32-service'] = ['~> 0.7', '<= 0.8.8', require: false]
- end
-
- gems['win32-dir'] = ['~> 0.3', '<= 0.4.9', require: false]
-
- if RUBY_VERSION.start_with?('1.')
- gems['win32console'] = ['1.3.2', require: false]
- # sys-admin was removed in Puppet 3.7.0 and doesn't compile under Ruby 2.x
- gems['sys-admin'] = ['1.5.6', require: false]
- end
+gems['facter'] = location_for(facter_version) if facter_version
+gems['hiera'] = location_for(hiera_version) if hiera_version
- # Puppet < 3.7.0 requires these.
- # Puppet >= 3.5.0 gem includes these as requirements.
- # The following versions are tested to work with 3.0.0 <= puppet < 3.7.0.
- gems['win32-api'] = ['1.4.8', require: false]
- gems['win32-taskscheduler'] = ['0.2.2', require: false]
- gems['windows-api'] = ['0.4.3', require: false]
- gems['windows-pr'] = ['1.2.3', require: false]
-elsif Gem.win_platform?
+if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)}
# If we're using a Puppet gem on Windows which handles its own win32-xxx gem
# dependencies (>= 3.5.0), set the maximum versions (see PUP-6445).
gems['win32-dir'] = ['<= 0.4.9', require: false]
gems['win32-eventlog'] = ['<= 0.6.5', require: false]
gems['win32-process'] = ['<= 0.7.5', require: false]
gems['win32-security'] = ['<= 0.2.5', require: false]
- gems['win32-service'] = ['<= 0.8.8', require: false]
+ gems['win32-service'] = ['0.8.8', require: false]
end
gems.each do |gem_name, gem_params|
gem gem_name, *gem_params
end
# Evaluate Gemfile.local and ~/.gemfile if they exist
extra_gemfiles = [
"#{__FILE__}.local",
File.join(Dir.home, '.gemfile'),
]
extra_gemfiles.each do |gemfile|
if File.file?(gemfile) && File.readable?(gemfile)
eval(File.read(gemfile), binding)
end
end
# vim: syntax=ruby
diff --git a/Rakefile b/Rakefile
index 802f67b..d4e36da 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,3 +1,6 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-syntax/tasks/puppet-syntax'
-require 'puppet_blacksmith/rake_tasks'
+require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
+
+PuppetLint.configuration.send('disable_relative')
+
diff --git a/metadata.json b/metadata.json
index b565bd1..4267404 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,113 +1,114 @@
{
"name": "puppetlabs-ntp",
"version": "7.1.1",
"author": "Puppet Inc",
"summary": "Installs, configures, and manages the NTP service.",
"license": "Apache-2.0",
"source": "https://github.com/puppetlabs/puppetlabs-ntp",
"project_page": "https://github.com/puppetlabs/puppetlabs-ntp",
"issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.13.1 < 5.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Fedora",
"operatingsystemrelease": [
"24",
"25"
]
},
{
"operatingsystem": "SLES",
"operatingsystemrelease": [
"11 SP1",
"12"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"7",
"8"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"14.04",
"16.04"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"11"
]
},
{
"operatingsystem": "AIX",
"operatingsystemrelease": [
"5.3",
"6.1",
"7.1"
]
},
{
"operatingsystem": "Amazon",
"operatingsystemrelease": [
"2013.09",
"2014.03",
"2014.09",
"2015.03"
]
},
{
"operatingsystem": "Archlinux"
}
],
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 4.9.4 < 6.0.0"
}
],
"description": "NTP Module for Debian, Ubuntu, CentOS, RHEL, OEL, Fedora, FreeBSD, ArchLinux, Amazon Linux and Gentoo.",
- "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git",
- "template-ref": "1.3.2-0-g07678c8"
+ "template-url": "https://github.com/puppetlabs/pdk-templates",
+ "template-ref": "heads/master-0-g34e3266",
+ "pdk-version": "1.5.0"
}
diff --git a/spec/acceptance/ntp_install_spec.rb b/spec/acceptance/ntp_install_spec.rb
index 3856e63..275c136 100644
--- a/spec/acceptance/ntp_install_spec.rb
+++ b/spec/acceptance/ntp_install_spec.rb
@@ -1,38 +1,38 @@
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'
when 'Solaris'
case fact('kernelrelease')
when '5.10'
- packagename = %w[SUNWntp4r SUNWntp4u]
+ packagename = ['SUNWntp4r', 'SUNWntp4u']
when '5.11'
packagename = 'service/network/ntp'
end
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
Array(packagename).each do |package|
describe package(package) do
it { is_expected.to be_installed }
end
end
end
diff --git a/spec/acceptance/ntp_parameters_spec.rb b/spec/acceptance/ntp_parameters_spec.rb
index 59d97d4..7e0b1ca 100644
--- a/spec/acceptance/ntp_parameters_spec.rb
+++ b/spec/acceptance/ntp_parameters_spec.rb
@@ -1,236 +1,236 @@
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'
when 'Solaris'
case fact('kernelrelease')
when '5.10'
- packagename = %w[SUNWntp4r SUNWntp4u]
+ packagename = ['SUNWntp4r', 'SUNWntp4u']
when '5.11'
packagename = 'service/network/ntp'
end
else
if fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12'
'ntpd'
else
'ntp'
end
end
keysfile = if fact('osfamily') == 'RedHat'
'/etc/ntp/keys'
elsif fact('osfamily') == 'Solaris'
'/etc/inet/ntp.keys'
else
'/etc/ntp.keys'
end
config = if fact('osfamily') == 'Solaris'
'/etc/inet/ntp.conf'
else
'/etc/ntp.conf'
end
describe 'ntp class:', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
# FM-5470, this was added to reset failed count and work around puppet 3.x
if (fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12') || (fact('operatingsystem') == 'Scientific' && fact('operatingsystemmajrelease') == '7')
after :each do
shell('systemctl reset-failed ntpd.service')
end
end
it 'applies successfully' do
pp = "class { 'ntp': }"
apply_manifest(pp, catch_failures: true) do |r|
expect(r.stderr).not_to match(%r{error}i)
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 { is_expected.to be_file }
end
end
describe 'config_template' do
before :all do
modulepath = default['distmoduledir']
shell("mkdir -p #{modulepath}/test/templates")
# Add spurious template logic to verify the use of the correct template rendering engine
shell("echo '<% [1].each do |i| %>erbserver<%= i %><%end %>' >> #{modulepath}/test/templates/ntp.conf.erb")
end
it 'sets the ntp.conf erb template location' do
pp = "class { 'ntp': config_template => 'test/ntp.conf.erb' }"
apply_manifest(pp, catch_failures: true)
end
describe file(config.to_s) do
it { is_expected.to be_file }
its(:content) { is_expected.to match 'erbserver1' }
end
it 'sets the ntp.conf epp template location and the ntp.conf erb template location which should fail' do
pp = "class { 'ntp': config_template => 'test/ntp.conf.erb', config_epp => 'test/ntp.conf.epp' }"
expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{Cannot supply both config_epp and config_template}i)
end
end
describe 'config_epp' do
before :all do
modulepath = default['distmoduledir']
shell("mkdir -p #{modulepath}/test/templates")
# Add spurious template logic to verify the use of the correct template rendering engine
shell("echo '<% [1].each |$i| { -%>eppserver<%= $i %><% } -%>' >> #{modulepath}/test/templates/ntp.conf.epp")
end
it 'sets the ntp.conf epp template location' do
pp = "class { 'ntp': config_epp => 'test/ntp.conf.epp' }"
apply_manifest(pp, catch_failures: true)
end
describe file(config.to_s) do
it { is_expected.to be_file }
its(:content) { is_expected.to match 'eppserver1' }
end
it 'sets the ntp.conf epp template location and the ntp.conf erb template location which should fail' do
pp = "class { 'ntp': config_template => 'test/ntp.conf.erb', config_epp => 'test/ntp.conf.epp' }"
expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{Cannot supply both config_epp and config_template}i)
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(config.to_s) do
it { is_expected.to be_file }
its(:content) { is_expected.to match 'driftfile /tmp/driftfile' }
end
end
describe 'keys' do
pp = <<-MANIFEST
class { 'ntp':
keys_enable => true,
keys_controlkey => 1,
keys_requestkey => 1,
keys_trusted => [ 1, 2 ],
keys => [ '1 M AAAABBBB' ],
}
MANIFEST
it 'enables the key parameters' do
apply_manifest(pp, catch_failures: true)
end
describe file(config.to_s) do
it { is_expected.to be_file }
its(:content) { is_expected.to match "keys #{keysfile}" }
its(:content) { is_expected.to match 'controlkey 1' }
its(:content) { is_expected.to match 'requestkey 1' }
its(:content) { is_expected.to match 'trustedkey 1 2' }
end
describe file(keysfile) do
it { is_expected.to be_file }
its(:content) { is_expected.to match '1 M AAAABBBB' }
end
end
describe 'package' do
pp = <<-MANIFEST
class { 'ntp':
package_ensure => present,
package_name => #{Array(packagename).inspect},
}
MANIFEST
it 'installs the right package' do
apply_manifest(pp, catch_failures: true)
end
Array(packagename).each do |package|
describe package(package) do
it { is_expected.to be_installed }
end
end
end
describe 'panic => 0' do
pp = <<-MANIFEST
class { 'ntp':
panic => 0,
}
MANIFEST
it 'disables the tinker panic setting' do
apply_manifest(pp, catch_failures: true)
end
describe file(config.to_s) do
its(:content) { is_expected.to match 'tinker panic 0' }
end
end
describe 'panic => 1' do
pp = <<-MANIFEST
class { 'ntp':
panic => 1,
}
MANIFEST
it 'enables the tinker panic setting' do
apply_manifest(pp, catch_failures: true)
end
describe file(config.to_s) do
its(:content) { is_expected.to match 'tinker panic 1' }
end
end
describe 'udlc' do
it 'adds a udlc' do
pp = "class { 'ntp': udlc => true }"
apply_manifest(pp, catch_failures: true)
end
describe file(config.to_s) do
it { is_expected.to be_file }
its(:content) { is_expected.to match '127.127.1.0' }
end
end
describe 'udlc_stratum' do
it 'sets the stratum value when using udlc' do
pp = "class { 'ntp': udlc => true, udlc_stratum => 10 }"
apply_manifest(pp, catch_failures: true)
end
describe file(config.to_s) do
it { is_expected.to be_file }
its(:content) { is_expected.to match 'stratum 10' }
end
end
end
diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb
index a86d8a5..cf9419f 100644
--- a/spec/classes/ntp_spec.rb
+++ b/spec/classes/ntp_spec.rb
@@ -1,949 +1,949 @@
require 'spec_helper'
on_supported_os.reject { |_, f| f[:os]['family'] == 'Solaris' }.each do |os, f|
describe 'ntp' do
let(:facts) { { is_virtual: false } }
context "on #{os}" do
let(:facts) do
f.merge(super())
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('ntp::install') }
it { is_expected.to contain_class('ntp::config') }
it { is_expected.to contain_class('ntp::service') }
describe 'ntp::config' do
it { is_expected.to contain_file('/etc/ntp.conf').with_owner('0') }
it { is_expected.to contain_file('/etc/ntp.conf').with_group('0') }
it { is_expected.to contain_file('/etc/ntp.conf').with_mode('0644') }
if f[:os]['family'] == 'RedHat'
it { is_expected.to contain_file('/etc/ntp/step-tickers').with_owner('0') }
it { is_expected.to contain_file('/etc/ntp/step-tickers').with_group('0') }
it { is_expected.to contain_file('/etc/ntp/step-tickers').with_mode('0644') }
end
if f[:os]['family'] == 'Suse' && f[:os]['release']['major'] == '12'
it { is_expected.to contain_file('/var/run/ntp/servers-netconfig').with_ensure_absent }
end
describe 'allows template to be overridden with erb template' do
let(:params) { { config_template: 'my_ntp/ntp.conf.erb' } }
it { is_expected.to contain_file('/etc/ntp.conf').with_content(%r{erbserver1}) }
end
describe 'allows template to be overridden with epp template' do
let(:params) { { config_epp: 'my_ntp/ntp.conf.epp' } }
it { is_expected.to contain_file('/etc/ntp.conf').with_content(%r{eppserver1}) }
end
describe 'keys' do
context 'when enabled' do
let(:params) do
{
keys_enable: true,
keys_trusted: [1, 2, 3],
keys_controlkey: 2,
keys_requestkey: 3,
}
end
it {
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{trustedkey 1 2 3})
}
it {
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{controlkey 2})
}
it {
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{requestkey 3})
}
end
end
context 'when disabled' do
let(:params) do
{
keys_enable: false,
keys_trusted: [1, 2, 3],
keys_controlkey: 2,
keys_requestkey: 3,
}
end
it {
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{trustedkey 1 2 3})
}
it {
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{controlkey 2})
}
it {
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{requestkey 3})
}
end
describe 'preferred servers' do
context 'when set' do
let(:params) do
{
- servers: %w[a b c d],
- preferred_servers: %w[a b],
+ servers: ['a', 'b', 'c', 'd'],
+ preferred_servers: ['a', 'b'],
iburst_enable: false,
}
end
it {
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server a prefer( maxpoll 9)?\nserver b prefer( maxpoll 9)?\nserver c( maxpoll 9)?\nserver d( maxpoll 9)?})
}
end
context 'when not set' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
preferred_servers: [],
}
end
it {
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{server a prefer})
}
end
end
describe 'noselect servers' do
context 'when set' do
let(:params) do
{
- servers: %w[a b c d],
- noselect_servers: %w[a b],
+ servers: ['a', 'b', 'c', 'd'],
+ noselect_servers: ['a', 'b'],
iburst_enable: false,
}
end
it {
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server a (maxpoll 9 )?noselect\nserver b (maxpoll 9 )?noselect\nserver c( maxpoll 9)?\nserver d( maxpoll 9)?})
}
end
context 'when not set' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
noselect_servers: [],
}
end
it {
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{server a noselect})
}
end
end
describe 'specified interfaces' do
context 'when set' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
interfaces: ['127.0.0.1', 'a.b.c.d'],
}
end
it {
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{interface ignore wildcard\ninterface listen 127.0.0.1\ninterface listen a.b.c.d})
}
end
context 'when not set' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
}
end
it {
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{interface ignore wildcard})
}
end
end
describe 'specified ignore interfaces' do
context 'when set' do
let(:params) do
{
interfaces: ['a.b.c.d'],
- interfaces_ignore: %w[wildcard ipv6],
+ interfaces_ignore: ['wildcard', 'ipv6'],
}
end
it {
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{interface ignore wildcard\ninterface ignore ipv6\ninterface listen a.b.c.d})
}
end
context 'when not set' do
let(:params) do
{
interfaces: ['127.0.0.1'],
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
}
end
it {
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{interface ignore wildcard\ninterface listen 127.0.0.1})
}
end
end
describe 'with parameter disable_auth' do
context 'when set to true' do
let(:params) do
{
disable_auth: true,
}
end
it 'contains disable auth setting' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^disable auth\n})
end
end
context 'when set to false' do
let(:params) do
{
disable_auth: false,
}
end
it 'does not contain disable auth setting' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^disable auth\n})
end
end
end
describe 'with parameter disable_dhclient' do
context 'when set to true' do
let(:params) do
{
disable_dhclient: true,
}
end
it 'contains disable ntp-servers setting' do
is_expected.to contain_augeas('disable ntp-servers in dhclient.conf')
end
it 'contains dhcp file' do
is_expected.to contain_file('/var/lib/ntp/ntp.conf.dhcp').with_ensure('absent')
end
it 'contains ntp.sh file' do
is_expected.to contain_file('/etc/dhcp/dhclient.d/ntp.sh').with_ensure('absent')
end
end
context 'when set to false' do
let(:params) do
{
disable_dhclient: false,
}
end
it 'does not contain disable ntp-servers setting' do
is_expected.not_to contain_augeas('disable ntp-servers in dhclient.conf')
end
it 'does not contain dhcp file' do
is_expected.not_to contain_file('/var/lib/ntp/ntp.conf.dhcp').with_ensure('absent')
end
end
end
describe 'with parameter disable_kernel' do
context 'when set to true' do
let(:params) do
{
disable_kernel: true,
}
end
it 'contains disable kernel setting' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^disable kernel\n})
end
end
context 'when set to false' do
let(:params) do
{
disable_kernel: false,
}
end
it 'does not contain disable kernel setting' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^disable kernel\n})
end
end
end
describe 'with parameter disable_monitor' do
context 'when default' do
let(:params) do
{
}
end
it 'contains disable monitor setting' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^disable monitor\n})
end
end
context 'when set to true' do
let(:params) do
{
disable_monitor: true,
}
end
it 'contains disable monitor setting' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^disable monitor\n})
end
end
context 'when set to false' do
let(:params) do
{
disable_monitor: false,
}
end
it 'does not contain disable monitor setting' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^disable monitor\n})
end
end
end
describe 'with parameter enable_mode7' do
context 'when default' do
let(:params) do
{
}
end
it 'does not contain enable mode7 setting' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^enable mode7\n})
end
end
context 'when set to true' do
let(:params) do
{
enable_mode7: true,
}
end
it 'contains enable mode7 setting' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^enable mode7\n})
end
end
context 'when set to false' do
let(:params) do
{
enable_mode7: false,
}
end
it 'does not contain enable mode7 setting' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^enable mode7\n})
end
end
end
describe 'with parameter broadcastclient' do
context 'when set to true' do
let(:params) do
{
broadcastclient: true,
}
end
it 'contains broadcastclient setting' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^broadcastclient\n})
end
end
context 'when set to false' do
let(:params) do
{
broadcastclient: false,
}
end
it 'does not contain broadcastclient setting' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^broadcastclient\n})
end
end
context 'when setting custom config_dir' do
let(:params) do
{
keys_enable: true,
config_dir: '/tmp/foo',
keys_file: '/tmp/foo/ntp.keys',
}
end
it 'contains custom config directory' do
is_expected.to contain_file('/tmp/foo').with(
'ensure' => 'directory', 'owner' => '0', 'group' => '0', 'mode' => '0775', 'recurse' => 'false',
)
end
end
context 'when manually setting conf file mode to 0777' do
let(:params) do
{
config_file_mode: '0777',
}
end
it 'contains file mode of 0777' do
is_expected.to contain_file('/etc/ntp.conf').with_mode('0777')
end
end
end
context 'when choosing the default pool servers' do
case f[:os]['family']
when 'RedHat'
if f[:os]['name'] == 'Fedora'
it 'uses the fedora ntp servers' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server \d.fedora.pool.ntp.org})
end
it do
is_expected.to contain_file('/etc/ntp/step-tickers').with('content' => %r{\d.fedora.pool.ntp.org})
end
else
it 'uses the centos ntp servers' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server \d.centos.pool.ntp.org})
end
it do
is_expected.to contain_file('/etc/ntp/step-tickers').with('content' => %r{\d.centos.pool.ntp.org})
end
end
when 'Debian'
it 'uses the debian ntp servers' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server \d.debian.pool.ntp.org iburst\n})
end
when 'Suse'
it 'uses the opensuse ntp servers' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server \d.opensuse.pool.ntp.org})
end
when 'FreeBSD'
it 'uses the freebsd ntp servers' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server \d.freebsd.pool.ntp.org iburst maxpoll 9})
end
when 'Archlinux'
it 'uses the Archlinux NTP servers' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{server \d.arch.pool.ntp.org})
end
when 'Solaris', 'Gentoo'
it 'uses the generic NTP pool servers' do
is_expected.to contain_file('/etc/inet/ntp.conf').with('content' => %r{server \d.pool.ntp.org})
end
else
it {
expect { catalogue }.to raise_error(
%r{The ntp module is not supported on an unsupported based system.},
)
}
end
end
describe 'slewalways' do
context 'when absent' do
if f[:kernel] == 'AIX'
it 'on AIX does contain "slewalways no"' do
is_expected.to contain_file('/etc/ntp.conf').with_content(%r{^slewalways no})
end
else
it 'on non-AIX does not contain a slewalways' do
is_expected.to contain_file('/etc/ntp.conf').without_content(%r{^slewalways})
end
end
end
context 'when "no"' do
let(:params) do
{
slewalways: 'no',
}
end
it 'does contain "slewalways no"' do
is_expected.to contain_file('/etc/ntp.conf').with_content(%r{^slewalways no})
end
end
context 'when "yes"' do
let(:params) do
{
slewalways: 'yes',
}
end
it 'does contain "slewalways yes"' do
is_expected.to contain_file('/etc/ntp.conf').with_content(%r{^slewalways yes})
end
end
end
end
describe 'ntp::install' do
let(:params) { { package_ensure: 'present', package_name: ['ntp'], package_manage: true } }
it {
is_expected.to contain_package('ntp').with(
ensure: 'present',
)
}
describe 'should allow package ensure to be overridden' do
let(:params) { { package_ensure: 'latest', package_name: ['ntp'], package_manage: true } }
it { is_expected.to 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'], package_manage: true } }
it { is_expected.to contain_package('hambaby') }
end
describe 'should allow the package to be unmanaged' do
let(:params) { { package_manage: false, package_name: ['ntp'] } }
it { is_expected.not_to contain_package('ntp') }
end
end
describe 'ntp::service' do
let(:params) do
{
service_manage: true,
service_enable: true,
service_ensure: 'running',
service_name: 'ntp',
}
end
describe 'with defaults' do
it {
is_expected.to 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 { is_expected.to contain_service('ntp').with_ensure('stopped') }
end
end
describe 'service_manage' do
let(:params) do
{
service_manage: false,
service_enable: true,
service_ensure: 'running',
service_name: 'ntpd',
}
end
it 'when set to false' do
is_expected.not_to contain_service('ntp').with('enable' => true,
'ensure' => 'running',
'name' => 'ntpd')
end
end
end
describe 'with parameter iburst_enable' do
context 'when set to true' do
let(:params) do
{
iburst_enable: true,
}
end
it do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{iburst})
end
end
context 'when set to false' do
let(:params) do
{
iburst_enable: false,
}
end
it do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{iburst\n})
end
end
end
describe 'with tinker parameter changed' do
describe 'when set to false' do
context 'when panic or stepout not overriden' do
let(:params) do
{
tinker: false,
}
end
it do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^tinker })
end
end
context 'when panic overriden' do
let(:params) do
{
tinker: false,
panic: 257,
}
end
it do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^tinker })
end
end
context 'when stepout overriden' do
let(:params) do
{
tinker: false,
stepout: 5,
}
end
it do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^tinker })
end
end
context 'when panic and stepout overriden' do
let(:params) do
{
tinker: false,
panic: 257,
stepout: 5,
}
end
it do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^tinker })
end
end
end
describe 'when set to true' do
context 'when only tinker set to true' do
let(:params) do
{
tinker: true,
}
end
it do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^tinker })
end
end
context 'when panic changed' do
let(:params) do
{
tinker: true,
panic: 257,
}
end
it do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^tinker panic 257\n})
end
end
context 'when stepout changed' do
let(:params) do
{
tinker: true,
stepout: 5,
}
end
it do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^tinker stepout 5\n})
end
end
context 'when panic and stepout changed' do
let(:params) do
{
tinker: true,
panic: 257,
stepout: 5,
}
end
it do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^tinker panic 257 stepout 5\n})
end
end
end
end
describe 'with parameters minpoll or maxpoll changed from default' do
context 'when minpoll changed from default' do
let(:params) do
{
minpoll: 6,
}
end
it do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{minpoll 6})
end
end
context 'when maxpoll changed from default' do
let(:params) do
{
maxpoll: 12,
}
end
it do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{maxpoll 12\n})
end
end
context 'when minpoll and maxpoll changed from default simultaneously' do
let(:params) do
{
minpoll: 6,
maxpoll: 12,
}
end
it do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{minpoll 6 maxpoll 12\n})
end
end
end
describe 'with parameter leapfile' do
context 'when set to true' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
leapfile: '/etc/leap-seconds.3629404800',
}
end
it 'contains leapfile setting' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^leapfile \/etc\/leap-seconds\.3629404800\n})
end
end
context 'when set to false' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
}
end
it 'does not contain a leapfile line' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{leapfile })
end
end
end
describe 'with parameter logfile' do
context 'when set to true' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
logfile: '/var/log/foobar.log',
}
end
it 'contains logfile setting' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^logfile \/var\/log\/foobar\.log\n})
end
end
context 'when set to false' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
}
end
it 'does not contain a logfile line' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{logfile })
end
end
end
describe 'with parameter ntpsigndsocket' do
context 'when set to true' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
ntpsigndsocket: '/usr/local/samba/var/lib/ntp_signd',
}
end
it 'contains ntpsigndsocket setting' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^ntpsigndsocket /usr/local/samba/var/lib/ntp_signd\n})
end
end
context 'when set to false' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
}
end
it 'does not contain a ntpsigndsocket line' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{ntpsigndsocket })
end
end
end
describe 'with parameter authprov' do
context 'when set to true' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
authprov: '/opt/novell/xad/lib64/libw32time.so 131072:4294967295 global',
}
end
it 'contains authprov setting' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^authprov /opt/novell/xad/lib64/libw32time.so 131072:4294967295 global\n})
end
end
context 'when set to false' do
let(:params) do
{
- servers: %w[a b c d],
+ servers: ['a', 'b', 'c', 'd'],
}
end
it 'does not contain a authprov line' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{authprov })
end
end
end
describe 'with parameter tos' do
context 'when set to true' do
let(:params) do
{
tos: true,
}
end
it 'contains tos setting' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{^tos})
end
end
context 'when set to false' do
let(:params) do
{
tos: false,
}
end
it 'does not contain tos setting' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{^tos})
end
end
end
describe 'pool' do
context 'when empty' do
let(:params) do
{
pool: [],
}
end
it 'does not contain a pool line' do
is_expected.to contain_file('/etc/ntp.conf').without_content(%r{^pool})
end
end
context 'when set' do
let(:params) do
{
- pool: %w[foo bar],
+ pool: ['foo', 'bar'],
}
end
it 'contains the pool lines - expectation one' do
is_expected.to contain_file('/etc/ntp.conf').with_content(%r{pool foo})
end
it 'contains the pool lines - expectation two' do
is_expected.to contain_file('/etc/ntp.conf').with_content(%r{pool bar})
end
end
end
describe 'peers' do
context 'when empty' do
let(:params) do
{
peers: [],
}
end
it 'does not contain a peer line' do
is_expected.to contain_file('/etc/ntp.conf').without_content(%r{^peer})
end
end
context 'when set' do
let(:params) do
{
- peers: %w[foo bar],
+ peers: ['foo', 'bar'],
}
end
it 'contains the peer lines - expectation one' do
is_expected.to contain_file('/etc/ntp.conf').with_content(%r{peer foo})
end
it 'contains the peer lines - expectation two' do
is_expected.to contain_file('/etc/ntp.conf').with_content(%r{peer bar})
end
end
end
describe 'for virtual machines' do
let :facts do
super().merge(is_virtual: true)
end
it 'does not use local clock as a time source' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{server.*127.127.1.0.*fudge.*127.127.1.0 stratum 10})
end
it 'allows large clock skews' do
is_expected.to contain_file('/etc/ntp.conf').with('content' => %r{tinker panic 0})
end
end
describe 'for physical machines' do
let :facts do
super().merge(is_virtual: false)
end
it 'disallows large clock skews' do
is_expected.not_to contain_file('/etc/ntp.conf').with('content' => %r{tinker panic 0})
end
end
end
end
end
diff --git a/spec/default_facts.yml b/spec/default_facts.yml
new file mode 100644
index 0000000..3248be5
--- /dev/null
+++ b/spec/default_facts.yml
@@ -0,0 +1,8 @@
+# Use default_module_facts.yml for module specific facts.
+#
+# Facts specified here will override the values provided by rspec-puppet-facts.
+---
+concat_basedir: "/tmp"
+ipaddress: "172.16.254.254"
+is_pe: false
+macaddress: "AA:AA:AA:AA:AA:AA"
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index c20a317..e117192 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,24 +1,36 @@
+
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
+
+begin
+ require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
+rescue LoadError => loaderror
+ warn "Could not require spec_helper_local: #{loaderror.message}"
+end
+
include RspecPuppetFacts
default_facts = {
puppetversion: Puppet.version,
facterversion: Facter.version,
}
default_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml'))
default_module_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml'))
if File.exist?(default_facts_path) && File.readable?(default_facts_path)
default_facts.merge!(YAML.safe_load(File.read(default_facts_path)))
end
if File.exist?(default_module_facts_path) && File.readable?(default_module_facts_path)
default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path)))
end
RSpec.configure do |c|
c.default_facts = default_facts
+ c.before :each do
+ # set to strictest setting for testing
+ # by default Puppet runs at warning level
+ Puppet.settings[:strict] = :warning
+ end
end
-require 'spec_helper_local'
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index 5755f69..d801584 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -1,38 +1,38 @@
require 'beaker-rspec'
require 'beaker/puppet_install_helper'
require 'beaker/module_install_helper'
-UNSUPPORTED_PLATFORMS = %w[windows Darwin].freeze
+UNSUPPORTED_PLATFORMS = ['windows', 'Darwin'].freeze
run_puppet_install_helper
install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i
install_module_on(hosts)
install_module_dependencies_on(hosts)
unless ENV['RS_PROVISION'] == 'no' || ENV['BEAKER_provision'] == 'no'
hosts.each do |host|
# Need to disable update of ntp servers from DHCP, as subsequent restart of ntp causes test failures
if fact_on(host, 'osfamily') == 'Debian'
on host, 'dpkg-divert --divert /etc/dhcp-ntp.bak --local --rename --add /etc/dhcp/dhclient-exit-hooks.d/ntp'
on host, 'dpkg-divert --divert /etc/dhcp3-ntp.bak --local --rename --add /etc/dhcp3/dhclient-exit-hooks.d/ntp'
elsif fact_on(host, 'osfamily') == 'RedHat'
on host, 'echo "PEERNTP=no" >> /etc/sysconfig/network'
end
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
hosts.each do |host|
copy_module_to(host, source: proj_root, module_name: 'ntp')
end
end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Aug 18, 8:43 PM (9 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3313014
Attached To
rSPNTP puppet-puppetlabs-ntp
Event Timeline
Log In to Comment