[pve-devel] [PATCH stable-4 container] use systemd-networkd for ubuntu >= 17.10

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Feb 27 13:30:09 CET 2018


From: Dominik Csapak <d.csapak at proxmox.com>

Ubuntu Artful uses systemd-networkd now,
but we have to delete the default netplan config from the
upstream lxc container, and enable systemd-networkd

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
(cherry picked from commit 73a7a0e8603db890116d5de8620a2d5554c9a34a)
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/LXC/Setup/Ubuntu.pm | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC/Setup/Ubuntu.pm b/src/PVE/LXC/Setup/Ubuntu.pm
index 59e18fb..c4035d9 100644
--- a/src/PVE/LXC/Setup/Ubuntu.pm
+++ b/src/PVE/LXC/Setup/Ubuntu.pm
@@ -51,7 +51,20 @@ sub template_fixup {
     my ($self, $conf) = @_;
 
     my $version = $self->{version};
-    
+
+    if ($version >= '17.10') {
+	# enable systemd-networkd
+	$self->ct_mkdir('/etc/systemd/system/multi-user.target.wants');
+	$self->ct_mkdir('/etc/systemd/system/socket.target.wants');
+	$self->ct_symlink('/lib/systemd/system/systemd-networkd.service',
+			  '/etc/systemd/system/multi-user.target.wants/systemd-networkd.service');
+	$self->ct_symlink('/lib/systemd/system/systemd-networkd.socket',
+			  '/etc/systemd/system/socket.target.wants/systemd-networkd.socket');
+
+	# unlink default netplan lxc config
+	$self->ct_unlink('/etc/netplan/10-lxc.yaml');
+    }
+
     if ($version eq '15.04' || $version eq '15.10' || $version eq '16.04') {
 	# edit /etc/securetty (enable login on console)
 	$self->setup_securetty($conf, qw(pts/0));
@@ -106,4 +119,14 @@ __EOD__
     }
 }
 
+sub setup_network {
+    my ($self, $conf) = @_;
+
+    if ($self->{version} >= '17.10') {
+	$self->setup_systemd_networkd($conf);
+    } else {
+	$self->SUPER::setup_network($conf);
+    }
+}
+
 1;
-- 
2.14.2





More information about the pve-devel mailing list