- öffne die shell in Proxmox
- apt update && apt install libguestfs-tools -y in case is fails to install -> apt install –no-install-recommends –no-install-suggests libguestfs-tools
- wo finde ich die Images: /var/lib/vz/template/iso/
- Beispiel um den Agent direkt im Image zu installieren:
virt-customize -a /var/lib/vz/template/iso/jammy-server-cloudimg-amd64.img --install qemu-guest-agent
[ 0.0] Examining the guest …
[ 6.5] Setting a random seed
virt-customize: warning: random seed could not be set for this type of
guest
[ 6.6] Setting the machine ID in /etc/machine-id
[ 6.6] Installing packages: qemu-guest-agent
[ 22.0] Finishing off
Kann auch via ansible Skript gemacht werden:
nano install_proxmox_libguestfs_tools.yaml
---
- name: Install libguestfs-tools package
hosts: '{{ host }}'
become: true
tasks:
- name: Update apt cache
apt:
update_cache: yes
- name: Install libguestfs-tools package
apt:
name: libguestfs-tools
state: present
ansible-playbook -v install_proxmox_libguestfs_tools.yaml -i hosts --extra-vars host=xxx
Einen User hinzufügen mit ssh key:
virt-customize -a /var/lib/vz/template/iso/jammy-server-cloudimg-amd64.img --run-command 'useradd admin'
virt-customize -a /var/lib/vz/template/iso/jammy-server-cloudimg-amd64.img --run-command 'mkdir -p /home/admin/.ssh'
virt-customize -a /var/lib/vz/template/iso/jammy-server-cloudimg-amd64.img --ssh-inject admin:file:/root/.ssh/id_rsa.pub
virt-customize -a /var/lib/vz/template/iso/jammy-server-cloudimg-amd64.img --run-command 'chown -R admin:admin /home/admin'
virt-customize -a /var/lib/vz/template/iso/jammy-server-cloudimg-amd64.img --run-command 'chmod 600 /home/admin/.ssh/id_rsa.pub'
Template erstellen unter Proxmox:
qm create 9001 --name "ubuntu-2204-cloudinit-template" --memory 2048 --cores 2 --net0 virtio,bridge=vmbr0
qm importdisk 9001 /var/lib/vz/template/iso/jammy-server-cloudimg-amd64.img local-lvm
qm set 9001 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9001-disk-0
qm set 9001 --boot c --bootdisk scsi0
qm set 9001 --ide2 local-lvm:cloudinit
qm set 9001 --serial0 socket --vga serial0
qm set 9001 --agent enabled=1
qm template 9001
VM installieren via commandline:
qm clone 9001 999 --name test-clone-cloud-init
qm set 999 --sshkey ~/.ssh/id_rsa.pub
qm set 999 --ipconfig0 ip=192.168.1.8/24,gw=192.168.1.1
qm start 999