From 930066d537bf66bfac13982aa7e680d58088208e Mon Sep 17 00:00:00 2001 From: Derek McEachern Date: Tue, 24 Jun 2014 13:09:16 -0500 Subject: [PATCH 1/7] (MODULES-213) Add support for Solaris Added Solaris section to params.pp. In Solaris there are two packages to install to support ntp, SUNWntpr and SUNWntpu. (Root and User packages.) Adding two files to the $package_name array caused the install class to fail so install.pp was updated so that the $package_name was the resouce title instead of the name attribute. This change assumes that the packages are already installed. If they are not then this will fail. --- manifests/install.pp | 3 +-- manifests/params.pp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 098949c3..237f4c1c 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,9 +1,8 @@ # class ntp::install inherits ntp { - package { 'ntp': + package { $package_name: ensure => $package_ensure, - name => $package_name, } } diff --git a/manifests/params.pp b/manifests/params.pp index 8bd9127e..0a645562 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -131,6 +131,25 @@ '2.pool.ntp.org', ] } + 'Solaris': { + $config = '/etc/inet/ntp.conf' + $driftfile = '/var/ntp/ntp.drift' + $keys_file = '/etc/inet/ntp.keys' + $package_name = [ 'SUNWntpr', 'SUNWntpu' ] + $restrict = [ + 'default kod nomodify notrap nopeer noquery', + '-6 default kod nomodify notrap nopeer noquery', + '127.0.0.1', + '-6 ::1', + ] + $service_name = 'network/ntp' + $servers = [ + '0.solaris.pool.ntp.org', + '1.solaris.pool.ntp.org', + '2.solaris.pool.ntp.org', + '3.solaris.pool.ntp.org', + ] + } # Gentoo was added as its own $::osfamily in Facter 1.7.0 'Gentoo': { $config = '/etc/ntp.conf' From 1a1bed20ef47c96d1ec8905ca4dae64a7a08a21e Mon Sep 17 00:00:00 2001 From: Derek McEachern Date: Wed, 25 Jun 2014 15:18:27 -0500 Subject: [PATCH 2/7] Updating test cases for Solaris and Change to init.pp. --- spec/acceptance/ntp_config_spec.rb | 2 ++ spec/acceptance/ntp_install_spec.rb | 2 ++ spec/acceptance/ntp_parameters_spec.rb | 5 +++-- spec/acceptance/ntp_service_spec.rb | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/ntp_config_spec.rb b/spec/acceptance/ntp_config_spec.rb index 196ba765..13e923b1 100644 --- a/spec/acceptance/ntp_config_spec.rb +++ b/spec/acceptance/ntp_config_spec.rb @@ -18,6 +18,8 @@ when 'Gentoo' line = '0.gentoo.pool.ntp.org' end +when 'Solaris' + line = '0.solaris.pool.ntp.org' when 'AIX' line = '0.debian.pool.ntp.org iburst' end diff --git a/spec/acceptance/ntp_install_spec.rb b/spec/acceptance/ntp_install_spec.rb index 1a451bbb..c90feb9a 100644 --- a/spec/acceptance/ntp_install_spec.rb +++ b/spec/acceptance/ntp_install_spec.rb @@ -14,6 +14,8 @@ end when 'AIX' packagename = 'bos.net.tcp.client' +when 'Solaris' + packagename = 'SUNWntpr' else packagename = 'ntp' end diff --git a/spec/acceptance/ntp_parameters_spec.rb b/spec/acceptance/ntp_parameters_spec.rb index 48e6cfdf..d1f6a3ca 100644 --- a/spec/acceptance/ntp_parameters_spec.rb +++ b/spec/acceptance/ntp_parameters_spec.rb @@ -14,6 +14,8 @@ end when 'AIX' packagename = 'bos.net.tcp.client' +when 'Solaris' + packagename = 'SUNWntpr' else packagename = 'ntp' end @@ -107,9 +109,8 @@ class { 'ntp': describe 'package' do it 'installs the right package' do pp = <<-EOS - class { 'ntp': + class { ['#{packagename}']: package_ensure => present, - package_name => ['#{packagename}'], } EOS apply_manifest(pp, :catch_failures => true) diff --git a/spec/acceptance/ntp_service_spec.rb b/spec/acceptance/ntp_service_spec.rb index cac12de5..83c27975 100644 --- a/spec/acceptance/ntp_service_spec.rb +++ b/spec/acceptance/ntp_service_spec.rb @@ -3,6 +3,8 @@ case fact('osfamily') when 'RedHat', 'FreeBSD', 'Linux', 'Gentoo' servicename = 'ntpd' +when 'Solaris' + servicename = 'network/ntp' when 'AIX' servicename = 'xntpd' else From 87ec0497b7ac4595d152307ea8dee52d295963dd Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 25 Jun 2014 16:00:17 -0700 Subject: [PATCH 3/7] Use standard ntp pool servers --- manifests/params.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 0a645562..960fb5fd 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -144,10 +144,10 @@ ] $service_name = 'network/ntp' $servers = [ - '0.solaris.pool.ntp.org', - '1.solaris.pool.ntp.org', - '2.solaris.pool.ntp.org', - '3.solaris.pool.ntp.org', + '0.pool.ntp.org', + '1.pool.ntp.org', + '2.pool.ntp.org', + '3.pool.ntp.org', ] } # Gentoo was added as its own $::osfamily in Facter 1.7.0 From 78d1be117a2759762b981d603254d03607b82584 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 25 Jun 2014 16:00:34 -0700 Subject: [PATCH 4/7] Update package name tests --- spec/classes/ntp_spec.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb index 49d6712b..e431975e 100644 --- a/spec/classes/ntp_spec.rb +++ b/spec/classes/ntp_spec.rb @@ -100,8 +100,7 @@ let(:params) {{ :package_ensure => 'present', :package_name => ['ntp'], }} it { should contain_package('ntp').with( - :ensure => 'present', - :name => 'ntp' + :ensure => 'present' )} describe 'should allow package ensure to be overridden' do @@ -111,7 +110,7 @@ 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') } + it { should contain_package('hambaby') } end end @@ -229,6 +228,16 @@ end end + describe "on osfamily Solaris" do + let(:facts) {{ :osfamily => 'Solaris' }} + + it 'uses the NTP pool servers by default' do + should contain_file('/etc/inet/ntp.conf').with({ + 'content' => /server \d.pool.ntp.org/, + }) + end + end + describe "for operating system family unsupported" do let(:facts) {{ :osfamily => 'unsupported', From bdc958eca6ca744c4f0a7bd51476cf2438955040 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 25 Jun 2014 16:02:03 -0700 Subject: [PATCH 5/7] Add solaris to metadata --- metadata.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/metadata.json b/metadata.json index 8d4f7392..a5bddf12 100644 --- a/metadata.json +++ b/metadata.json @@ -50,6 +50,12 @@ "14.04" ] }, + { + "operatingsystem": "Solaris", + "operatingsystemrelease": [ + "10" + ] + }, { "operatingsystem": "AIX", "operatingsystemrelease": [ From f7d6f37141db23c9207662aaac195a62223970c7 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 25 Jun 2014 16:06:54 -0700 Subject: [PATCH 6/7] Update readme --- README.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.markdown b/README.markdown index 7d96b145..ac0fc2f8 100644 --- a/README.markdown +++ b/README.markdown @@ -210,6 +210,8 @@ The module has been tested on: * Gentoo * Arch Linux * FreeBSD +* Solaris 10 +* AIX 5.3, 6.1, 7.1 Testing on other platforms has been light and cannot be guaranteed. From 66e0c92ae78ebfeeebcd04109ff166906b66c35d Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 25 Jun 2014 16:16:51 -0700 Subject: [PATCH 7/7] Update beaker tests --- spec/acceptance/ntp_config_spec.rb | 2 +- spec/acceptance/ntp_install_spec.rb | 8 +++++--- spec/acceptance/ntp_parameters_spec.rb | 11 +++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/spec/acceptance/ntp_config_spec.rb b/spec/acceptance/ntp_config_spec.rb index 13e923b1..c31e5e3d 100644 --- a/spec/acceptance/ntp_config_spec.rb +++ b/spec/acceptance/ntp_config_spec.rb @@ -19,7 +19,7 @@ line = '0.gentoo.pool.ntp.org' end when 'Solaris' - line = '0.solaris.pool.ntp.org' + line = '0.pool.ntp.org' when 'AIX' line = '0.debian.pool.ntp.org iburst' end diff --git a/spec/acceptance/ntp_install_spec.rb b/spec/acceptance/ntp_install_spec.rb index c90feb9a..aff37558 100644 --- a/spec/acceptance/ntp_install_spec.rb +++ b/spec/acceptance/ntp_install_spec.rb @@ -15,7 +15,7 @@ when 'AIX' packagename = 'bos.net.tcp.client' when 'Solaris' - packagename = 'SUNWntpr' + packagename = ['SUNWntpr','SUNWntpu'] else packagename = 'ntp' end @@ -27,7 +27,9 @@ class { 'ntp': } }, :catch_failures => true) end - describe package(packagename) do - it { should be_installed } + Array(packagename).each do |package| + describe package(package) do + it { should be_installed } + end end end diff --git a/spec/acceptance/ntp_parameters_spec.rb b/spec/acceptance/ntp_parameters_spec.rb index d1f6a3ca..95a9c584 100644 --- a/spec/acceptance/ntp_parameters_spec.rb +++ b/spec/acceptance/ntp_parameters_spec.rb @@ -15,7 +15,7 @@ when 'AIX' packagename = 'bos.net.tcp.client' when 'Solaris' - packagename = 'SUNWntpr' + packagename = ['SUNWntpr','SUNWntpu'] else packagename = 'ntp' end @@ -109,15 +109,18 @@ class { 'ntp': describe 'package' do it 'installs the right package' do pp = <<-EOS - class { ['#{packagename}']: + class { 'ntp': package_ensure => present, + package_name => #{Array(packagename).inspect}, } EOS apply_manifest(pp, :catch_failures => true) end - describe package(packagename) do - it { should be_installed } + Array(packagename).each do |package| + describe package(package) do + it { should be_installed } + end end end