notes/Proxmox/Proxmox Cloud-Init Support.md

55 lines
1.8 KiB
Markdown

### Proxmox Cloud-Init Support
https://pve.proxmox.com/wiki/Cloud-Init_Support
https://cloud-images.ubuntu.com
```bash
# download the image
wget https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
# create a new VM
qm create 3000 --memory 1024 --net0 virtio,bridge=vmbr1
qm set 3000 --name ubuntu
# import the downloaded disk to local-lvm storage
qm importdisk 3000 focal-server-cloudimg-amd64.img local-lvm
# finally attach the new disk to the VM as scsi drive
qm set 3000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-3000-disk-0
```
###### Add Cloud-Init CD-ROM drive
The next step is to configure a CD-ROM drive, which will be used to pass the Cloud-Init data to the VM.
```bash
qm set 3000 --ide2 local-lvm:cloudinit
```
To be able to boot directly from the Cloud-Init image, set the bootdisk parameter to scsi0, and restrict BIOS to boot from disk only. This will speed up booting, because VM BIOS skips the testing for a bootable CD-ROM.
```bash
qm set 3000 --boot c --bootdisk scsi0
```
Also configure a serial console and use it as a display. Many Cloud-Init images rely on this, as it is an requirement for OpenStack images.
```bash
qm set 3000 --serial0 socket --vga serial0
```
In a last step, it is helpful to convert the VM into a template. From this template you can then quickly create linked clones. The deployment from VM templates is much faster than creating a full clone (copy).
```bash
qm template 3000
```
###### Deploying Cloud-Init Templates
You can easily deploy such a template by cloning:
```bash
qm clone 3000 171 --name us171
```
Then configure the SSH public key used for authentication, and configure the IP setup:
```bash
qm set 171 --sshkey ~/.ssh/id_rsa.pub
qm set 171 --ipconfig0 ip=192.168.10.171/24,gw=192.168.10.9
```