fix: virt customize bootstrap

This commit is contained in:
Matthieu Bessat 2024-06-21 11:44:40 +02:00
parent 30c76bf9c5
commit abdac550e6
4 changed files with 28 additions and 4 deletions

15
README.md Normal file
View file

@ -0,0 +1,15 @@
# Debian VM auto setup
## Methods
- Preseed
- Cloud-init
- Virt-customize
## Tips
### Connect to guest machine via SSH
```
ssh -v -p 2222 root@localhost -i ./sandbox -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
```

View file

@ -0,0 +1,10 @@
#!/usr/bin/sh
set -x
chown root:root /root/.ssh/root
netplan apply
ssh-keygen -A
systemctl restart sshd
date --iso-8601=s > /root/init_date.txt

View file

@ -10,6 +10,5 @@ virt-customize \
--hostname "sandbox05" \
--firstboot-install "procps,psmisc,vim,net-tools,curl,dnsutils,file,tmux" \
--copy-in "$base/netplan:/etc" \
--copy-in "$base/.ssh:/root" \
--firstboot-command 'netplan apply && ssh-keygen -A && systemctl restart sshd'
--firstboot "../guest_bootstrap.sh"

View file

@ -1,9 +1,9 @@
cd vm
qemu-system-x86_64 \
-net nic \
-net user \
-machine accel=kvm \
-cpu host \
-m 512 \
-nographic \
-hda ./debian-12-generic-amd64.qcow2
-hda ./debian-12-generic-amd64.qcow2 \
-net user,hostfwd=tcp::2222-:22