Created
November 22, 2014 22:06
-
-
Save cgwalters/a366c14b2fc58e0f7367 to your computer and use it in GitHub Desktop.
create-cloud-vm.sh
This file contains 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/sh | |
# Clone a copy-on-write "gold" cloud image, resize it to the target, and | |
# use virt-install to create a VM, attaching a cloud-init metadata ISO. | |
# Run in /var/lib/libvirt/images | |
img=$1 | |
shift | |
name=$1 | |
shift | |
size=$1 | |
shift | |
set -e | |
set -x | |
disk=$(pwd)/$name.qcow2 | |
qemu-img create -f qcow2 -o "backing_file=$img" "$disk" $size | |
exec virt-install --force --noautoconsole --name "$name" --ram 1024 --import --disk=${disk} --disk=$(pwd)/gold/insecure-vagrant-userdata.iso,device=cdrom "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment