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

Add disable_dhclient parameter #293

Merged
merged 3 commits into from
Sep 8, 2015
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
5 changes: 5 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ client and symmetric passive associations.

Disable kernel time discipline.

####`disable_dhclient`

Disables `ntp-servers` in `dhclient.conf` to avoid Dhclient from managing
the NTP configuration.

####`disable_monitor`

Disables the monitoring facility in NTP. Valid options: 'true' or 'false'. Default value: 'false'
Expand Down
10 changes: 10 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@
}
}

if $ntp::disable_dhclient {
augeas { 'disable ntp-servers in dhclient.conf':
context => '/files/etc/dhcp/dhclient.conf',
changes => 'rm request/*[.="ntp-servers"]',
}

file { '/var/lib/ntp/ntp.conf.dhcp':
ensure => absent,
}
}
}
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$config = $ntp::params::config,
$config_template = $ntp::params::config_template,
$disable_auth = $ntp::params::disable_auth,
$disable_dhclient = $ntp::params::disable_dhclient,
$disable_kernel = $ntp::params::disable_kernel,
$disable_monitor = $ntp::params::disable_monitor,
$fudge = $ntp::params::fudge,
Expand Down Expand Up @@ -47,6 +48,7 @@
validate_absolute_path($config)
validate_string($config_template)
validate_bool($disable_auth)
validate_bool($disable_dhclient)
validate_bool($disable_kernel)
validate_bool($disable_monitor)
validate_absolute_path($driftfile)
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
$tos_floor = '1'
$tos_ceiling = '15'
$tos_cohort = '0'
$disable_dhclient = false

# Allow a list of fudge options
$fudge = []
Expand Down
26 changes: 26 additions & 0 deletions spec/classes/ntp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,32 @@
end
end
end
describe 'with parameter disable_dhclient' do
context 'when set to true' do
let(:params) {{
:disable_dhclient => true,
}}

it 'should contain disable ntp-servers setting' do
should contain_augeas('disable ntp-servers in dhclient.conf')
end
it 'should contain dhcp file' do
should contain_file('/var/lib/ntp/ntp.conf.dhcp').with_ensure('absent')
end
end
context 'when set to false' do
let(:params) {{
:disable_dhclient => false,
}}

it 'should not contain disable ntp-servers setting' do
should_not contain_augeas('disable ntp-servers in dhclient.conf')
end
it 'should not contain dhcp file' do
should_not contain_file('/var/lib/ntp/ntp.conf.dhcp').with_ensure('absent')
end
end
end
describe 'with parameter disable_kernel' do
context 'when set to true' do
let(:params) {{
Expand Down