[SOLVED] Cloud-init breaking grub-pc boot disk selection?

czechsys

Renowned Member
Nov 18, 2015
388
36
93
Hi,

i have debian 11 VM as golden image. I have boot disk set as /dev/sda. VM shutdown, cloud-init disk regenerated.

Disk /dev/sda:
Code:
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: QEMU HARDDISK   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb75887e2

Device     Boot Start      End  Sectors Size Id Type
/dev/sda1  *     2048 20969471 20967424  10G 8e Linux LVM


Disk /dev/mapper/vg0-root: 7.45 GiB, 7998537728 bytes, 15622144 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/vg0-swap: 2.55 GiB, 2734686208 bytes, 5341184 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Clone the new VM:
1] without cloud-init:
Code:
debconf-show grub-pc

grub-pc/install_devices: /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0

2] with cloud-init:
Code:
debconf-show grub pc

grub-pc/install_devices: /dev/disk/by-id/dm-name-vg0-root

The 2] is generating same problem as https://ubuntuforums.org/showthread.php?t=2408085 , dunno if problem is grub-pc directly or cloud-init. My ansible is failing due this. How to solve it?
 
How is cloud-init configured inside the guest? /etc/cloud/cloud.cfg
Please also provide the VM config qm config <VMID>.

Does it boot fine and is it just Ansible that fails once it is booted, or where exactly does it fail?
 
Code:
boot: cdn
bootdisk: scsi0
cores: 2
cpu: host
ide0: vg-iscsi:vm-103-cloudinit,media=cdrom,size=4M
ide2: none,media=cdrom
memory: 4096
name: testcloud
net0: virtio=06:55:57:66:58:E1,bridge=vmbr0,link_down=1
net1: virtio=2A:4C:E8:43:F6:BF,bridge=vmbr0,link_down=1,tag=VLANID
numa: 0
ostype: l26
protection: 1
scsi0: vg-iscsi:vm-103-disk-0,discard=on,size=10G
scsihw: virtio-scsi-pci
smbios1: uuid=eda53093-210d-4780-aade-f6c75331c3a7
sockets: 1

/etc/cloud/cloud.cfg from cloned and booted VM:
Code:
# The top level settings are used as module
# and system configuration.

# A set of users which may be applied and/or used by various modules
# when a 'default' entry is found it will reference the 'default_user'
# from the distro configuration specified below
users:
   - default

# If this is set, 'root' will not be able to ssh in and they 
# will get a message to login instead as the above $user (debian)
disable_root: true

# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: false

# This prevents cloud-init from rewriting apt's sources.list file,
# which has been a source of surprise.
apt_preserve_sources_list: true

# Example datasource config
# datasource: 
#    Ec2: 
#      metadata_urls: [ 'blah.com' ]
#      timeout: 5 # (defaults to 50 seconds)
#      max_wait: 10 # (defaults to 120 seconds)

# The modules that run in the 'init' stage
cloud_init_modules:
 - migrator
 - seed_random
 - bootcmd
 - write-files
 - growpart
 - resizefs
 - disk_setup
 - mounts
 - set_hostname
 - update_hostname
 - update_etc_hosts
 - ca-certs
 - rsyslog
 - users-groups
 - ssh

# The modules that run in the 'config' stage
cloud_config_modules:
# Emit the cloud config ready event
# this can be used by upstart jobs for 'start on cloud-config'.
 - emit_upstart
 - ssh-import-id
 - locale
 - set-passwords
 - grub-dpkg
 - apt-pipelining
 - apt-configure
 - ntp
 - timezone
 - disable-ec2-metadata
 - runcmd
 - byobu

# The modules that run in the 'final' stage
cloud_final_modules:
 - package-update-upgrade-install
 - fan
 - puppet
 - chef
 - salt-minion
 - mcollective
 - rightscale_userdata
 - scripts-vendor
 - scripts-per-once
 - scripts-per-boot
 - scripts-per-instance
 - scripts-user
 - ssh-authkey-fingerprints
 - keys-to-console
 - phone-home
 - final-message
 - power-state-change

# System and/or distro specific settings
# (not accessible to handlers/transforms)
system_info:
   # This will affect which distro class gets used
   distro: debian
   # Default user name + that default users groups (if added/used)
   default_user:
     name: debian
     lock_passwd: True
     gecos: Debian
     groups: [adm, audio, cdrom, dialout, dip, floppy, netdev, plugdev, sudo, video]
     sudo: ["ALL=(ALL) NOPASSWD:ALL"]
     shell: /bin/bash
   # Other config here will be given to the distro class and/or path classes
   paths:
      cloud_dir: /var/lib/cloud/
      templates_dir: /etc/cloud/templates/
      upstart_dir: /etc/init/
   package_mirrors:
     - arches: [default]
       failsafe:
         primary: http://deb.debian.org/debian
         security: http://security.debian.org/
   ssh_svcname: ssh

I think i have cloud-init pure default, just setting IP in GUI to be accessible via ansible after boot. VM boots fine, ansible fails on every operation via apt when grub(-pc) is reconfigured.
 
Looks fine here. Can you provide your ansible playbook and the exact error you get, including the step that lead to it?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!