Skip to content

Commit

Permalink
Merge pull request voxpupuli#120 from aquister/nameservers_ipv6
Browse files Browse the repository at this point in the history
support for IPv6 nameservers
  • Loading branch information
jyaworski authored Nov 3, 2016
2 parents 8c05eb4 + 9c27d7d commit 3ada084
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class dhcp (
$dnsdomain = undef,
$nameservers = [ '8.8.8.8', '8.8.4.4' ],
$nameservers_ipv6 = [],
$ntpservers = [],
$dnssearchdomains = [],
$dhcp_conf_header = 'INTERNAL_TEMPLATE',
Expand Down Expand Up @@ -57,6 +58,7 @@
validate_array($dnssearchdomains)

validate_array($nameservers)
validate_array($nameservers_ipv6)
validate_array($ntpservers)
validate_bool($authoritative)

Expand Down
21 changes: 11 additions & 10 deletions manifests/pool.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
define dhcp::pool (
$network,
$mask,
$gateway = '',
$range = '',
$failover = '',
$options = '',
$parameters = '',
$nameservers = undef,
$pxeserver = undef,
$mtu = undef,
$domain_name = '',
$ignore_unknown = undef,
$gateway = '',
$range = '',
$failover = '',
$options = '',
$parameters = '',
$nameservers = undef,
$nameservers_ipv6 = undef,
$pxeserver = undef,
$mtu = undef,
$domain_name = '',
$ignore_unknown = undef,
) {
if $mtu {
validate_integer($mtu)
Expand Down
3 changes: 3 additions & 0 deletions spec/classes/dhcp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
'dnsdomain' => ['sampledomain.com', '1.1.1.in-addr.arpa'],
'nameservers' => ['1.1.1.1'],
'nameservers_ipv6' => ['1:5ee:bad::c0de'],
'dhcp_conf_header' => 'INTERNAL_TEMPLATE',
'dhcp_conf_ddns' => 'INTERNAL_TEMPLATE',
'dhcp_conf_pxe' => 'INTERNAL_TEMPLATE',
Expand Down Expand Up @@ -185,10 +186,12 @@
'include "/etc/rndc.key";',
"zone #{params['dnsdomain'].first}. {",
" primary #{params['nameservers'].first};",
" primary6 #{params['nameservers_ipv6'].first};",
' key rndc.key;',
'}',
"zone #{params['dnsdomain'].last}. {",
" primary #{params['nameservers'].first};",
" primary6 #{params['nameservers_ipv6'].first};",
' key rndc.key;',
'}'
]
Expand Down
5 changes: 5 additions & 0 deletions templates/dhcpd.conf-header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ log-facility <%= @logfacility %>;
# Options
# ----------
option domain-name "<%= @dnsdomain_real.first %>";
<% if @nameservers && !@nameservers.empty? -%>
option domain-name-servers <%= @nameservers.join(', ') %>;
<% end -%>
<% if @nameservers_ipv6 && !@nameservers_ipv6.empty? -%>
option dhcp6.name-servers <%= @nameservers_ipv6.join(', ') %>;
<% end -%>
<% if @dnssearchdomains && !@dnssearchdomains.empty? -%>
option domain-search "<%= @dnssearchdomains.join('", "') %>";
<% end -%>
Expand Down
5 changes: 5 additions & 0 deletions templates/dhcpd.conf.ddns.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ use-host-decl-names on;
include "<%= @dnsupdatekey %>";
<% @dnsdomain_real.each do |dom| -%>
zone <%= dom %>. {
<% if @nameservers && !@nameservers.empty? -%>
primary <%= @nameservers.first %>;
<% end -%>
<% if @nameservers_ipv6 && !@nameservers_ipv6.empty? -%>
primary6 <%= @nameservers_ipv6.first %>;
<% end -%>
key <%= @_dnskeyname %>;
}
<% end -%>
Expand Down
5 changes: 5 additions & 0 deletions templates/dhcpd.pool.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ subnet <%= @network %> netmask <%= @mask %> {
<% elsif @nameservers -%>
option domain-name-servers <%= @nameservers %>;
<% end -%>
<% if @nameservers_ipv6 and @nameservers_ipv6.is_a? Array -%>
option dhcp6.name-servers <%= @nameservers_ipv6.join(', ') %>;
<% elsif @nameservers_ipv6 -%>
option dhcp6.name-servers <%= @nameservers_ipv6 %>;
<% end -%>
<% if @pxeserver -%>
next-server <%= @pxeserver %>;
<% end -%>
Expand Down

0 comments on commit 3ada084

Please sign in to comment.