feat: add cloud-init and virt-customize method
This commit is contained in:
parent
32bf78edbe
commit
30c76bf9c5
17 changed files with 119 additions and 0 deletions
2
virt-customize_method/.gitignore
vendored
Normal file
2
virt-customize_method/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*.qcow2
|
||||
vm
|
||||
1
virt-customize_method/.ssh/authorized_keys
Normal file
1
virt-customize_method/.ssh/authorized_keys
Normal file
|
|
@ -0,0 +1 @@
|
|||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBeNeE0gk6mO0Bz9dDvKQrhA2Oo7x05FicCQJivxqIyi sandbox
|
||||
7
virt-customize_method/README.md
Normal file
7
virt-customize_method/README.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Initial setup of debian VM with virt-customize + netplan
|
||||
|
||||
This method consist of using the debian generic cloud image and just customizing it before first boot with the [virt-customize](https://man.archlinux.org/man/virt-customize.1.en) util.
|
||||
|
||||
Then for the network config, we will be using [netplan](https://netplan.readthedocs.io/en/stable/).
|
||||
|
||||
|
||||
15
virt-customize_method/init.sh
Executable file
15
virt-customize_method/init.sh
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/sh
|
||||
base="$(pwd)"
|
||||
mkdir -p vm
|
||||
cd vm
|
||||
wget -N https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
|
||||
|
||||
virt-customize \
|
||||
--add ./debian-12-generic-amd64.qcow2 \
|
||||
--root-password password:root \
|
||||
--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'
|
||||
|
||||
9
virt-customize_method/netplan/50-dhcp.yaml
Normal file
9
virt-customize_method/netplan/50-dhcp.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
network:
|
||||
version: 2
|
||||
ethernets:
|
||||
all-en:
|
||||
match:
|
||||
name: "en*"
|
||||
dhcp4: true
|
||||
dhcp6: true
|
||||
|
||||
9
virt-customize_method/run.sh
Executable file
9
virt-customize_method/run.sh
Executable file
|
|
@ -0,0 +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
|
||||
Loading…
Add table
Add a link
Reference in a new issue