Update Ubuntu 20.04 default network-config by cloud-config

Bug #1925454 reported by Adam Niedzwiecki
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Invalid
Undecided
Unassigned

Bug Description

This is a follow-up on the case https://bugs.launchpad.net/cloud-init/+bug/1924922

I cannot update default Ubuntu network-config by writing user-data file in cloud-config.

Attached are logs. Below is a snippet from the cloud-config

#cloud-config
write_files:
  - path: /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
    permissions: '0644'
    content: |
      network:
        config: disabled
  - path: /etc/netplan/50-cloud-init.yaml
    permissions: '0644'
    content: |
      network:
        version: 2
        ethernets:
          eth0:
            dhcp4: true
            addresses:
              - 192.168.53.3/26
            gateway4: 192.168.53.62
            nameservers:
              addresses:
                - 1.1.1.1
                - 8.8.8.8
runcmd:
  - [sudo, netplan, try]
  - [sudo, netplan, generate]
  - [sudo, netplan, apply]
power_state:
  mode: 'reboot'
  message: 'reboot triggered by cloud-init'

-----

Result is such that the hardcoded network-config ('optional': True, not waiting for DHCP server) is attached/generated with IP as, for an example - 192.168.53.4, not the IP I really want 192.168.53.3. This leads to couple of problems, one as specified in bug/1924922, that ssh_import_id is not working (for the time is not sync up)
Is there a way to overwrite this default with user-data, and not to go to the config partition and manually change it?

Revision history for this message
Adam Niedzwiecki (aniecki) wrote :
Revision history for this message
Adam Niedzwiecki (aniecki) wrote :

I also tried to modify this network-config, to delete line

optional: true

runcmd:
  - [
      sudo,
      sed,
      -i,
      '/optional: true/d',
      /boot/firmware/network-config,
    ]

It did deleted the line, yet again I can see this info (with optional: True)

137 2020-04-01 17:23:50,830 - networking.py[DEBUG]: net: all expected physical devices present
    138 2020-04-01 17:23:50,830 - stages.py[DEBUG]: applying net config names for {'version': 2, 'ethernets': {'eth0': {'dhcp4': True, 138 'optional': True}}}
    139 2020-04-01 17:23:50,831 - __init__.py[DEBUG]: no interfaces to rename

----
Please assist, how to change the thing, to optional: False, as the way I applied (deleted the line - as can be verified below) , has no impact

cat /boot/firmware/network-config
# Some additional examples are commented out below

version: 2
ethernets:
  eth0:
    dhcp4: true
#wifis:

Revision history for this message
Ryan Harper (raharper) wrote :

Hi Adam,

> Is there a way to overwrite this default with user-data, and not to go to the config partition and manually change it?

No. The network-config on /boot/firmware partition must be edited before you boot the image. Once cloud-init is started, it's too late to modify the network-config (it has already read it off the the partition).

On other cloud platforms, the network config is provided during early boot from the cloud's metadata service. For NoCloud configurations like the rpi image, it has to be done offline.

Revision history for this message
Ryan Harper (raharper) wrote :

I'm marking this bug as Invalid. cloud-init is working as expected for NoCloud datasource. Changes to the network-config during execution can't affect cloud-inits behavior during boot with the NoCloud datasource.

Changed in cloud-init:
status: New → Invalid
Revision history for this message
Ryan Harper (raharper) wrote :

This tutorial was helpful to me recently configuring an rpi:

https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#3-wifi-or-ethernet

Revision history for this message
James Falcon (falcojr) wrote :
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.