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 ?

1 Answers1

10

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.