# HG changeset patch # User IBBoard # Date 1694960412 -3600 # Node ID 5c97adb07a0aaad5938cd56aa0f032e3667a17a9 # Parent ce488cfb225a230e487918814d13c717e10c50d8 Fix IP addresses in Ubuntu Apparently that file was wrong and didn't work after reboot. Each Ubuntu LTS has a different way of configuring. Also added a "restart networking on change" command. diff -r ce488cfb225a -r 5c97adb07a0a manifests/templates.pp --- a/manifests/templates.pp Sun Sep 10 09:48:49 2023 +0100 +++ b/manifests/templates.pp Sun Sep 17 15:20:12 2023 +0100 @@ -93,45 +93,30 @@ } if $proxy_4to6_ip_prefix != undef { + # …:1 to …:9 for websites, …:10 for mail + $ipv6_addresses = Integer[1, 10].map |$octet| { "$proxy_4to6_ip_prefix:$octet" } if $operatingsystem == 'Ubuntu' { # Ubuntu can't parse the existing file, so we need to brute-force it with a template - file { "/etc/network/interfaces.d/eth0": - content => epp('privat/eth0.epp', - { - default_address => $primary_ip, - gateway_address => $gateway_ip, - prefix_address => $proxy_4to6_ip_prefix, - } - ), + $ipv6_secondaries = join($ipv6_addresses, "\naddress=") + file { "/etc/systemd/network/50-ip-alias.network": + content => "[Network]\naddress=$ipv6_secondaries\n", + notify => Exec["restart_networking"], } - -# # …:1 to …:9 for websites, …:10 for mail -# Integer[1, 10].each |$octet| { -# augeas { "IPv6 secondary address $octet": -# context => "/files/etc/network/interfaces.d/eth0", -# changes => [ -# "set auto[child::1 = 'eth0:$octet']/1 eth0:$octet", -# "set no-auto-down[child::1 = 'eth0:$octet']/1 eth0:$octet", -# "set iface[. = 'eth0:$octet'] eth0:$octet", -# "set iface[. = 'eth0:$octet']/family inet6", -# "set iface[. = 'eth0:$octet']/method static", -# "set iface[. = 'eth0:$octet']/address $proxy_4to6_ip_prefix:$octet", -# "set iface[. = 'eth0:$octet']/netmask 64", -# -# ], -# } -# } } else { - # …:1 to …:9 for websites, …:10 for mail - $ipv6_addresses = Integer[1, 10].map |$octet| { "$proxy_4to6_ip_prefix:$octet" } $ipv6_secondaries = join($ipv6_addresses, " ") augeas {'IPv6 secondary addresses': context => "/files/etc/sysconfig/network-scripts/ifcfg-eth0", changes => "set IPV6ADDR_SECONDARIES '\"$ipv6_secondaries\"'", + notify => Exec["restart_networking"], } } + + Exec { 'restart_networking': + command => 'systemctl restart networking', + refreshonly => true, + } } require repos