* Christian Dohm <[email protected]> [2020-11-29 15:50]:
> Public bug reported:
> 

Thank you for filing a bug.

> I've created a 'network-config' file with Terraform's yamldecode() function 
> that contains (btw. I've tried with the version being a Number w/o quotes and 
> as well as a String as shown here):
> ---
> "network":
>   "ethernets":
>     "eth0":
>       "gateway4": "192.168.1.1"
>       "nameservers":
>         "addresses":
>         - "192.168.1.74"
>         - "192.168.1.104"
>         "search":
>         - "fritz.box"
>       "set-name": "eth0"
>   "version": "2"
> ---
> After running on Raspberry Pi 4B with 4 GB, created with 
> ubuntu-20.04.1-preinstalled-server-arm64+raspi.img.xz, the machine's setup 
> fails and /var/log/cloud-init.log reveals that:
> ---
> 2020-04-01 17:23:48,649 - util.py[DEBUG]: Reading from 
> /boot/firmware//network-config (quiet=False)
> 2020-04-01 17:23:48,649 - util.py[DEBUG]: Read 245 bytes from 
> /boot/firmware//network-config
> 2020-04-01 17:23:48,650 - util.py[DEBUG]: Attempting to load yaml from string 
> of length 240 with allowed root types (<class 'dict'>,)
> 2020-04-01 17:23:48,652 - util.py[DEBUG]: Attempting to load yaml from string 
> of length 245 with allowed root types (<class 'dict'>,)
> 2020-04-01 17:23:48,656 - DataSourceNoCloud.py[DEBUG]: Top level network key 
> in network-config but missing 'config' or 'version': {'network': 
> {'ethernets': {'eth0': {'gateway4': '192.168.1.1', 'nameservers': 
> {'addresses': ['192.168.1.74', '192.168.1.104'], 'search': ['fritz.box']}, 
> 'set-name': 'eth0'}}, 'version': '2'}}

This happens due to the _maybe_remove_top_network method which only
understood network-config v1 format.  If the config provided included
the 'network' key, it would remove it.  It does some additional
checks (for v1 only) and if they don't match it returns the config
as it was loaded; in this case, with the top-level 'network' key.

Then this network config is passed to cloudinit.net which expects
the DataSource's .network_config property to include a config without a
'network' key; however, in this case, it still has the top-level key
and this confuses the .net's extract_physdevs function.

We should fix _maybe_remove_top_network to handle either v1 or v2;
We may want to accept version field as string and attempt to int() the
value.

As a workaround, if you specify your network config version 2 with the
following changes:

1) remove 'network' key
2) use integer 2 in the 'version' field
3) optionally, your 'set-name' requires use of a 'match' attribute,
   otherwise it's ignored.

  set-name: eth0
  match:
    macaddress: 'AA:BB:CC:DD:EE:FF'


This should let you progress.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1906187

Title:
  Version tag is not respected when put last

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1906187/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to