sbates130272 / batesste-ansible

A collection of Ansible scripts for setting up new systems to my liking.
Apache License 2.0
3 stars 1 forks source link

netplan issues on home server #26

Open sbates130272 opened 1 year ago

sbates130272 commented 1 year ago

Since my home server has a bunch of network interfaces the boot stalls on waitng for IP address. Need to use netplan to make interfaces optional. See this for some discussion. Also got something that might be close to working:

batesste@newry:~$ cat /etc/netplan/02-ignore-newry-unused-interfaces.yml
# Written by batesste on 14 Oct 2022 for newry
network:
  version: 2
  ethernets:
    wlp7s0:
      optional: true
    enp7s0:
      optional: true
sbates130272 commented 1 year ago

This also seems to be related. Note the above is not consistently working for some reason.

systemd-networkd-wait-online.service
sbates130272 commented 1 year ago

Oh the reason this script in the first comment does not work consistently is that the damn interface names can change from one install of the OS to another.

sbates130272 commented 1 year ago

Using this and setting its status to --any may work better.

sbates130272 commented 1 year ago

So a nice way to solve this is to add the --any command option to the call into the systemd-networkd-wait-online. This is a nice thing to do on any system so I may well implement a role for this.

ExecStart=/lib/systemd/systemd-networkd-wait-online --any
sbates130272 commented 1 year ago

Turns out that --any does have issues when we add virtualization because it includes things like virtual NICs and bridges. So we may need a better approach.

Locking interface names to MAC addresses might work well on certain machines like this. Re-opening.

sbates130272 commented 1 year ago

The below is nice in that it locks down the interface names and also ensures that the interface I want is the one that comes up. Note quite sure what this means for the Ansible roles but placing this here so we can consider the options.

What works well on newry is a combination of this (/etc/netplan/00-installer-config.yaml):

#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Wait for Network to be Configured
Documentation=man:systemd-networkd-wait-online.service(8)
DefaultDependencies=no
Conflicts=shutdown.target
Requires=systemd-networkd.service
After=systemd-networkd.service
Before=network-online.target shutdown.target

[Service]
Type=oneshot
ExecStart=/lib/systemd/systemd-networkd-wait-online --interface=enp1s0
RemainAfterExit=yes

[Install]
WantedBy=network-online.target

and this (/lib/systemd/system/systemd-networkd-wait-online.service)

# This is the network config written by 'subiquity'
network:
  ethernets:
    enp1s0:
      match:
        macaddress: 58:11:22:b0:56:50
      dhcp4: true
      set-name: enp1s0
    enp2s0:
      match:
        macaddress: 58:11:22:b0:56:51
      set-name: enp2s0
      dhcp4: true
      optional: true
  version: 2