Skip to content

Instantly share code, notes, and snippets.

@matti
Last active December 25, 2024 20:30
Show Gist options
  • Save matti/6166f8570ffd6fd3c51d24f05f9c27ff to your computer and use it in GitHub Desktop.
Save matti/6166f8570ffd6fd3c51d24f05f9c27ff to your computer and use it in GitHub Desktop.
proxmox cloudinit cloud-init pata
#!/usr/bin/env bash
set -eEuo pipefail
set -x
storage=local-btrfs
mkdir -p /var/lib/vz/snippets
cd /root
if [[ ! -f noble-server-cloudimg-amd64.img ]] ; then
wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
fi
nextId=$(pvesh get /cluster/nextid)
qm create "$nextId" --name "$nextId" \
--agent 1 \
--cores 32 \
--memory $((32*1024)) \
--net0 virtio,bridge=vmbr2 \
--serial0 socket --vga serial0 \
--boot c --bootdisk scsi0 \
--cicustom "user=local:snippets/${nextId}.yml" \
--ide2 "${storage}:cloudinit" \
--ipconfig0 ip=dhcp \
--scsihw virtio-scsi-pci
qm set "$nextId" --scsi0 "${storage}:0,import-from=/root/noble-server-cloudimg-amd64.img"
qm resize "$nextId" scsi0 50G
passwd='...'
echo """#cloud-config
runcmd:
- sed -i '/^#\?KbdInteractiveAuthentication/c\KbdInteractiveAuthentication yes' /etc/ssh/sshd_config
users:
- name: nimda
lock_passwd: false
passwd: ${passwd}
groups:
- sudo
sudo:
- ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
""" > "/var/lib/vz/snippets/${nextId}.yml"
qm start "$nextId"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment