netplan fails to apply /run/netplan/*.yaml config at startup

Bug #1791198 reported by Michael Wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Netplan
New
Undecided
Unassigned

Bug Description

In my system with Ubuntu 18.04 server OS, I have a CDROM with an iso file which contains a single netplan *.yaml config that gets mounted to /run/netplan/ at startup.

However, after bootup, the *.yaml config is not applied to the network interface. I need to manually execute "sudo netplan apply" for the netplan config in /run/netplan/ to be applied to the network interface.

I have created a run-netplan.mount unit to ensured systemd mounts the CDROM to /run/netplan/ before the network starts at bootup; however, the expected netplan config is still not applied after bootup.

Any help or feedback will be much appreciated. Thanks.

-----------------------------------------------
content of /run/netplan/10-example-ip.yaml:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 10.10.10.2/24
      gateway4: 10.10.10.1
      nameservers:
          search: [mydomain, otherdomain]
          addresses: [10.10.10.1, 1.1.1.1]

-----------------------------------------------
content of /etc/systemd/system/run-netplan.mount:

[Unit]
Description=Mount CD-ROM as netplan config
Before=systemd-networkd.service

[Mount]
What=/dev/sr0
Where=/run/netplan

[Install]
WantedBy=network.target

-----------------------------------------------
content of /etc/fstab:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=85e259f0-e29a-4438-a76f-da86b1b0ef01 / ext4 errors=remount-ro 0 1
/swapfile none swap sw 0 0
/dev/sr0 /run/netplan udf,iso9660 user,auto,exec,utf8,nofail 0 0

Revision history for this message
Daniel Axtens (daxtens) wrote :

Hmm, interesting.

On boot netplan runs as a systemd generator.

Looking at https://www.freedesktop.org/software/systemd/man/systemd.generator.html, it looks like it will have run well before your unit file kicks in.

Could you try setting up your unit file to run 'netplan generate' after mounting?

Regards,
Daniel

Revision history for this message
Michael Wang (zoltan77719) wrote :

Hi Daniel,

Thank you for your comments.

Knowing that netplan runs as a systemd generator, which runs well before unit files explain why my /run/netplan/*.yaml network config is not applied after startup.

After setting my unit file to run "netplan generate", the network configs are applied correctly after bootup.

Thanks,
Michael

Revision history for this message
andykimpe (andykimpe) wrote :

same problem for me config provided by ovh

force to delete the netplan file for which starts in dhccp

then put it back and retype netplan try

eno1 in dhcp primary server ip
eno2 ip failover

/etc/netplan/50-cloud-init.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
          eno2:
                  dhcp4: no
                  dhcp6: no
                  addresses: [146.59.XXX.XX/32]
                  gateway4: XX.XX.131.254
                  nameservers:
                          addresses: [213.186.33.99]
                  routes:
                  - to: XX.XX.131.254/32
                    via: 0.0.0.0
                    scope: link

after

netplan try

working

ifconfig

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
        inet XX.XX.131.165 netmask 255.255.255.0 broadcast XX.XX.131.255
        ether ac:1f:XX:XX:51:08 txqueuelen 1000 (Ethernet)
        RX packets 2420464 bytes 645356260 (645.3 MB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 3516469 bytes 3270577881 (3.2 GB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eno2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
        inet 146.59.XXX.XX netmask 255.255.255.255 broadcast 0.0.0.0
        ether ac:1f:XX:XX:51:09 txqueuelen 10000 (Ethernet)
        RX packets 0 bytes 0 (0.0 B)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 10 bytes 796 (796.0 B)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
        inet 127.0.0.1 netmask 255.0.0.0
        loop txqueuelen 1000 (Local Loopback)
        RX packets 3224040 bytes 10843099504 (10.8 GB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 3224040 bytes 10843099504 (10.8 GB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

I have volunteered to replace some part of the ip by X

to not list the exact ip it's not the most important

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.