aboutsummaryrefslogtreecommitdiff
path: root/docs/new-vm.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/new-vm.md')
-rw-r--r--docs/new-vm.md37
1 files changed, 37 insertions, 0 deletions
diff --git a/docs/new-vm.md b/docs/new-vm.md
new file mode 100644
index 0000000..76e4eea
--- /dev/null
+++ b/docs/new-vm.md
@@ -0,0 +1,37 @@
+Download generic cloud image:
+
+ cd /data3/libvirt/images/pool/
+ export TS=20240717-1811
+ wget https://cloud.debian.org/images/cloud/bookworm/$TS/debian-12-genericcloud-amd64-$TS.qcow2
+ cp debian-*-$TS.qcow2 $VM.qcow2
+ qemu-img resize $VM.qcow2 20G
+ # This requires guestfs-tools
+ virt-resize --expand /dev/sda1 debian-*$TS.qcow2 $VM.qcow2
+
+Inject SSH key for root user:
+
+ virt-customize \
+ --add /data3/libvirt/images/pool/$VM.qcow2 \
+ --root-password password:root \
+ --hostname $VM \
+ --firstboot-command 'ssh-keygen -A && systemctl restart sshd' \
+ --ssh-inject "root:file:$(echo ~trygvis/.ssh/id_ed25519.pub)"
+
+Register a new VM with Virtual Machine Manager.
+
+ * Import existing disk image
+ * Select $VM.qcow2, select correct OS
+ * Set name to $VM, use "Bridge device", enter `br0`.
+
+Connect to the machine, log in as root/root and run `dhclient enp1s0`.
+
+Add host to Ansible inventory `ansible/inventory`.
+
+SSH to the host first so the host's fingerprint is saved:
+
+ ssh $VM
+
+Apply users playbook:
+
+ ansible-playbook ansible/plays/users.yml -l $VM -u root -k
+ ansible-playbook plays/danneri.yml