Last active
January 11, 2024 07:07
-
-
Save cristiklein/7219589c7f1e728b1cb6e872e6dbe5e9 to your computer and use it in GitHub Desktop.
Short script to quickly test cloud-init configuration files
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
#!/bin/bash | |
set -e | |
IMAGE_URL=https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img | |
IMAGE_FILE=$(basename $IMAGE_URL) | |
if [ ! -e $IMAGE_FILE ]; then | |
wget $IMAGE_URL | |
fi | |
rm -rf vm1.qcow2 | |
qemu-img create -f qcow2 -b $IMAGE_FILE vm1.qcow2 20G | |
cat >meta-data <<EOF | |
local-hostname: instance-1 | |
EOF | |
cat >user-data <<EOF | |
#cloud-config | |
password: blahblah000 | |
#growpart: | |
# mode: off # disable root partition resizing | |
#resize_rootfs: false # disable root filesystem resize operation | |
runcmd: | |
- lsblk | |
- df -h | |
# - poweroff | |
EOF | |
genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data | |
kvm -m 256 \ | |
-net nic -net user,hostfwd=tcp::2222-:22 \ | |
-drive file=vm1.qcow2,if=virtio \ | |
-drive file=seed.iso,if=virtio \ | |
-nographic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment