diff --git a/manifests/interface.pp b/manifests/interface.pp index ec602302b49b87d5ff23d68d305f30d55072c344..31784731544ff35c58ac6f1bb12d77ccd32c6113 100644 --- a/manifests/interface.pp +++ b/manifests/interface.pp @@ -282,6 +282,7 @@ define network::interface ( $enable_dhcp = false, $ipaddress = '', + $prefix = undef, $netmask = undef, $network = undef, $broadcast = undef, @@ -634,9 +635,17 @@ define network::interface ( }, default => $peerntp, } - $manage_ipaddr = $ipaddr ? { - '' => $ipaddress, - default => $ipaddr, + case $ipaddr { + '': { $manage_ipaddr = $ipaddress} + default: { + if $ipaddr =~ /^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\/([0-9]|[1-2][0-9]|3[0-2])$/ { + $manage_ipaddr = $1 + $manage_prefix = $2 + } else { + $manage_ipaddr = $ipaddr + $manage_prefix = $prefix + } + } } $manage_onboot = $onboot ? { '' => $enable ? { diff --git a/templates/interface/RedHat.erb b/templates/interface/RedHat.erb index 23ec584288eccea85b24c6610a7cdb6c4f588bcf..dd858e02451d47c6d55bc994e27207330fc16143 100644 --- a/templates/interface/RedHat.erb +++ b/templates/interface/RedHat.erb @@ -50,6 +50,21 @@ IPADDR<%= id %>="<%= @ipaddress[id-1] %>" IPADDR="<%= @manage_ipaddr %>" <% end -%> <% end -%> +<% if @manage_prefix -%> +<% if @ipaddress.kind_of?(Array) -%> +<% if @manage_prefix.kind_of?(Array) -%> +<%- (1..(@manage_prefix.length)).each do |id| -%> +PREFIX<%= id %>="<%= @manage_prefix[id-1] %>" +<% end -%> +<% else -%> +<%- (1..(@ipaddress.length)).each do |id| -%> +PREFIX<%= id %>="<%= @manage_prefix %>" +<% end -%> +<% end -%> +<% else -%> +PREFIX="<%= @manage_prefix %>" +<% end -%> +<% end -%> <% if @netmask -%> <% if @ipaddress.kind_of?(Array) -%> <% if @netmask.kind_of?(Array) -%>