all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH container] enable systemd-networkd per preset in fedora 37+
Date: Fri, 18 Nov 2022 10:36:42 +0100	[thread overview]
Message-ID: <20221118093642.46697-1-w.bumiller@proxmox.com> (raw)

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





             reply	other threads:[~2022-11-18  9:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18  9:36 Wolfgang Bumiller [this message]
2022-11-18 11:57 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221118093642.46697-1-w.bumiller@proxmox.com \
    --to=w.bumiller@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal