Skip to content

Work for SLES 12 compatibility #312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ Tells Puppet whether to manage the NTP service. Valid options: 'true' or 'false'

Tells Puppet what NTP service to manage. Valid options: string. Default value: varies by operating system

####`service_provider`

Tells Puppet which service provider to use for NTP. Valid options: string. Default value: 'undef'

####`stepout`

Tells puppet to change stepout. Applies only if `tinker` value is 'true'. Valid options: unsigned shortint digit. Default value: undef.
Expand Down
7 changes: 7 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Private Class
class ntp::config inherits ntp {

#The servers-netconfig file overrides NTP config on SLES 12, interfering with our configuration.
if $::operatingsystem == 'SLES' and $::operatingsystemmajrelease == '12' {
file { '/var/run/ntp/servers-netconfig':
ensure => 'absent'
}
}

if $ntp::keys_enable {
case $ntp::config_dir {
'/', '/etc', undef: {}
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
$service_ensure = $ntp::params::service_ensure,
$service_manage = $ntp::params::service_manage,
$service_name = $ntp::params::service_name,
$service_provider = $ntp::params::service_provider,
$stepout = $ntp::params::stepout,
$tinker = $ntp::params::tinker,
$tos = $ntp::params::tos,
Expand Down
15 changes: 15 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
'3.debian.pool.ntp.org',
]
$maxpoll = undef
$service_provider= undef
}
'Debian': {
$config = $default_config
Expand All @@ -98,6 +99,7 @@
'3.debian.pool.ntp.org',
]
$maxpoll = undef
$service_provider= undef
}
'RedHat': {
$config = $default_config
Expand All @@ -106,6 +108,7 @@
$package_name = $default_package_name
$service_name = $default_service_name
$maxpoll = undef
$service_provider= undef

case $::operatingsystem {
'Fedora': {
Expand Down Expand Up @@ -146,23 +149,28 @@
$service_name = 'ntp'
$keys_file = '/etc/ntp.keys'
$package_name = [ 'xntp' ]
$service_provider = undef
}
'11': {
$service_name = 'ntp'
$keys_file = $default_keys_file
$package_name = $default_package_name
$service_provider = undef
}
'12': {
$service_name = 'ntpd'
$keys_file = '/etc/ntp.keys'
$package_name = $default_package_name
#Puppet 3 does not recognise systemd as service provider on SLES 12.
$service_provider = 'systemd'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal preference: I'd prefer the $service_provider to be set more explicitly... so it should be set to undef on all of the other cases. Similar to how $maxpoll is handled. It's pretty obvious to the majority of people reading the code that $service_provider should be undef in all platforms != SLES12, but it doesn't hurt to be explicit IMO.

}
default: {
fail("The ${module_name} module is not supported on an ${::operatingsystem} ${::operatingsystemmajrelease} distribution.")
}
}
}
'OpenSuSE': {
$service_provider = undef
case $::operatingsystemrelease {
'13.2': {
$service_name = 'ntpd'
Expand All @@ -180,6 +188,7 @@
$service_name = 'ntp'
$keys_file = $default_keys_file
$package_name = $default_package_name
$service_provider = undef
}
}
$config = $default_config
Expand Down Expand Up @@ -219,6 +228,7 @@
'3.freebsd.pool.ntp.org',
]
$maxpoll = 9
$service_provider= undef
}
'Archlinux': {
$config = $default_config
Expand All @@ -240,6 +250,7 @@
'3.arch.pool.ntp.org',
]
$maxpoll = undef
$service_provider= undef
}
'Solaris': {
$config = '/etc/inet/ntp.conf'
Expand Down Expand Up @@ -272,6 +283,7 @@
'3.pool.ntp.org',
]
$maxpoll = undef
$service_provider= undef
}
# Gentoo was added as its own $::osfamily in Facter 1.7.0
'Gentoo': {
Expand All @@ -294,6 +306,7 @@
'3.gentoo.pool.ntp.org',
]
$maxpoll = undef
$service_provider= undef
}
'Linux': {
# Account for distributions that don't have $::osfamily specific settings.
Expand All @@ -319,6 +332,7 @@
'3.gentoo.pool.ntp.org',
]
$maxpoll = undef
$service_provider= undef
}
'Amazon': {
$config = $default_config
Expand All @@ -339,6 +353,7 @@
'2.centos.pool.ntp.org',
]
$maxpoll = undef
$service_provider= undef
$disable_monitor = false
}
default: {
Expand Down
1 change: 1 addition & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ensure => $ntp::service_ensure,
enable => $ntp::service_enable,
name => $ntp::service_name,
provider => $ntp::service_provider,
hasstatus => true,
hasrestart => true,
}
Expand Down
29 changes: 15 additions & 14 deletions spec/classes/ntp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@
describe 'ntp' do
let(:facts) {{ :is_virtual => 'false' }}

['Debian', 'RedHat', 'Fedora', 'Suse', 'FreeBSD', 'Archlinux', 'Gentoo', 'Gentoo (Facter < 1.7)'].each do |system|
['Debian', 'RedHat', 'Fedora', 'Suse11', 'Suse12', 'FreeBSD', 'Archlinux', 'Gentoo', 'Gentoo (Facter < 1.7)'].each do |system|
context "when on system #{system}" do
if system == 'Gentoo (Facter < 1.7)'
let :facts do
let :facts do
case system
when 'Gentoo (Facter < 1.7)'
super().merge({ :osfamily => 'Linux', :operatingsystem => 'Gentoo' })
end
elsif system == 'Suse'
let :facts do
super().merge({ :osfamily => system,:operatingsystem => 'SLES',:operatingsystemmajrelease => '11' })
end
elsif system == 'Fedora'
let :facts do
super().merge({ :osfamily => 'RedHat', :operatingsystem => system ,:operatingsystemmajrelease => '22' })
end
else
let :facts do
when 'Suse11'
super().merge({ :osfamily => 'Suse', :operatingsystem => 'SLES', :operatingsystemmajrelease => '11' })
when 'Suse12'
super().merge({ :osfamily => 'Suse', :operatingsystem => 'SLES', :operatingsystemmajrelease => '12' })
when 'Fedora'
super().merge({ :osfamily => 'RedHat', :operatingsystem => system, :operatingsystemmajrelease => '22' })
else
super().merge({ :osfamily => system })
end
end
Expand All @@ -32,6 +29,10 @@
it { should contain_file('/etc/ntp.conf').with_group('0') }
it { should contain_file('/etc/ntp.conf').with_mode('0644') }

if system == 'Suse12'
it { should contain_file('/var/run/ntp/servers-netconfig').with_ensure_absent }
end

describe 'allows template to be overridden' do
let(:params) {{ :config_template => 'my_ntp/ntp.conf.erb' }}
it { should contain_file('/etc/ntp.conf').with({
Expand Down