diff --git a/manifests/interface.pp b/manifests/interface.pp index ec602302b49b87d5ff23d68d305f30d55072c344..34b486d29b5bbdcc09c08d2b9ad6b1e5a3433ef9 100644 --- a/manifests/interface.pp +++ b/manifests/interface.pp @@ -634,9 +634,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..0808cf8023c9bcfd76189cfa0b27db0a438b4336 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) -%> @@ -65,9 +80,6 @@ NETMASK<%= id %>="<%= @netmask %>" NETMASK="<%= @netmask %>" <% end -%> <% end -%> -<% if @prefix -%> -PREFIX="<%= @prefix %>" -<% end -%> <% if @broadcast -%> BROADCAST="<%= @broadcast %>" <% end -%>