Script creating new VMs #252

Merged
raucao merged 16 commits from feature/244-new_vm_script into master 2020-12-09 15:33:08 +00:00
2 changed files with 15 additions and 5 deletions
Showing only changes of commit 6f7b493173 - Show all commits

View File

@ -1,11 +1,6 @@
#!/bin/bash
set -e
# The base VM was downloaded using the following commands:
# mkdir /var/lib/libvirt/images/base
# curl -o http://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img /var/lib/libvirt/images/base/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.qcow2
# chown -R libvirt-qemu:root /var/lib/libvirt/images/base
if [[ $# -eq 0 ]] ; then
echo 'USAGE: create_vm VMNAME'
exit 1

This doesn't look right to me. It would attempt to download the path as a second file, no? The pathname should come after the -o flag.

However, why not just use a normal file download resource in the KVM host recipe in the first place? Same amount of characters as this extended comment, but then it's automated and handles existing files.

This doesn't look right to me. It would attempt to download the path as a second file, no? The pathname should come after the `-o` flag. However, why not just use a normal file download resource in the KVM host recipe in the first place? Same amount of characters as this extended comment, but then it's automated and handles existing files.

View File

@ -26,6 +26,21 @@
package %w(virtinst libvirt-daemon-system)
directory "/var/lib/libvirt/images/base" do
recursive true
owner "libvirt-qemu"
group "root"
mode "0750"
end
# Base Ubuntu 20.04 image
remote_file "/var/lib/libvirt/images/base/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.qcow2" do
source "http://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img"
owner "libvirt-qemu"
group "root"
mode "0640"
end
cookbook_file "/usr/local/sbin/create_vm" do
source "create_vm"
mode "0750"