autoinstall: user-data validation fails for users or packages if they contain list of object

Bug #2047796 reported by Yao Wei
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cloud-init
New
Undecided
Unassigned
subiquity
Invalid
Undecided
Unassigned
subiquity (Ubuntu)
Invalid
Undecided
Olivier Gayot

Bug Description

autoinstall.user-data schema validation failed in the following cases:

* cannot define a user in user-config:

autoinstall:
  user-data:
    users:
    - name: ubuntu
      plain_text_passwd: 'ubuntu'
      home: /home/ubuntu
      shell: /bin/bash
      lock_passwd: false
      gecos: Ubuntu all-oem-init
      groups: [adm, cdrom, dip, lxd, sudo]

* cannot use packages[#].apt or packages[#].snap which contains a list of packages:

autoinstall:
  user-data:
    packages:
    - snap:
      - certbot
      - [juju, --edge]
      - [lxd, --channel=5.15/stable]
    - apt:
      - mg

These schemas documented in cloud-init documentations should be usable.

Yao Wei (medicalwei)
description: updated
Revision history for this message
Yao Wei (medicalwei) wrote :

In the 1st case, the following error message is in the debug log:

Traceback (most recent call last):
  File "/snap/ubuntu-desktop-installer/1276/bin/subiquity/subiquity/server/server.py", line 686, in start
    self.load_autoinstall_config(only_early=False)
  File "/snap/ubuntu-desktop-installer/1276/bin/subiquity/subiquity/server/server.py", line 488, in load_autoinstall_config
    controller.setup_autoinstall()
  File "/snap/ubuntu-desktop-installer/1276/bin/subiquity/subiquity/server/controller.py", line 76, in setup_autoinstall
    self.load_autoinstall_data(ai_data)
  File "/snap/ubuntu-desktop-installer/1276/bin/subiquity/subiquity/server/controllers/userdata.py", line 34, in load_autoinstall_data
    self.app.base_model.validate_cloudconfig_schema(
  File "/snap/ubuntu-desktop-installer/1276/bin/subiquity/subiquity/models/subiquity.py", line 349, in validate_cloudconfig_schema
    raise SchemaValidationError(schema_errors=errors)
cloudinit.config.schema.SchemaValidationError: Cloud config schema errors: autoinstall.user-data.users.0: {'gecos': 'Ubuntu all-oem-init', 'groups': ['adm', 'cdrom', 'dip', 'lxd', 'sudo'], 'home': '/home/ubuntu', 'lock_passwd': False, 'name': 'ubuntu', 'plain_text_passwd': 'ubuntu', 'shell': '/bin/bash'} is not of type 'string', autoinstall.user-data.users.0: {'gecos': 'Ubuntu all-oem-init', 'groups': ['adm', 'cdrom', 'dip', 'lxd', 'sudo'], 'home': '/home/ubuntu', 'lock_passwd': False, 'name': 'ubuntu', 'plain_text_passwd': 'ubuntu', 'shell': '/bin/bash'} is not valid under any of the given schemas

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in subiquity (Ubuntu):
status: New → Confirmed
Revision history for this message
David Collantes (fastidious) wrote :

Is this on its way to be fixed?

Olivier Gayot (ogayot)
Changed in subiquity (Ubuntu):
assignee: nobody → Olivier Gayot (ogayot)
Olivier Gayot (ogayot)
tags: added: foundations-todo
Revision history for this message
Olivier Gayot (ogayot) wrote :

Hello,

For the first example (with the users), it looks like the "home" directive is invalid. Looking at the documentation, I think it should be "homedir" instead. I've opened a pull request in cloud-init [1] to fix the documented example.

Looking at the second example now.

[1] https://github.com/canonical/cloud-init/pull/5101

Revision history for this message
Olivier Gayot (ogayot) wrote (last edit ):

For the second example, I tested with cloud-init from the jammy-security pocket (i.e., 23.1.2-0ubuntu0~22.04.1):

$ cloud-init schema --config-file test.yaml

Invalid cloud-config test.yaml
Error: Cloud config schema errors: packages.0: {'snap': ['certbot', ['juju', '--edge'], ['lxd', '--channel=5.15/stable']]} is not valid under any of the given schemas, packages.1: {'apt': ['mg']} is not valid under any of the given schemas

Whereas with the version of cloud-init in the jammy-updates pocket (i.e., 23.4.4-0ubuntu0~22.04.1):

$ cloud-init schema --config-file test.yaml

Valid schema test.yaml

Yao, do you reproduce the issue on a recent version of subiquity (or ubuntu-desktop-bootstrap) ?

Revision history for this message
Yao Wei (medicalwei) wrote (last edit ):

I retried these configurations in cloud-init 24.1.2-0ubuntu1 in noble and this seems to be resolved.

Thanks, and sorry for the noise!

Revision history for this message
Olivier Gayot (ogayot) wrote :

No problem. Closing the tasks for Subiquity since no changes are required.

Changed in subiquity (Ubuntu):
status: Confirmed → Invalid
Changed in subiquity:
status: New → Invalid
Olivier Gayot (ogayot)
tags: removed: foundations-todo
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.