forked from theforeman/puppet-dhcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing theforeman#62 - add support for dhcp6
- Loading branch information
Showing
8 changed files
with
232 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# class dhcp::dhcp6 | ||
class dhcp::dhcp6 ( | ||
Array[String] $dnsdomain = $dhcp::params::dnsdomain, | ||
Array[String] $nameservers = ['2001:4860:4860::8888', '2001:4860:4860::8844'], | ||
Integer[0] $default_lease_time6 = 2592000, | ||
Integer[0] $default_preferred_lifetime6 = 604800, | ||
Integer[0] $default_renewal_time6 = 3600, | ||
Integer[0] $default_rebinding_time6 = 7200, | ||
Integer[0] $default_info_refresh_time6 = 21600, | ||
Boolean $leasequery6 = true, | ||
Boolean $rapid_commit6 = false, | ||
Integer[0] $default_preference6 = 10, | ||
Stdlib::Absolutepath $dhcp_dir = $dhcp::params::dhcp_dir, | ||
Stdlib::Absolutepath $default_leasefile_path6 = $dhcp::params::default_leasefile_path6, | ||
String $packagename = $dhcp::params::packagename, | ||
String $servicename6 = $dhcp::params::servicename6, | ||
Variant[Array[String], Optional[String]] $options = undef, | ||
String $dhcp_root_group = $dhcp::params::root_group, | ||
Hash[String, Hash] $pools6 = {}, | ||
Hash[String, Hash] $hosts6 = {}, | ||
Variant[Array[String], Optional[String]] $includes = undef, | ||
) inherits dhcp::params { | ||
|
||
concat { "${dhcp_dir}/dhcpd6.conf": | ||
owner => 'root', | ||
group => $dhcp_root_group, | ||
mode => '0644', | ||
require => Package[$packagename], | ||
notify => Service[$servicename6], | ||
} | ||
|
||
concat::fragment { 'dhcp6.conf+01_main.dhcp': | ||
target => "${dhcp_dir}/dhcpd6.conf", | ||
content => template('dhcp/dhcpd6.conf.erb'), | ||
order => '01', | ||
} | ||
|
||
if $includes { | ||
concat::fragment { 'dhcp6.conf+20_includes': | ||
target => "${dhcp_dir}/dhcpd6.conf", | ||
content => template('dhcp/dhcpd6.conf.includes.erb'), | ||
order => '20', | ||
} | ||
} | ||
|
||
concat { "${dhcp_dir}/dhcpd6.hosts": | ||
owner => 'root', | ||
group => $dhcp_root_group, | ||
mode => '0644', | ||
require => Package[$packagename], | ||
notify => Service[$servicename6], | ||
} | ||
|
||
concat::fragment { 'dhcp6.hosts+01_main.hosts': | ||
target => "${dhcp_dir}/dhcpd6.hosts", | ||
content => "# static DHCP hosts\n", | ||
order => '01', | ||
} | ||
|
||
create_resources('dhcp::pool6', $pools6) | ||
create_resources('dhcp::host6', $hosts6) | ||
|
||
service { $servicename6: | ||
ensure => running, | ||
enable => true, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#class dhcp::host6 | ||
define dhcp::host6 ( | ||
String $ip, | ||
Dhcp::Macaddress $mac, | ||
Optional[String] $comment=undef, | ||
) { | ||
|
||
$host = $name | ||
|
||
concat::fragment { "dhcp.hosts+10_${name}.hosts": | ||
target => "${::dhcp::dhcp_dir}/dhcpd6.hosts", | ||
content => template('dhcp/dhcpd6.host.erb'), | ||
order => "10-${name}", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# class dhcp::pool6 | ||
define dhcp::pool6 ( | ||
String $network, | ||
Integer[0] $prefix, | ||
Variant[Array[String], Optional[String]] $pool_parameters = undef, | ||
Variant[Array[Dhcp::Range], String, Optional[Dhcp::Range], Enum[''], Boolean] $range = undef, | ||
Optional[String] $failover = undef, | ||
Variant[Array[String], Optional[String]] $options = undef, | ||
Variant[Array[String], Optional[String]] $parameters = undef, | ||
Optional[Integer[0]] $mtu = undef, | ||
Variant[Array[String], Optional[String]] $nameservers = undef, | ||
Optional[String] $pxeserver = undef, | ||
Optional[String] $pxefilename = undef, | ||
Optional[String] $domain_name = undef, | ||
Variant[Array[String], Optional[String]] $search_domains = undef, | ||
Optional[String] $raw_append = undef, | ||
Optional[String] $raw_prepend = undef, | ||
) { | ||
|
||
concat::fragment { "dhcp6.conf+70_${name}.dhcp": | ||
target => "${::dhcp::dhcp_dir}/dhcpd6.conf", | ||
content => template('dhcp/dhcpd6.pool.erb'), | ||
order => "70-${name}", | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# dhcpd6.conf | ||
|
||
default-lease-time <%= @default_lease_time6 %>; | ||
preferred-lifetime <%= @default_preferred_lifetime6 %>; | ||
option dhcp-renewal-time <%= @default_renewal_time6 %>; | ||
option dhcp-rebinding-time <%= @default_rebinding_time6 %>; | ||
option dhcp6.info-refresh-time <%= @default_info_refresh_time6 %>; | ||
|
||
<% if @leasequery6 -%> | ||
allow leasequery; | ||
<% end -%> | ||
|
||
<% if @default_preference6 -%> | ||
option dhcp6.preference 255; | ||
<% end -%> | ||
|
||
<% if @rapid_commit6 -%> | ||
option dhcp6.rapid-commit; | ||
<% end -%> | ||
|
||
<% if @nameservers and @nameservers.is_a? Array -%> | ||
option dhcp6.name-servers <%= @nameservers.sort.join(', ') %>; | ||
<% elsif @nameservers -%> | ||
option dhcp6.name-servers <%= @nameservers %>; | ||
<% end -%> | ||
<% if @search_domains and @search_domains.is_a? Array -%> | ||
option dhcp6.domain-search "<%= @search_domains.sort.join('", "') %>"; | ||
<% elsif @search_domains -%> | ||
option dhcp6.domain-search "<%= @search_domains.split(/[, ]+/).join('", "') %>"; | ||
<% end -%> | ||
|
||
# The path of the lease file | ||
dhcpv6-lease-file-name "<%= @default_leasefile_path6 %>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
host <%= @host %> { | ||
hardware ethernet <%= @mac %>; | ||
fixed-address6 <%= @ip %>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# <%= @name %> | ||
subnet6 <%= @network %>/<%= @prefix %> { | ||
<% if @raw_prepend -%> | ||
<%= @raw_prepend %> | ||
<% end -%> | ||
<% if (@range && @range.is_a?(String) && [email protected]?) || (@range && @range.is_a?(Array)) -%> | ||
<% if @pool_parameters.is_a? Array -%> | ||
<% @pool_parameters.each do |param| -%> | ||
<%= param %>; | ||
<% end -%> | ||
<% elsif @pool_parameters && !@pool_parameters.strip.empty? -%> | ||
<%= @pool_parameters %>; | ||
<% end -%> | ||
<% if @range and @range.is_a? Array -%> | ||
<% @range.each do |rng| -%> | ||
range6 <%= rng %>; | ||
<% end -%> | ||
<% elsif @range && [email protected]? -%> | ||
range6 <%= @range %>; | ||
<% end -%> | ||
<% end -%> | ||
<% if @domain_name && !@domain_name.strip.empty? -%> | ||
option dhcp6.domain-name "<%= @domain_name %>"; | ||
<% end -%> | ||
<% if @options.is_a? Array -%> | ||
<% @options.each do |opt| -%> | ||
option <%= opt %>; | ||
<% end -%> | ||
<% elsif @options && [email protected]? -%> | ||
option <%= @options %>; | ||
<% end -%> | ||
<% if @parameters.is_a? Array -%> | ||
<% @parameters.each do |param| -%> | ||
<%= param %>; | ||
<% end -%> | ||
<% elsif @parameters && [email protected]? -%> | ||
<%= @parameters %>; | ||
<% end -%> | ||
<% if @nameservers and @nameservers.is_a? Array -%> | ||
option dhcp6.name-servers <%= @nameservers.sort.join(', ') %>; | ||
<% elsif @nameservers -%> | ||
option dhcp6.name-servers <%= @nameservers %>; | ||
<% end -%> | ||
<% if @search_domains and @search_domains.is_a? Array -%> | ||
option dhcp6.domain-search "<%= @search_domains.sort.join('", "') %>"; | ||
<% elsif @search_domains -%> | ||
option dhcp6.domain-search "<%= @search_domains.split(/[, ]+/).join('", "') %>"; | ||
<% end -%> | ||
<% if @raw_append -%> | ||
<%= @raw_append %> | ||
<% end -%> | ||
} |