4
network:
    network:
        version: 2
        ethernets:
            enp0s25:
               dhcp4: yes

Being before installation how do I know the name of the network adapter before installing it ? Can be used just mac without knowing the device name ?

  • Did you mean this one: https://www.freedesktop.org/software/systemd/man/systemd.net-naming-scheme.html – Rinzwind Apr 06 '21 at 17:41
  • @Rinzwind the device name ex: "enp025" I need to know it to set it the autoinstall config, or if I don't have it, maybe use the mac (with match) - regarding mac in docs appear under the name – user3541631 Apr 06 '21 at 17:50
  • It is explained in the link: for PCI devices it is "en" + "p" + {portnumber} + "s" + {slotnumber} in decimal. – Rinzwind Apr 06 '21 at 18:06
  • Ubuntu 20? There is no such release. Ubuntu uses yy.mm format (year.month of release) for all server & desktop releases, the yy being used only for IoT and specialist appliance/device releases (also suitable for cloud use) that can use snap packages only. By Ubuntu 20 do you mean Ubuntu Core 20? as it's a different product to Ubuntu 20.04 LTS (desktop or server). – guiverc Apr 06 '21 at 21:59

1 Answers1

8

If you delete the network: section from your autoinstall config, then a network config will be generated automatically. This might suit your needs.

default behavior

The networking configuration process is very confusing, but this is the way it seems to work when there is no network: section in the autoinstall config

1

In the installer, cloud-init has a default generic netplan config that is used when nothing is specified. This config matches all physical interfaces.

# This is the initial network config.
# It can be overwritten by cloud-init or subiquity.
network:
    version: 2
    ethernets:
        zz-all-en:
            match:
                name: "en*"
            dhcp4: true
        zz-all-eth:
            match:
                name: "eth*"
            dhcp4: true

2

Actual interface details are added to the installer filesystem in /etc/cloud/cloud.cfg.d/${IFNAME}.cfg. I believe casper is putting this file in place.

3

When the installer boots cloud-init merges its configuration to create a netplan config for the installer environment. A test VM I tried ends up with

# cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens192:
            critical: true
            dhcp-identifier: mac
            dhcp4: true
            nameservers:
                addresses:
                - REDACTED
                - REDACTED
                search:
                - REDACTED
        zz-all-en:
            dhcp4: true
            match:
                name: en*
        zz-all-eth:
            dhcp4: true
            match:
                name: eth*
    version: 2

4

The installer, subiquity, creates a config for curtin that only includes the portion of the installer netplan config that relates to actual interfaces.

# cat /var/log/installer/subiquity-curtin-install.conf
...
write_files:
...
  etc_netplan_installer: {content: "# This is the network config written by 'subiquity'\n\
      network:\n  ethernets:\n    ens192:\n      critical: true\n      dhcp-identifier:\
      \ mac\n      dhcp4: true\n      nameservers:\n        addresses:\n        -\
      \ REDACTED\n        - REDACTED\n        search:\n        - REDACTED\n\
      \  version: 2\n", path: etc/netplan/00-installer-config.yaml}
...

5

the installed system (located in /target) ends up with configuration given to curtin.

# cat /target/etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    ens192:
      critical: true
      dhcp-identifier: mac
      dhcp4: true
      nameservers:
        addresses:
        - REDACTED
        - REDACTED
        search:
        - REDACTED
  version: 2

6

At some point, the installer also changes its own configuration to use the installed configuration.

  • 1
    Great post and really helpful! I find it mindblowing that the cloud-init documentation is so poor and that you have to pick up the pieces from dozens of sources and somehow make do with the help of people like you who're actually creating the 'official' documentation. – Lethargos Sep 28 '22 at 23:03