public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH container] enable systemd-networkd per preset in fedora 37+
@ 2022-11-18  9:36 Wolfgang Bumiller
  2022-11-18 11:57 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfgang Bumiller @ 2022-11-18  9:36 UTC (permalink / raw)
  To: pve-devel

While the template has systemd-networkd enabled, the lack of
/etc/machine-id causes systemd to revert to its "preset",
where now in
  /usr/lib/systemd/system-preset/90-default.preset
fedora disables systemd-networkd in favor of NetworkManager.

Without this patch, the first boot of a fresh fedora 37
container would disable networking requiring a
`systemctl enable systemd-networkd` from within the
container once, after which it sticks around (until
/etc/machine-id is deleted).

This patch provides an
`/etc/systemd/system-preset/00-pve.preset` file to keep
systemd-networkd enabled via the `template_fixup` hook.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
 src/PVE/LXC/Setup/Fedora.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/PVE/LXC/Setup/Fedora.pm b/src/PVE/LXC/Setup/Fedora.pm
index aad1eb4..021a44a 100644
--- a/src/PVE/LXC/Setup/Fedora.pm
+++ b/src/PVE/LXC/Setup/Fedora.pm
@@ -29,6 +29,18 @@ sub template_fixup {
 sub setup_init {
     my ($self, $conf) = @_;
     $self->setup_container_getty_service($conf);
+
+    my $version = $self->{version};
+
+    if ($version >= 37) {
+	# systemd-networkd is disabled by the preset in >=37, reenable it
+	# this only affects the first-boot (if no /etc/machien-id exists).
+	$self->ct_mkdir('/etc/systemd/system-preset', 0755);
+	$self->ct_file_set_contents(
+	    '/etc/systemd/system-preset/00-pve.preset',
+	    "enable systemd-networkd.service\n",
+	);
+    }
 }
 
 sub setup_network {
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-18 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-18  9:36 [pve-devel] [PATCH container] enable systemd-networkd per preset in fedora 37+ Wolfgang Bumiller
2022-11-18 11:57 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal