Skip to content

Commit

Permalink
Merge pull request #135 from kenyon/hiera-data
Browse files Browse the repository at this point in the history
  • Loading branch information
kenyon authored Dec 25, 2021
2 parents b47052f + c155137 commit 847e993
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 110 deletions.
9 changes: 9 additions & 0 deletions data/Archlinux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
chrony::clientlog: true
chrony::cmdacl:
- cmdallow 127.0.0.1
chrony::config_keys_mode: '0644'
chrony::config_keys: /etc/chrony.keys
chrony::config: /etc/chrony.conf
chrony::dumpdir: /var/lib/chrony
chrony::rtconutc: true
5 changes: 5 additions & 0 deletions data/Gentoo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
chrony::clientlog: true
chrony::config_keys_mode: '0644'
chrony::package_name: net-misc/chrony
chrony::rtconutc: true
5 changes: 5 additions & 0 deletions data/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
chrony::config_keys_group: chrony
chrony::config_keys: /etc/chrony.keys
chrony::config: /etc/chrony.conf
chrony::wait_manage: true
5 changes: 5 additions & 0 deletions data/Suse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
chrony::config_keys_group: chrony
chrony::config_keys: /etc/chrony.keys
chrony::config: /etc/chrony.conf
chrony::wait_manage: true
7 changes: 7 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 5

hierarchy:
- name: OS family
paths:
- '%{facts.os.family}.yaml'
26 changes: 13 additions & 13 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,24 @@
Array[Stdlib::IP::Address] $bindaddress = [],
Array[String] $bindcmdaddress = ['127.0.0.1', '::1'],
Optional[String] $initstepslew = undef,
Array[String] $cmdacl = $chrony::params::cmdacl,
Array[String] $cmdacl = [],
Optional[Stdlib::Port] $cmdport = undef,
$commandkey = 0,
Stdlib::Unixpath $config = $chrony::params::config,
Stdlib::Unixpath $config = '/etc/chrony/chrony.conf',
String[1] $config_template = 'chrony/chrony.conf.epp',
Stdlib::Unixpath $config_keys = $chrony::params::config_keys,
Stdlib::Unixpath $config_keys = '/etc/chrony/chrony.keys',
String[1] $config_keys_template = 'chrony/chrony.keys.epp',
String[1] $chrony_password = 'xyzzy',
Variant[Integer[0],String[1]] $config_keys_owner = $chrony::params::config_keys_owner,
Variant[Integer[0],String[1]] $config_keys_group = $chrony::params::config_keys_group,
Stdlib::Filemode $config_keys_mode = $chrony::params::config_keys_mode,
Variant[Integer[0],String[1]] $config_keys_owner = 0,
Variant[Integer[0],String[1]] $config_keys_group = 0,
Stdlib::Filemode $config_keys_mode = '0640',
Boolean $config_keys_manage = true,
Array[String[1]] $keys = [],
Stdlib::Unixpath $driftfile = '/var/lib/chrony/drift',
Variant[Boolean[false],Integer[1,15]] $local_stratum = 10,
Optional[String[1]] $log_options = undef,
String[1] $package_ensure = 'present',
String[1] $package_name = $chrony::params::package_name,
String[1] $package_name = 'chrony',
Optional[String] $package_source = undef,
Optional[String] $package_provider = undef,
$refclocks = [],
Expand All @@ -243,15 +243,15 @@
Float $threshold = 0.5,
Boolean $lock_all = false,
Optional[Stdlib::Port] $port = undef,
Boolean $clientlog = $chrony::params::clientlog,
Boolean $clientlog = false,
Optional[Integer] $clientloglimit = undef,
Boolean $service_enable = true,
Stdlib::Ensure::Service $service_ensure = 'running',
Boolean $service_manage = true,
String[1] $service_name = $chrony::params::service_name,
String[1] $service_name = 'chronyd',
Boolean $wait_enable = false,
Stdlib::Ensure::Service $wait_ensure = 'stopped',
Boolean $wait_manage = $chrony::params::wait_manage,
Boolean $wait_manage = false,
String[1] $wait_name = 'chrony-wait.service',
Optional[String] $smoothtime = undef,
Optional[Enum['system', 'step', 'slew', 'ignore']] $leapsecmode = undef,
Expand All @@ -261,10 +261,10 @@
Optional[Float] $maxupdateskew = undef,
Optional[Numeric] $stratumweight = undef,
Boolean $rtcsync = true,
Boolean $rtconutc = $chrony::params::rtconutc,
Boolean $rtconutc = false,
Variant[Hash,Array[String]] $hwtimestamps = [],
Optional[Stdlib::Unixpath] $dumpdir = $chrony::params::dumpdir,
) inherits chrony::params {
Optional[Stdlib::Unixpath] $dumpdir = undef,
) {
if ! $config_keys_manage and $chrony_password != 'unset' {
fail("Setting \$config_keys_manage false and \$chrony_password at same time in ${module_name} is not possible.")
}
Expand Down
67 changes: 0 additions & 67 deletions manifests/params.pp

This file was deleted.

37 changes: 7 additions & 30 deletions spec/classes/chrony_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@

# rubocop:disable RSpec/EmptyExampleGroup
describe 'chrony' do
context 'on any other system' do
let(:facts) do
{
os: { family: 'UnsupportedOS' }
}
end

it { is_expected.to raise_error(%r{The chrony module is not supported on an UnsupportedOS based system\.}) }
end

on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
Expand Down Expand Up @@ -42,7 +32,6 @@
context 'with defaults' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('chrony') }
it { is_expected.to contain_class('chrony::params') }
it { is_expected.to contain_class('chrony::install').that_comes_before('Class[chrony::config]') }
it { is_expected.to contain_class('chrony::config').that_notifies('Class[chrony::service]') }
it { is_expected.to contain_class('chrony::service') }
Expand Down Expand Up @@ -470,7 +459,7 @@
end

context 'chrony::service' do
let :params do
let(:params) do
{
service_ensure: 'running',
service_enable: true,
Expand All @@ -496,24 +485,12 @@
end
end

case facts[:os]['family']
when 'Archlinux', 'RedHat', 'Gentoo'
context 'using defaults' do
it do
is_expected.to contain_service('chronyd').with(
ensure: 'running',
enable: true
)
end
end
when 'Debian'
context 'using defaults' do
it do
is_expected.to contain_service('chrony').with(
ensure: 'running',
enable: true
)
end
context 'using defaults' do
it do
is_expected.to contain_service('chronyd').with(
ensure: 'running',
enable: true
)
end
end
end
Expand Down

0 comments on commit 847e993

Please sign in to comment.