Last active
December 23, 2024 16:46
-
-
Save kkroesch/282d2c5fb44ae22daa4b0942313942cc to your computer and use it in GitHub Desktop.
Provision QEMU Debian images.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image_name := "debian.qcow2" | |
set shell := ["bash", "-cu"] | |
ansible_password := `(openssl rand -base64 12)` | |
download: | |
@curl -Lo {{image_name}} https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-amd64.qcow2 | |
prepare: | |
@echo {{ansible_password}} > .password | |
@virt-customize -a {{image_name}} --update \ | |
--install openssh-server \ | |
--run-command "systemctl enable ssh" \ | |
--run-command "useradd -m -s /bin/bash -G sudo ansible" --password "ansible:password:{{ansible_password}}" \ | |
--ssh-inject ansible:file:$HOME/.ssh/id_ed25519.pub \ | |
--root-password locked:disabled \ | |
--upload keyboard:/etc/default/ \ | |
--hostname debian12 | |
install: | |
virt-install \ | |
--name Debian12 \ | |
--ram 2048 \ | |
--vcpus 2 \ | |
--disk path={{image_name}},format=qcow2 \ | |
--os-variant debian12 \ | |
--import \ | |
--network network=default \ | |
--graphics none \ | |
--noautoconsole \ | |
--qemu-commandline='-monitor unix:/tmp/mon_debian12.sock,server,nowait' | |
@virsh domifaddr Debian12 | awk '/ipv4/ { split($4,f,"/"); print f[1]; }' | |
uninstall: | |
virsh destroy Debian12 | |
virsh undefine Debian12 | |
connect: | |
virsh console Debian12 | |
monitor node: | |
socat UNIX-CONNECT:/tmp/mon_{{node}}.sock STDIO | |
cluster: | |
#!/bin/bash | |
vinstall() { | |
hostname=$1 | |
hostimage="$1-{{image_name}}" | |
echo cp {{image_name}} $hostimage | |
echo virt-customize -a $hostimage --hostname $1 | |
mon_command="'-monitor unix:/tmp/mon_$1.sock,server,nowait'" | |
echo virt-install \ | |
--name $1 \ | |
--ram 2048 \ | |
--vcpus 2 \ | |
--disk path=$hostimage,format=qcow2 \ | |
--os-variant debian12 \ | |
--import \ | |
--network network=default \ | |
--graphics none \ | |
--noautoconsole \ | |
--qemu-commandline=$mon_command | |
} | |
for node in jump ctrl1 ctrl2 work1 work2 work3; do | |
echo "Creating $node-{{image_name}}" | |
vinstall $node | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# KEYBOARD CONFIGURATION FILE | |
# Consult the keyboard(5) manual page. | |
XKBMODEL="pc105" | |
XKBLAYOUT="ch" | |
XKBVARIANT="de" | |
XKBOPTIONS="lv3:ralt_switch,compose:rctrl" | |
BACKSPACE="guess" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment