Skip to content

Commit

Permalink
Merge pull request #293 from raphink/dev/dhclient_conf
Browse files Browse the repository at this point in the history
Add disable_dhclient parameter
  • Loading branch information
tphoney committed Sep 8, 2015
2 parents dfa496a + 84e60d0 commit 1b57d27
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
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

0 comments on commit 1b57d27

Please sign in to comment.