ds-identify yaml parsing is broken
Bug report
Any call to check_config() in ds-identify is subtly broken, and could result in false positives as a result of this key in /etc/cloud/cloud.cfg or /etc/cloud/cloud.cfg/.d*. The most impactful use of this false positive can result in the false positive detection of MAAS as the datasource.
For example, the following configuration:
datasource:
MAAS:
metadata_urls: [ 'blah.com' ]
Will result in MAAS being detected, even if it is not the correct platform.
# cat /run/cloud-init/cloud.cfg
datasource_list: [ MAAS, LXD, None ]
This may impact users that excpect to use a single configuration for multiple datasources, by causing cloud-init to attempt detection of maas at runtime:
2024-01-23 19:59:14,496 - __init__.py[DEBUG]: Looking for data source in: ['MAAS', 'LXD', 'None'], via packages ['', 'cloudinit.sources'] that matches dependencies ['FILESYSTEM']
2024-01-23 19:59:14,499 - __init__.py[DEBUG]: Searching for local data source in: ['DataSourceMAAS', 'DataSourceLXD']
2024-01-23 19:59:14,499 - handlers.py[DEBUG]: start: init-local/search-MAAS: searching for local data from DataSourceMAAS
2024-01-23 19:59:14,499 - __init__.py[DEBUG]: Seeing if we can get any data from <class 'cloudinit.sources.DataSourceMAAS.DataSourceMAAS'>
2024-01-23 19:59:14,500 - __init__.py[DEBUG]: Update datasource metadata and network config due to events: boot-new-instance
2024-01-23 19:59:14,500 - __init__.py[DEBUG]: Detected platform: DataSourceMAAS [None]. Checking for active instance data
2024-01-23 19:59:14,500 - __init__.py[DEBUG]: Datasource DataSourceMAAS [None] not updated for events: boot-new-instance
2024-01-23 19:59:14,500 - handlers.py[DEBUG]: finish: init-local/search-MAAS: SUCCESS: no local data found from DataSourceMAAS
2024-01-23 19:59:14,500 - handlers.py[DEBUG]: start: init-local/search-LXD: searching for local data from DataSourceLXD
The originally documented example failure case was fixed in https://github.com/canonical/cloud-init/pull/4905, but another way to trigger the MAAS collision is still possible, which was documented with an xfail in that same PR.