fix qemu vm not installing
This commit is contained in:
parent
c1fb658ba3
commit
f72458a7b6
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
ovmf:
|
# set this depending on your system
|
||||||
vm_ram: 1G
|
ovmf: /usr/share/edk2-ovmf/x64/OVMF_CODE.fd
|
||||||
vm_disk_size: 9G
|
vm_ram: 3G
|
||||||
vm_ssh_port: 22
|
vm_disk_size: 10G
|
||||||
|
vm_ssh_port: 7777 # vm doesn't seem to start with 22, leaving this here for now
|
||||||
userdata: "{{playbook_dir}}/userdata"
|
userdata: "{{playbook_dir}}/userdata"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# Gather info
|
# Gather info
|
||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
tasks:
|
tasks:
|
||||||
|
# make this check for the actual drive* files probably
|
||||||
- name: Check if vm was created already
|
- name: Check if vm was created already
|
||||||
stat:
|
stat:
|
||||||
path: "{{userdata}}"
|
path: "{{userdata}}"
|
||||||
|
@ -30,7 +31,7 @@
|
||||||
command: curl -o "{{playbook_dir}}/files/ubuntu20_04.iso" https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso
|
command: curl -o "{{playbook_dir}}/files/ubuntu20_04.iso" https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso
|
||||||
when: isoexists.stat.exists == false
|
when: isoexists.stat.exists == false
|
||||||
|
|
||||||
- name: Create disk images
|
- name: "Create disk images"
|
||||||
shell:
|
shell:
|
||||||
cmd: "for i in {1..6}; do qemu-img create -f qcow2 {{userdata}}/drive${i} {{vm_disk_size}}; done"
|
cmd: "for i in {1..6}; do qemu-img create -f qcow2 {{userdata}}/drive${i} {{vm_disk_size}}; done"
|
||||||
when: vmexists.stat.exists == false
|
when: vmexists.stat.exists == false
|
||||||
|
|
36
qemu/run.yml
36
qemu/run.yml
|
@ -1,18 +1,20 @@
|
||||||
---
|
---
|
||||||
- name: Start VM
|
- hosts: localhost
|
||||||
# async: 10000
|
tasks:
|
||||||
# poll: 0
|
- name: Start VM
|
||||||
shell:
|
# async: 10000
|
||||||
cmd: "qemu-system-x86_64 \
|
# poll: 0
|
||||||
-enable-kvm -boot order=d \
|
shell:
|
||||||
-drive file={{userdata}}/drive1,if=virtio,id=a,media=disk,format=qcow2 \
|
cmd: "qemu-system-x86_64 \
|
||||||
-drive file={{userdata}}/drive2,if=virtio,id=b,media=disk,format=qcow2 \
|
-enable-kvm -boot order=d \
|
||||||
-drive file={{userdata}}/drive3,if=virtio,id=c,media=disk,format=qcow2 \
|
-drive file={{userdata}}/drive1,if=virtio,id=a,media=disk,format=qcow2 \
|
||||||
-drive file={{userdata}}/drive4,if=virtio,id=d,media=disk,format=qcow2 \
|
-drive file={{userdata}}/drive2,if=virtio,id=b,media=disk,format=qcow2 \
|
||||||
-drive file={{userdata}}/drive5,if=virtio,id=e,media=disk,format=qcow2 \
|
-drive file={{userdata}}/drive3,if=virtio,id=c,media=disk,format=qcow2 \
|
||||||
-drive file={{userdata}}/drive6,if=virtio,id=f,media=disk,format=qcow2 \
|
-drive file={{userdata}}/drive4,if=virtio,id=d,media=disk,format=qcow2 \
|
||||||
-drive file={{userdata}}/seed.iso,if=virtio,format=raw \
|
-drive file={{userdata}}/drive5,if=virtio,id=e,media=disk,format=qcow2 \
|
||||||
-bios {{ovmf}} \
|
-drive file={{userdata}}/drive6,if=virtio,id=f,media=disk,format=qcow2 \
|
||||||
-m {{vm_ram}} \
|
-drive file={{userdata}}/seed.iso,if=virtio,format=raw \
|
||||||
-net user,hostfwd=tcp::{{vm_ssh_port}}-:22 \
|
-bios {{ovmf}} \
|
||||||
-net nic"
|
-m {{vm_ram}} \
|
||||||
|
-net user,hostfwd=tcp::{{vm_ssh_port}}-:22 \
|
||||||
|
-net nic"
|
||||||
|
|
Loading…
Reference in New Issue