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

support for IPv6 pool #121

Merged
merged 1 commit into from
Nov 3, 2016
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
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 -%>
}