Search code examples
ubuntuhyper-vcloud-init

Cloud-init error when installing VM with cloud config file


I created a cloud-init file and validated it using the following command:

cloud-init schema --config-file source-files/server/user-data

After including my cloud config file in an Ubuntu 22.04 ISO file, I modified other files in Ubuntu to make it use my user-data. However, when attempting to install the VM, I encountered the following error:

__init()__ missing 1 required positional argument: 'name'

Here is my cloud-init content:

#cloud-config
autoinstall:
  version: 1
  identity:
    realname: clusteradmin
    username: clusteradmin
    hostname: newhost
    password: "$6$m39rWH9yal3nbN1M$R54RPwl0iMwkVz4A.qFyW.e.2ieMPBQL58RySuRtmDCofNS/lZiP2PbZUrLB5whEAOSrAUOh54aTWmMceB1SO1"
  ssh:
    allow-pw: true
    install-server: true
  refresh-installer:
    update: false
  locale: en_US.UTF-8
  keyboard:
    layout: us
    variant: eng
  package_update: true
  package_upgrade: true
  storage:
    config:
    - id: sda
      type: disk
      name: 'main'
      ptable: gpt
      wipe: superblock
      preserve: false
      grub_device: true
    - id: bios-grub-partition
      type: partition
      number: 1
      device: sda
      size: 1048576
      preserve: false
      grub_device: false
      flag: bios_grub
    - id: boot-partition
      type: partition
      number: 2
      device: sda
      size: 2G
      wipe: superblock
      preserve: false
      grub_device: false
      flag: ''
    - id: ubuntu-vg-partition
      type: partition
      number: 3
      device: sda
      size: -1
      wipe: superblock
      preserve: false
      grub_device: false
      flag: ''
    - id: boot-format
      type: format
      fstype: ext4
      volume: boot-partition
      preserve: false
    - id: boot-mount
      type: mount
      device: boot-format
      path: /boot
    - id: ubuntu-vg
      type: lvm_volgroup
      name: ubuntu-vg
      devices:
      - ubuntu-vg-partition
      preserve: false
    - id: root-lv
      type: lvm_partition
      volgroup: ubuntu-vg
      size: 15%
      wipe: superblock
      preserve: false
    - id: var-lv
      type: lvm_partition
      volgroup: ubuntu-vg
      size: 30%
      wipe: superblock
      preserve: false
    - id: vartmp-lv
      type: lvm_partition
      volgroup: ubuntu-vg
      size: 5%
      wipe: superblock
      preserve: false
    - id: varlog-lv
      type: lvm_partition
      volgroup: ubuntu-vg
      size: 15%
      wipe: superblock
      preserve: false
    - id: varlogaudit-lv
      type: lvm_partition
      volgroup: ubuntu-vg
      size: 15%
      wipe: superblock
      preserve: false
    - id: home-lv
      type: lvm_partition
      volgroup: ubuntu-vg
      size: 15%
      wipe: superblock
      preserve: false
    - id: tmp-lv
      type: lvm_partition
      volgroup: ubuntu-vg
      size: 5%
      wipe: superblock
      preserve: false
    - id: root-format
      type: format
      volume: root-lv
      preserve: false
      fstype: ext4
    - id: var-format
      type: format
      volume: var-lv
      preserve: false
      fstype: ext4
    - id: vartmp-format
      type: format
      volume: vartmp-lv
      preserve: false
      fstype: ext4
    - id: varlog-format
      type: format
      volume: varlog-lv
      preserve: false
      fstype: ext4
    - id: varlogaudit-format
      type: format
      volume: varlogaudit-lv
      preserve: false
      fstype: ext4
    - id: home-format
      type: format
      volume: home-lv
      preserve: false
      fstype: ext4
    - id: tmp-format
      type: format
      volume: tmp-lv
      preserve: false
      fstype: ext4
    - id: root-mount
      type: mount
      device: root-format
      path: /
    - id: var-mount
      type: mount
      device: var-format
      path: /var
    - id: vartmp-mount
      type: mount
      device: vartmp-format
      path: /var/tmp
    - id: varlog-mount
      type: mount
      device: varlog-format
      path: /var/log
    - id: varlogaudit-mount
      type: mount
      device: varlogaudit-format
      path: /var/log/audit
    - id: home-mount
      type: mount
      device: home-format
      path: /home
    - id: tmp-mount
      type: mount
      device: tmp-format
      path: /tmp

Here is the view from the VM when I connect: enter image description here


Solution

  • You have an error in your storage configuration. All logical volumes must have a name, but you're missing a name: attribute in all of your lvm_partition blocks. Instead of:

    - id: root-lv
      type: lvm_partition
      volgroup: ubuntu-vg
      size: 15%
      wipe: superblock
      preserve: false
    

    You need something like:

    - id: root-lv
      name: root
      type: lvm_partition
      volgroup: ubuntu-vg
      size: 15%
      wipe: superblock
      preserve: false
    

    (And so forth for the rest of your logical volume definitions.)


    I would argue that you should also report a bug against the installer: you should be receiving a more useful error message in this situation.