Shell-Scripts/Proxmox/cloud-init_agent_creation.sh
2024-08-31 21:34:01 -05:00

20 lines
1.0 KiB
Bash

# installing libguestfs-tools only required once, prior to first run
apt update -y
apt install libguestfs-tools -y
# remove existing image in case last execution did not complete successfully
rm jammy-server-cloudimg-amd64.img
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
# Install required tools for virtualization
virt-customize -a jammy-server-cloudimg-amd64.img --install qemu-guest-agent
virt-customize -a jammy-server-cloudimg-amd64.img --run-command ""
virt-customize -a jammy-server-cloudimg-amd64.img --run-command "echo -n > /etc/machine-id"
sudo qm create 9000 --name "ubuntu-cloudinit-template" --memory 2048 --cores 2 --net0 virtio,bridge=vmbr0
sudo qm importdisk 9000 jammy-server-cloudimg-amd64.img CEPH-SSD
sudo qm set 9000 --scsihw virtio-scsi-pci --scsi0 CEPH-SSD:vm-9000-disk-0
sudo qm set 9000 --boot c --bootdisk scsi0
sudo qm set 9000 --ide2 CEPH-SSD:cloudinit
sudo qm set 9000 --serial0 socket --vga serial0
sudo qm set 9000 --agent enabled=1
sudo qm template 9000
rm jammy-server-cloudimg-amd64.img