true autoinstall

autoautoinstall
Daniel Liu 1 year ago
parent f4f973327c
commit b05ebe8013
  1. 28
      qemu/main.yml

@ -13,11 +13,21 @@
path: "{{playbook_dir}}/files/ubuntu20_04.iso"
register: isoexists
ignore_errors: true
- name: Check for ubuntu iso seed
- name: Check for seed iso
stat:
path: "{{userdata}}/seed.iso"
register: seedexists
ignore_errors: true
- name: Check for extracted linux kernel
stat:
path: "{{userdata}}/vmlinuz"
register: kernelexists
ignore_errors: true
- name: Check for extracted initrd
stat:
path: "{{userdata}}/initrd"
register: initrdexists
ignore_errors: true
# Setting up VM
- name: Create directory for VM
@ -40,6 +50,16 @@
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: Extracting linux kernel from iso
shell:
cmd: "isoinfo -i {{playbook_dir}}/files/ubuntu20_04.iso -R -x /casper/vmlinuz > {{userdata}}/vmlinuz"
when: kernelexists.stat.exists == false
- name: Extracting initrd from iso
shell:
cmd: "isoinfo -i {{playbook_dir}}/files/ubuntu20_04.iso -R -x /casper/initrd > {{userdata}}/initrd"
when: initrdexists.stat.exists == false
- name: Starting autoinstallation
shell:
cmd: "qemu-system-x86_64 -cdrom {{playbook_dir}}/files/ubuntu20_04.iso \
@ -52,7 +72,9 @@
-drive file={{userdata}}/drive6,if=virtio,id=f,media=disk,format=qcow2 \
-drive file={{userdata}}/seed.iso,if=virtio,format=raw \
-bios {{ovmf}} \
-m {{vm_ram}}"
-m {{vm_ram}} \
-kernel {{userdata}}/vmlinuz \
-initrd {{userdata}}/initrd \
-append autoinstall"
# todo: find a way to not ask for confirmation to start autoinstall
# bug: autoinstall will not shutdown properly so the ansible task will never finish

Loading…
Cancel
Save