Skip to content
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

Validate ntp paths #25

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
9 changes: 5 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
$default_service_name = 'ntp'
$default_config_file = '/etc/ntp.conf'
$default_driftfile = '/var/lib/ntp/ntp.drift'
$step_tickers_enable = true
$step_tickers_enable = false

case $::lsbmajdistrelease {
'9','10': {
Expand All @@ -147,7 +147,7 @@
'solaris': {
case $::kernelrelease {
'5.9','5.10': {
$default_package_name = [ 'SUNWntp4r', 'SUNWntp4u' ]
$default_package_name = [ 'SUNWntpr' ]
Copy link
Owner

Choose a reason for hiding this comment

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

You are correct that it will complain, since it will needed different values for source and adminfile. We are lucky here that there is only one package, which prevents us from having to put in more complicated logic.

We might want to ensure that the type is a string for solaris or that the array only has one element.

}
'5.11': {
$default_package_name = [ 'network/ntp' ]
Expand All @@ -159,7 +159,7 @@
$default_package_noop = true
$default_package_source = '/var/spool/pkg'
$default_package_adminfile = '/var/sadm/install/admin/puppet-ntp'
$default_service_name = 'ntp4'
$default_service_name = 'ntp'
$default_config_file = '/etc/inet/ntp.conf'
$default_driftfile = '/var/ntp/ntp.drift'
$step_tickers_enable = false
Expand Down Expand Up @@ -253,7 +253,7 @@
owner => 'root',
group => 'root',
mode => '0644',
source => 'puppet:///files/ntp/admin_file',
content => template('ntp/admin_file.erb'),
}
}

Expand All @@ -275,6 +275,7 @@
require => Package['ntp_package'],
}


file { 'step-tickers':
ensure => $step_tickers_ensure_real,
path => $step_tickers_path,
Expand Down
17 changes: 4 additions & 13 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
it {
should contain_service('ntp_service').with({
'ensure' => 'running',
'name' => 'ntp4',
'name' => 'ntp',
'enable' => 'true',
})
}
Expand Down Expand Up @@ -234,11 +234,8 @@

it {
should contain_file('step-tickers').with({
'ensure' => 'present',
'ensure' => 'absent',
'path' => '/etc/ntp/step-tickers',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
should contain_file('ntp_conf').with_content(/server 0.us.pool.ntp.org\nserver 1.us.pool.ntp.org\nserver 2.us.pool.ntp.org/)
}
Expand Down Expand Up @@ -286,11 +283,8 @@

it {
should contain_file('step-tickers').with({
'ensure' => 'present',
'ensure' => 'absent',
'path' => '/etc/ntp/step-tickers',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
should contain_file('ntp_conf').with_content(/server 0.us.pool.ntp.org\nserver 1.us.pool.ntp.org\nserver 2.us.pool.ntp.org/)
}
Expand Down Expand Up @@ -338,11 +332,8 @@

it {
should contain_file('step-tickers').with({
'ensure' => 'present',
'ensure' => 'absent',
'path' => '/etc/ntp/step-tickers',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
should contain_file('ntp_conf').with_content(/server 0.us.pool.ntp.org\nserver 1.us.pool.ntp.org\nserver 2.us.pool.ntp.org/)
}
Expand Down
14 changes: 14 additions & 0 deletions templates/admin_file.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
instance=overwrite
partial=nocheck
runlevel=nocheck
idepend=nocheck
rdepend=nocheck
space=nocheck
setuid=nocheck
conflict=nocheck
action=nocheck
networktimeout=60
networkretries=3
authentication=quit
keystore=/var/sadm/security
Copy link
Owner

Choose a reason for hiding this comment

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

is this a solaris default or an Ericsson specifc thing?

Copy link
Author

Choose a reason for hiding this comment

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

It is not real an Ericsson specific thing - but Solaris default, The default admin file = /var/sadm/install/admin/default also lists keystore=/var/sadm/security as the keystore directory - however, the default admin file causes interactive installation.

ref:
http://docs.oracle.com/cd/E19082-01/819-2379/swmgrpkgs-19113/index.html

basedir=default
9 changes: 9 additions & 0 deletions templates/ntp.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,16 @@ fudge 127.127.1.0 stratum <%= @fudge_stratum %>

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.

<% if @operatingsystem !~ /SLE[DS]/ -%>
keys /etc/ntp/keys
<% end -%>

<% if @operatingsystem =~ /SLE[DS]/ -%>
#Failing because of a bug - when key is set,
#need to figure out how to get it fixed
#keys /etc/ntp.keys
Copy link
Author

Choose a reason for hiding this comment

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

SuSE stores its keys in /etc/ntp.keys - but it seems to fail by default when keys /etc/ntp/keys are specified in /etc/ntp.conf

Copy link
Owner

Choose a reason for hiding this comment

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

Well that makes sense. We are looking in the wrong place. Make the path for /etc/ntp/keys a variable.

<% end -%>

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
Expand Down