Skip to content

Commit

Permalink
add interface-mtu option (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvin-huang authored and mmoll committed Jul 3, 2016
1 parent 1632737 commit 0bc528d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$omapi_key = undef,
$pxeserver = undef,
$pxefilename = undef,
$mtu = undef,
$logfacility = 'local7',
$dhcp_monitor = true,
$dhcp_dir = $dhcp::params::dhcp_dir,
Expand All @@ -28,6 +29,10 @@
$includes = undef,
) inherits dhcp::params {

if $mtu {
validate_integer($mtu)
}

# Incase people set interface instead of interfaces work around
# that. If they set both, use interfaces and the user is a unwise
# and deserves what they get.
Expand Down
5 changes: 5 additions & 0 deletions manifests/pool.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
$failover = undef,
$options = undef,
$parameters = undef,
$mtu = undef,
$nameservers = undef,
$pxeserver = undef,
$domain_name = undef,
$static_routes = undef,
$search_domains = undef,
) {

if $mtu {
validate_integer($mtu)
}

concat::fragment { "dhcp.conf+70_${name}.dhcp":
target => "${::dhcp::dhcp_dir}/dhcpd.conf",
content => template('dhcp/dhcpd.pool.erb'),
Expand Down
2 changes: 2 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
:omapi_name => 'mykeyname',
:omapi_key => 'myomapikey',
:pxeserver => '10.0.0.5',
:mtu => 9000,
:pxefilename => 'mypxefilename',
:option_static_route => true,
:options => ['provision-url code 224 = text', 'provision-type code 225 = text'],
Expand Down Expand Up @@ -94,6 +95,7 @@
'option pxegrub code 150 = text ;',
'option rfc3442-classless-static-routes code 121 = array of integer 8;',
'option ms-classless-static-routes code 249 = array of integer 8;',
'option interface-mtu 9000;',
'option provision-url code 224 = text;',
'option provision-type code 225 = text;',
'next-server 10.0.0.5;',
Expand Down
2 changes: 2 additions & 0 deletions spec/defines/pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
:parameters => 'max-lease-time 300',
:nameservers => ['10.0.0.2', '10.0.0.4'],
:pxeserver => '10.0.0.2',
:mtu => 9000,
:domain_name => 'example.org',
:static_routes => [ { 'mask' => '24', 'network' => '10.0.1.0', 'gateway' => '10.0.0.2' } ],
:search_domains => ['example.org', 'other.example.org'],
Expand All @@ -132,6 +133,7 @@
" max-lease-time 300;",
" option domain-name-servers 10.0.0.2, 10.0.0.4;",
" option domain-search \"example.org\", \"other.example.org\";",
" option interface-mtu 9000;",
" next-server 10.0.0.2;",
"}",
])
Expand Down
4 changes: 4 additions & 0 deletions templates/dhcpd.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ option rfc3442-classless-static-routes code 121 = array of integer 8;
option ms-classless-static-routes code 249 = array of integer 8;
<% end -%>
<% if has_variable?( 'mtu' ) && @mtu -%>
option interface-mtu <%= @mtu %>;
<% end -%>
<% if @options.is_a? Array -%>
<% @options.each do |option| -%>
option <%= option %>;
Expand Down
3 changes: 3 additions & 0 deletions templates/dhcpd.pool.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ subnet <%= @network %> netmask <%= @mask %> {
<% elsif @search_domains -%>
option domain-search "<%= @search_domains.split(/[, ]+/).join('", "') %>";
<% end -%>
<% if @mtu -%>
option interface-mtu <%= @mtu %>;
<% end -%>
<% if @pxeserver -%>
next-server <%= @pxeserver %>;
<% end -%>
Expand Down

0 comments on commit 0bc528d

Please sign in to comment.