Skip to content

Commit

Permalink
Merge pull request voxpupuli#121 from aquister/pool6
Browse files Browse the repository at this point in the history
support for IPv6 pool
  • Loading branch information
jyaworski authored Nov 3, 2016
2 parents 3ada084 + 1bf833f commit 4bd3eaf
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
30 changes: 30 additions & 0 deletions manifests/pool6.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# == Define: dhcp::pool6
#
define dhcp::pool6 (
$network,
$prefix,
$range = '',
$range_temp = '',
$failover = '',
$options = '',
$parameters = '',
$nameservers = undef,
$nameservers_ipv6 = undef,
$pxeserver = undef,
$mtu = undef,
$domain_name = '',
$ignore_unknown = undef,
) {
if $mtu {
validate_integer($mtu)
}

include ::dhcp::params

$dhcp_dir = $dhcp::params::dhcp_dir

concat::fragment { "dhcp_pool_${name}":
target => "${dhcp_dir}/dhcpd.pools",
content => template('dhcp/dhcpd.pool6.erb'),
}
}
22 changes: 22 additions & 0 deletions spec/defines/pool6_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'spec_helper'

describe 'dhcp::pool6', type: :define do
let :title do
'test_pool6'
end
let(:facts) do
{
concat_basedir: '/dne',
osfamily: 'RedHat'
}
end
let :params do
{
'network' => '2001:db8::',
'prefix' => '64',
'range' => '2001:db8::100 2001:db8::110'
}
end

it { should contain_concat__fragment("dhcp_pool_#{title}") }
end
66 changes: 66 additions & 0 deletions templates/dhcpd.pool6.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#################################
# <%= @name %> <%= @network %>/<%= @prefix %>
#################################
subnet6 <%= @network %>/<%= @prefix %> {
<% if @range != '' or @failover != '' -%>
pool6
{
<% if @failover != '' -%>
failover peer "<%= @failover %>";
<% end -%>
<% if @ignore_unknown == true -%>
ignore unknown-clients ;
<% end -%>
<% if @range and @range.is_a? Array -%>
<% @range.each do |r| -%>
range6 <%= r %>;
<% end -%>
<% elsif @range != '' -%>
range6 <%= @range %>;
<% end -%>
<% if @range_temp and @range_temp.is_a? Array -%>
<% @range_temp.each do |r| -%>
range6 <%= r %> temporary;
<% end -%>
<% elsif @range_temp != '' -%>
range6 <%= @range_temp %> temporary;
<% end -%>

}
<% end -%>

<% if @domain_name and !@domain_name.empty? -%>
option domain-name "<%= @domain_name %>";
<% end -%>
<% if @options.is_a? Array -%>
<% @options.each do |opt| -%>
option <%= opt %>;
<% end -%>
<% elsif @options != '' -%>
option <%= @options %>;
<% end -%>
<% if @parameters.is_a? Array -%>
<% @parameters.each do |param| -%>
<%= param %>;
<% end -%>
<% elsif @parameters != '' -%>
<%= @parameters %>;
<% end -%>
<% if @nameservers and @nameservers.is_a? Array -%>
option domain-name-servers <%= @nameservers.join(', ') %>;
<% 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 -%>
<% if @mtu -%>
option interface-mtu <%= @mtu %>;
<% end -%>
}

0 comments on commit 4bd3eaf

Please sign in to comment.