aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2024-11-02 17:01:23 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2024-11-02 17:01:42 +0100
commit6bafe8d69bb160f83b0a72cd601c58cd017b1ac2 (patch)
tree42ce72fb62059b8121787a4bb14f6e17e64693a4
parentab2409752fc8992a172e8caffa64fa19beafbcb7 (diff)
downloadinfra-6bafe8d69bb160f83b0a72cd601c58cd017b1ac2.tar.gz
infra-6bafe8d69bb160f83b0a72cd601c58cd017b1ac2.tar.bz2
infra-6bafe8d69bb160f83b0a72cd601c58cd017b1ac2.tar.xz
infra-6bafe8d69bb160f83b0a72cd601c58cd017b1ac2.zip
new-vm
-rw-r--r--docs/new-vm.md31
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/new-vm.md b/docs/new-vm.md
new file mode 100644
index 0000000..aa02e3b
--- /dev/null
+++ b/docs/new-vm.md
@@ -0,0 +1,31 @@
+Download generic cloud image:
+
+ cd /data3/libvirt/images/pool/
+ wget https://cloud.debian.org/images/cloud/bookworm/20240717-1811/debian-12-genericcloud-amd64-20240717-1811.qcow2
+ cp debian-*.qcow2 $VM.qcow2
+ qemu-img resize $VM.qcow2 20G
+ virt-resize --expand /dev/sda1 debian-*.qcow2 danneri.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.
+
+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