Skip to content

Commit

Permalink
Merge pull request theforeman#58 from treydock/dnskeyname-parameter
Browse files Browse the repository at this point in the history
Add dnskeyname parameter
  • Loading branch information
hunner committed Apr 2, 2015
2 parents 92f20d7 + d9b5df2 commit 6b2f888
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ Define the server and the zones it will be responsible for.
nameservers => ['10.0.1.20'],
ntpservers => ['us.pool.ntp.org'],
interfaces => ['eth0'],
dnsupdatekey => "/etc/bind/keys.d/$ddnskeyname",
require => Bind::Key[ $ddnskeyname ],
dnsupdatekey => '/etc/bind/keys.d/rndc.key',
dnskeyname => 'rndc-key',
require => Bind::Key['rndc-key'],
pxeserver => '10.0.1.50',
pxefilename => 'pxelinux.0',
}
Expand Down
9 changes: 9 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
$interfaces = undef,
$interface = 'NOTSET',
$dnsupdatekey = undef,
$dnskeyname = undef,
$pxeserver = undef,
$pxefilename = undef,
$logfacility = 'daemon',
Expand Down Expand Up @@ -55,6 +56,14 @@
$dhcp_interfaces = $interfaces
}

if $dnsupdatekey {
$_dnsupdatekey_split = split($dnsupdatekey, '[/]')
$_dnsupdatekey_basename = $_dnsupdatekey_split[-1]
$_dnskeyname = pick($dnskeyname, $_dnsupdatekey_basename)
} else {
$_dnskeyname = $dnskeyname
}

# JJM Decide where to pull the fragment content from. Either this module, or
# from the end user. This makes the module much more re-usable by 3rd
# parties without modifying the module itself.
Expand Down
54 changes: 54 additions & 0 deletions spec/classes/dhcp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,60 @@
it {should contain_file(files)}
end
end
context 'ddns' do
let :params do
default_params.merge({
:interface => 'eth0',
})
end

it do
should contain_concat__fragment('dhcp-conf-ddns').with_content(/^ddns-update-style none;$/)
end

context 'dnsupdatekey defined' do
let :params do
default_params.merge({
:interface => 'eth0',
:dnsupdatekey => '/etc/rndc.key',
})
end

it do
content = subject.resource('concat::fragment', 'dhcp-conf-ddns').send(:parameters)[:content]
expected_lines = [
'ddns-updates on;',
'ddns-update-style interim;',
'update-static-leases on;',
'use-host-decl-names on;',
'include "/etc/rndc.key";',
"zone #{params['dnsdomain'].first}. {",
" primary #{params['nameservers'].first};",
' key rndc.key;',
'}',
"zone #{params['dnsdomain'].last}. {",
" primary #{params['nameservers'].first};",
' key rndc.key;',
'}',
]
expect(content.split("\n").reject {|l| l =~ /^#|^$/ }).to eq(expected_lines)
end

context 'dnskeyname defined' do
let :params do
default_params.merge({
:interface => 'eth0',
:dnsupdatekey => '/etc/rndc.key',
:dnskeyname => 'rndc-key',
})
end

it do
should contain_concat__fragment('dhcp-conf-ddns').with_content(/^ key rndc-key;$/)
end
end
end
end
end
context 'on a Dawin OS' do
let :facts do
Expand Down
2 changes: 1 addition & 1 deletion templates/dhcpd.conf.ddns.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include "<%= @dnsupdatekey %>";
<% @dnsdomain_real.each do |dom| -%>
zone <%= dom %>. {
primary <%= @nameservers.first %>;
key <%= @dnsupdatekey.split('/').last %>;
key <%= @_dnskeyname %>;
}
<% end -%>
<% else -%>
Expand Down

0 comments on commit 6b2f888

Please sign in to comment.