Skip to content

Commit

Permalink
Merge pull request #133 from voxpupuli/modulesync
Browse files Browse the repository at this point in the history
modulesync 5.1.0
  • Loading branch information
bastelfreak authored Dec 24, 2021
2 parents cdd1f19 + 3654ec4 commit b47052f
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '4.2.0'
modulesync_config_version: '5.1.0'
4 changes: 3 additions & 1 deletion .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
--relative
--fail-on-warnings
--no-parameter_documentation-check
--no-parameter_types-check
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :test do
gem 'voxpupuli-test', '~> 2.5', :require => false
gem 'voxpupuli-test', '~> 5.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 1.0', :require => false
Expand All @@ -21,7 +21,7 @@ end

group :release do
gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5'
gem 'voxpupuli-release', '>= 1.0.2', :require => false
gem 'voxpupuli-release', '>= 1.2.0', :require => false
gem 'puppet-strings', '>= 2.2', :require => false
end

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper),
# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper),
# otherwise attempt to load it directly.
begin
require 'voxpupuli/test/rake'
Expand Down
12 changes: 8 additions & 4 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'
# rubocop:disable RSpec/RepeatedExample
# rubocop:disable RSpec/RepeatedExampleGroupBody
describe 'chrony class:' do
it 'works idempotently with no errors' do
pp = <<-EOS
Expand All @@ -20,6 +22,7 @@ class { 'chrony': }
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('chrony-wait.service') do
it { is_expected.not_to be_enabled }
it { is_expected.not_to be_running }
Expand All @@ -29,9 +32,9 @@ class { 'chrony': }
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('chrony-wait.service') do
it { is_expected.not_to be_running }
it { is_expected.not_to be_running }
end

end
Expand All @@ -55,6 +58,7 @@ class { 'chrony':
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('chrony-wait.service') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
Expand All @@ -64,11 +68,11 @@ class { 'chrony':
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('chrony-wait.service') do
it { is_expected.not_to be_running }
it { is_expected.not_to be_running }
end
end
end
end
# rubocop:enable RSpec/RepeatedExample
# rubocop:enable RSpec/RepeatedExampleGroupBody
39 changes: 20 additions & 19 deletions spec/classes/chrony_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require 'spec_helper'

# rubocop:disable RSpec/EmptyExampleGroup
describe 'chrony' do
context 'on any other system' do
let(:facts) do
Expand Down Expand Up @@ -56,6 +59,7 @@
when 'Archlinux'
context 'using defaults' do
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*cmdallow 127\.0\.0\.1$}) }

['0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org', '3.pool.ntp.org'].each do |s|
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*server #{s} iburst$}) }
end
Expand Down Expand Up @@ -85,6 +89,7 @@
without_content(%r{^\s*dumpdir}).
without_content(%r{^\s*\n\s*$})
end

it do
is_expected.to contain_file('/etc/chrony/chrony.keys').
with_mode('0644').
Expand All @@ -99,6 +104,7 @@
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*bindcmdaddress ::1$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*bindcmdaddress 127\.0\.0\.1$}) }
it { is_expected.not_to contain_file('/etc/chrony.conf').with_content(%r{^\s*cmdallow.*$}) }

['0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org', '3.pool.ntp.org'].each do |s|
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*server #{s} iburst$}) }
end
Expand All @@ -117,6 +123,7 @@
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*bindcmdaddress ::1$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*bindcmdaddress 127\.0\.0\.1$}) }
it { is_expected.not_to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*cmdallow.*$}) }

['0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org', '3.pool.ntp.org'].each do |s|
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*server #{s} iburst$}) }
end
Expand Down Expand Up @@ -167,7 +174,7 @@
when 'Archlinux'
context 'with some params passed in' do
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*port 123$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^s*allow 192\.168\/16$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^s*allow 192\.168/16$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*cmdallow 1\.2\.3\.4$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*cmddeny 1\.2\.3$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*cmdallow all 1\.2$}) }
Expand All @@ -194,7 +201,7 @@
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*smoothtime 400 0\.001 leaponly$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*port 123$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*cmdport 257$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^s*allow 192\.168\/16$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^s*allow 192\.168/16$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*bindaddress 10\.0\.0\.1$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*bindaddress ::1$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*initstepslew 600$}) }
Expand Down Expand Up @@ -223,7 +230,7 @@
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*smoothtime 400 0\.001 leaponly$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*port 123$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*cmdport 257$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^s*allow 192\.168\/16$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^s*allow 192\.168/16$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*bindaddress 10\.0\.0\.1$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*bindaddress ::1$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*initstepslew 600$}) }
Expand Down Expand Up @@ -255,6 +262,7 @@
it { is_expected.not_to contain_file('/etc/chrony/chrony.conf').with_content(%r{stratumweight}) }
end
end

context 'when set' do
let(:params) do
{
Expand Down Expand Up @@ -283,6 +291,7 @@
expect(config_file_contents.split("\n") & expected_lines).to eq(expected_lines)
end
end

context 'when servers is an array' do
let(:params) do
{
Expand All @@ -298,6 +307,7 @@
expect(config_file_contents.split("\n") & expected_lines).to eq(expected_lines)
end
end

context 'when servers is an (unsorted) hash' do
let(:params) do
{
Expand Down Expand Up @@ -326,6 +336,7 @@
context 'by default' do
it { expect(config_file_contents).not_to match(%r{^pool}) }
end

context 'when pools is an array' do
let(:params) do
{
Expand All @@ -341,6 +352,7 @@
expect(config_file_contents.split("\n") & expected_lines).to eq(expected_lines)
end
end

context 'when pools is a hash' do
let(:params) do
{
Expand Down Expand Up @@ -369,6 +381,7 @@
context 'by default' do
it { expect(config_file_contents).not_to match(%r{^peer}) }
end

context 'when peers is an array' do
let(:params) do
{
Expand All @@ -384,6 +397,7 @@
expect(config_file_contents.split("\n") & expected_lines).to eq(expected_lines)
end
end

context 'when peers is a hash' do
let(:params) do
{
Expand Down Expand Up @@ -416,12 +430,7 @@

context 'chrony::config' do
case facts[:os]['family']
when 'Archlinux'
context 'unmanaged chrony.keys file' do
it { is_expected.to contain_file('/etc/chrony.keys').with_replace(false) }
it { is_expected.to contain_file('/etc/chrony.keys').with_content(sensitive('')) }
end
when 'RedHat'
when 'Archlinux', 'RedHat'
context 'unmanaged chrony.keys file' do
it { is_expected.to contain_file('/etc/chrony.keys').with_replace(false) }
it { is_expected.to contain_file('/etc/chrony.keys').with_content(sensitive('')) }
Expand Down Expand Up @@ -488,16 +497,7 @@
end

case facts[:os]['family']
when 'Archlinux'
context 'using defaults' do
it do
is_expected.to contain_service('chronyd').with(
ensure: 'running',
enable: true
)
end
end
when 'RedHat', 'Gentoo'
when 'Archlinux', 'RedHat', 'Gentoo'
context 'using defaults' do
it do
is_expected.to contain_service('chronyd').with(
Expand Down Expand Up @@ -585,3 +585,4 @@
end
end
end
# rubocop:enable RSpec/EmptyExampleGroup
10 changes: 5 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

Expand All @@ -7,15 +9,13 @@

# puppetlabs_spec_helper will set up coverage if the env variable is set.
# We want to do this if lib exists and it hasn't been explicitly set.
ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__))
ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__))

require 'voxpupuli/test/spec_helper'

if File.exist?(File.join(__dir__, 'default_module_facts.yml'))
facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml')))
if facts
facts.each do |name, value|
add_custom_fact name.to_sym, value
end
facts&.each do |name, value|
add_custom_fact name.to_sym, value
end
end
2 changes: 2 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'voxpupuli/acceptance/spec_helper_acceptance'

configure_beaker
2 changes: 2 additions & 0 deletions spec/type_aliases/servers_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'Chrony::Servers' do
Expand Down

0 comments on commit b47052f

Please sign in to comment.