mirror of
https://github.com/Noratrieb/vmlab.git
synced 2026-01-14 08:35:11 +01:00
install works
This commit is contained in:
parent
f6c4997f01
commit
c27807e86f
2 changed files with 36 additions and 6 deletions
25
create-vms.sh
Normal file → Executable file
25
create-vms.sh
Normal file → Executable file
|
|
@ -2,25 +2,42 @@
|
|||
|
||||
set -eu
|
||||
|
||||
DIR="$(dirname "$(realpath "$0")")"
|
||||
|
||||
NAME="$1"
|
||||
|
||||
mkdir -p tmp
|
||||
mkdir -p vm-state
|
||||
|
||||
IMG=debian-12-genericcloud-amd64.qcow2
|
||||
# https://mop.koeln/blog/creating-a-local-debian-vm-using-cloud-init-and-libvirt/
|
||||
# > DO NOT DOWNLOAD THE GENERICCLOUD IMAGE
|
||||
IMG=debian-12-generic-amd64.qcow2
|
||||
|
||||
if ! [ -f "tmp/$IMG" ]; then
|
||||
curl -L -o "tmp/$IMG" https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2
|
||||
curl -L -o "tmp/$IMG" https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
|
||||
fi
|
||||
|
||||
DISK="vm-state/$NAME.qcow2"
|
||||
cp "tmp/$IMG" "$DISK"
|
||||
|
||||
meta_data=$(mktemp)
|
||||
|
||||
cat >"$meta_data" <<EOF
|
||||
instance-id: $NAME
|
||||
local-hostname: $NAME
|
||||
EOF
|
||||
|
||||
virt-install -n "$NAME" \
|
||||
--os-variant=debian12 \
|
||||
--ram=2048 --vcpus=2 \
|
||||
--import --disk "path=$DISK,bus=virtio" \
|
||||
--network network=default,model=virtio \
|
||||
--graphics=none --rng /dev/urandom \
|
||||
--cloud-init=user-data=user-data
|
||||
#--noautoconsole
|
||||
"--cloud-init=user-data=$DIR/user-data,meta-data=$meta_data" \
|
||||
--noautoconsole
|
||||
|
||||
rm "$meta_data"
|
||||
|
||||
echo "Successfully created $NAME"
|
||||
|
||||
virsh domifaddr "$NAME"
|
||||
|
|
|
|||
17
user-data
17
user-data
|
|
@ -1,2 +1,15 @@
|
|||
ssh_authorized_keys:
|
||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG0n1ikUG9rYqobh7WpAyXrqZqxQoQ2zNJrFPj12gTpP nilsh@PC-Nils
|
||||
#cloud-config
|
||||
|
||||
chpasswd:
|
||||
list: |
|
||||
root: hello-world123
|
||||
expire: false
|
||||
|
||||
users:
|
||||
- name: chef
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
shell: /bin/bash
|
||||
ssh_authorized_keys:
|
||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG0n1ikUG9rYqobh7WpAyXrqZqxQoQ2zNJrFPj12gTpP nilsh@PC-Nils
|
||||
|
||||
ssh_pwauth: true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue