changeset 461:5c97adb07a0a

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.
author IBBoard <dev@ibboard.co.uk>
date Sun, 17 Sep 2023 15:20:12 +0100
parents ce488cfb225a
children 2f2ecf1f0215
files manifests/templates.pp
diffstat 1 files changed, 12 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- 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