This commit is contained in:
root 2026-02-16 23:50:20 +02:00
commit bfbcb8d087
2 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,44 @@
#!/usr/bin/env bash
IMAGE="./Rocky-10-GenericCloud-Base.latest.x86_64.qcow2"
TID=1009 # Template ID
SIZE=50G # Disk size
RAM=2048 # Memory in MB
CORES=2 # CPU cores
BRIDGE=vmbr0 # Network bridge
STORAGE=local-lvm # Storage pool
CUSER="rocky"
CPASS="rocky"
apt update
apt install libguestfs-tools -y
virt-customize -a ${IMAGE} --install vim,bash-completion,wget,curl,qemu-guest-agent
virt-customize -a ${IMAGE} --run-command 'systemctl enable qemu-guest-agent'
virt-customize -a ${IMAGE} --timezone "UTC"
virt-customize -a $IMAGE --selinux-relabel
virt-customize -a $IMAGE --run-command ' sed -i "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config'
qm create $TID --memory $RAM --cores $CORES --net0 virtio,bridge=$BRIDGE --scsihw virtio-scsi-pci --cpu host
qemu-img resize ${IMAGE} $SIZE
qm importdisk $TID ${IMAGE} $STORAGE
qm set $TID --scsihw virtio-scsi-pci --virtio0 $STORAGE:vm-$TID-disk-0
qm set $TID --ide2 $STORAGE:cloudinit --boot c --bootdisk virtio0 --serial0 socket --vga serial0 --agent 1
qm set $TID --ipconfig0 ip=dhcp --cipassword "${CPASS}" --ciuser "${CUSER}"
qm set $TID --name Rocky-10-Template
mkdir -p "/var/lib/vz/snippets"
cp -vf home-assistant-user-data.yml /var/lib/vz/snippets/custom_cloudinit_rocky10_ha.yml
qm set $TID --cicustom "user=local:snippets/custom_cloudinit_rocky10_ha.yml"
qm template $TID

View File

@ -0,0 +1,42 @@
#cloud-config
users:
- name: homeadmin
ssh-authorized-keys:
- ssh-ed25519 A... e@d
sudo: ALL=(ALL) NOPASSWD:ALL
groups: sudo, wheel
shell: /bin/bash
package_update: true
package_upgrade: true
packages:
- yum-utils
- device-mapper-persistent-data
- lvm2
- kernel-modules-extra
- iptables-services
timezone: UTC
runcmd:
- dnf install -y kernel-modules-extra-$(uname -r)
- dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
- systemctl enable --now docker
- mkdir -p /opt/homeassistant
- cd /opt/homeassistant && docker compose up -d
write_files:
- path: /opt/homeassistant/docker-compose.yaml
content: |
services:
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
volumes:
- /opt/homeassistant/config:/config
- /etc/localtime:/etc/localtime:ro
restart: always
privileged: true
network_mode: host