true autoinstall

This commit is contained in:
Daniel Liu 2021-09-29 19:49:39 -04:00
parent f4f973327c
commit b05ebe8013
1 changed files with 25 additions and 3 deletions

View File

@ -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