1

I am trying to install Ubuntu live server. Everything works fine till the system requests the cloud-init configs. I have tried to change my user-data file several times. Ether it throughs an error "An error occurred. Press enter to start shell (image 1)

Image 1

then I change the configuration file user-data file, it passes from waiting for cloud-init step and loads (I suppose ) user data file then it throws another error: Image 2

Here is my user-data file:

#cloud-config

# Locale and Timezone
locale: en_US.UTF-8
timezone: UTC

# Preserve the hostname
preserve_hostname: true

# Users configuration
users:
  - name: user
    gecos: ubuntu-server
    groups: adm, cdrom, dip, lxd, plugdev, sudo
    lock_passwd: false
    passwd: some-hashed-password
    sudo: ALL=(ALL) NOPASSWD:ALL
    shell: /bin/bash
    ssh_pwauth: true

# Disk setup for flexible sizes
# The partitioning will use the entire disk size
disk_setup:
  /dev/sda:
    table_type: gpt
    layout: true
    overwrite: false
    partition:
      - size: 1024        # 1GB for /boot
        type: 0xEF00      # EFI System Partition
      - size: 2048        # 2GB for /boot
        type: 0x8300      # Linux Filesystem for /boot
      - size: -1          # Use remaining space for root (LVM)

# LVM setup to use remaining disk space
lvm:
  vg:
    ubuntu-vg:
      devices:
        - /dev/sda3  # Third partition is for LVM

fs_setup:
  - label: boot
    filesystem: ext4
    device: /dev/sda2  # Boot partition

  - label: root
    filesystem: ext4
    device: /dev/mapper/ubuntu--vg-ubuntu--lv  # LVM root partition

# Mount points configuration
mounts:
  - [ /dev/sda2, /boot ]
  - [ /dev/mapper/ubuntu--vg-ubuntu--lv, / ]

# Growpart to automatically resize partitions
growpart:
  mode: 'auto'
  devices: ['/']

resize_rootfs: true  # Automatically resize the root filesystem

# Network setup (adjust the interface as needed)
network:
  version: 2
  ethernets:
    ens160:
      dhcp4: true

# Packages to install
packages:
  - openssh-server
  - htop
  - curl

# Run custom commands after first boot
runcmd:
  - echo "System successfully initialized!"
  - apt-get update && apt-get upgrade -y

# Reboot after cloud-init is done
power_state:
  mode: reboot

# Final message after boot
final_message: "The system is ready! You can now log in."

Could someone suggest me how to figure it out and make it work?

1

1 Answer 1

2

ssh_pwauth is not a per-user config key, but a top-level config key. So:

users:
  - name: user
    gecos: ubuntu-server
    groups: adm, cdrom, dip, lxd, plugdev, sudo
    lock_passwd: false
    passwd: some-hashed-password
    sudo: ALL=(ALL) NOPASSWD:ALL
    shell: /bin/bash

# separated from the users object
ssh_pwauth: true

And like @schrodingerscatcuriosity said in the comments, run the user-data file through cloud-init schema --config-file user_data.yaml to validate it to find the error(s) in the file.

1
  • 1
    @schrodingerscatcuriosity and telcoM thank you for suggestions. Yes I had some misconfigurations on it, but it was not only problem that caused my pxe not to work after radically changing my user-data and using autoinstall: before user-data: I was able to get live logs on the screen of the pxe, so I have identified that all the logs about the installation steps are written on /var/crash/ directory of the machine (which I was trying to install ubuntu), so I reviewed this log file and fixed all my misconfigurations and errors. Finally I achieved installation through pxe. Commented Sep 11, 2024 at 10:19

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.