fixed variables in qemu

This commit is contained in:
Daniel Liu 2021-09-25 23:52:25 -04:00
parent 884c437e7b
commit 1f966eedd0
7 changed files with 12 additions and 23 deletions

View File

@ -1,2 +1,2 @@
[defaults]
inventory = hosts.yml
inventory = hosts

View File

View File

@ -1,10 +0,0 @@
# not required for libvirt
# ovmf: /usr/share/edk1-ovmf/x64/OVMF_CODE.fd
ovmf:
vm_ram: 1G
userdata: "{{ playbook_dir }}/userdata"
vm_disk_size: 9G
vm_ssh_port: 22
# need to redo variables
# not being called correctly in playbooks

View File

2
hosts
View File

@ -7,4 +7,4 @@
# guide on how to create vm manually (more control, more disks)
# another playbook that runs on such a vm and sets up all the services in roles (except zfs)
[local]
127.0.0.1 ansible_connection=local
127.0.0.1 ansible_connection=local

View File

@ -1,7 +0,0 @@
all:
local:
hosts:
localhost:
vm:
hosts:
ubuntu@localhost:

View File

@ -1,6 +1,12 @@
---
# Gather info
- hosts: localhost
vars:
ovmf:
vm_ram: 1G
vm_disk_size: 9G
vm_ssh_port: 22
userdata: "{{playbook_dir}}/userdata"
tasks:
- name: Check if vm was created already
stat:
@ -9,7 +15,7 @@
ignore_errors: true
- name: Check for ubuntu iso
stat:
path: "{{role_path}}/files/ubuntu20_04.iso"
path: "{{playbook_dir}}/files/ubuntu20_04.iso"
register: isoexists
ignore_errors: true
- name: Check for ubuntu iso seed
@ -27,7 +33,7 @@
# didn't use get_url module since it broke with symlinks
- name: Fetching ubuntu iso
command: curl -o "{{role_path}}/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
- name: Create disk images
@ -36,12 +42,12 @@
when: vmexists.stat.exists == false
- name: Creating cloud-init iso
command: "genisoimage -output {{userdata}}/seed.iso -volid cidata -joliet -rock {{role_path}}/files/user-data {{role_path}}/files/meta-data"
command: "genisoimage -output {{userdata}}/seed.iso -volid cidata -joliet -rock {{playbook_dir}}/files/user-data {{playbook_dir}}/files/meta-data"
when: seedexists.stat.exists == false
- name: Starting autoinstallation
shell:
cmd: "qemu-system-x86_64 -cdrom {{role_path}}/files/ubuntu20_04.iso \
cmd: "qemu-system-x86_64 -cdrom {{playbook_dir}}/files/ubuntu20_04.iso \
-enable-kvm -boot order=d \
-drive file={{userdata}}/drive1,if=virtio,id=a,media=disk,format=qcow2 \
-drive file={{userdata}}/drive2,if=virtio,id=b,media=disk,format=qcow2 \