---------------------------------------
network.pp (snippet)
################
# IPv6 stuff
################
if str2bool($ipv6_enabled) {
# Get the fourth octet from the node’s IPv4 address:
$i4 = regsubst($ip,'^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$','\4')
# Set ipv6 address space
case $::network_eth0 {
"172.31.28.0": { $ipv6_space = "2001:67c:274:XXXX" }
"172.31.24.0": { $ipv6_space = "2001:67c:274:XXYY" }
default: { $ipv6_space = "undef" }
}
if $ipv6_space != "undef" {
# Construct ipv6 address
$ipv6_addr = "${ipv6_space}::${i4}"
# Add network to address string, used in ifcfg template later
$ipv6_addr_cidr = "${ipv6_addr}/64"
notify { "ipv6 addr: $ipv6_addr_cidr":}
}
}
################
# END IPv6 stuff
################
file { "ifcfg-$device":
path => "$cfgdir/ifcfg-$device",
owner => root,
group => root,
mode => 644,
ensure => present,
content => $ifcfg_template,
}
---------------------------------------
ifcfg.erb
<% if @ipv6_addr_cidr -%>
#IPV6ADDR <%= @ipv6_addr_cidr %>
<% end -%>
---------------------------------------
The results of above code is just:
#IPV6ADDR
but no variable value.
Regards,
Adam