|
| 1 | +--- |
| 2 | + |
| 3 | +- name: Gather os specific variables |
| 4 | + include_vars: "{{ item }}" |
| 5 | + with_first_found: |
| 6 | + - files: |
| 7 | + - "{{ ansible_distribution }}-{{ ansible_distribution_major_version}}.yml" |
| 8 | + - "{{ ansible_distribution }}.yml" |
| 9 | + - "{{ ansible_os_family }}.yml" |
| 10 | + skip: true |
| 11 | + tags: vars |
| 12 | + |
| 13 | +- name: Ensure ovmf generator checkout directory is owned by ansible_user |
| 14 | + file: |
| 15 | + path: "{{ libvirt_ovmf_vars_generator_checkout_path }}" |
| 16 | + owner: "{{ ansible_user }}" |
| 17 | + state: directory |
| 18 | + become: true |
| 19 | + |
| 20 | +- name: Clone ovfm-vars generator |
| 21 | + git: |
| 22 | + repo: 'https://github.com/puiterwijk/qemu-ovmf-secureboot' |
| 23 | + dest: "{{ libvirt_ovmf_vars_generator_checkout_path }}" |
| 24 | + update: yes |
| 25 | + |
| 26 | +- name: Get checksum of template OVMF vars |
| 27 | + # We need to keep the generated vars in sync with templated version. |
| 28 | + # if the OVMF package is updated - we should update a new version with |
| 29 | + # the signing keys enrolled. |
| 30 | + stat: |
| 31 | + path: "{{ libvirt_vm_ovmf_efi_variable_store_path }}" |
| 32 | + get_checksum: true |
| 33 | + checksum_algorithm: sha256 |
| 34 | + register: ovmf_template |
| 35 | + |
| 36 | +- name: Register path of generated variables |
| 37 | + set_fact: |
| 38 | + ovmf_enrolled_variables_path: "\ |
| 39 | + {{ libvirt_ovmf_vars_generator_output_path }}/\ |
| 40 | + {{ libvirt_ovmf_vars_generator_output_prefix }}\ |
| 41 | + {{ ovmf_template.stat.checksum }}" |
| 42 | + |
| 43 | +- name: Check to see if we have generated these vars before |
| 44 | + stat: |
| 45 | + path: "{{ ovmf_enrolled_variables_path }}" |
| 46 | + register: generated_ovmf |
| 47 | + |
| 48 | +- name: Run OVMF vars generator |
| 49 | + command: > |
| 50 | + python {{ libvirt_ovmf_vars_generator_checkout_path}}/ovmf-vars-generator |
| 51 | + --ovmf-binary {{ libvirt_vm_ovmf_efi_firmware_path }} |
| 52 | + --uefi-shell-iso {{ libvirt_vm_ovmf_uefi_shell_iso_path }} |
| 53 | + --ovmf-template-vars {{ libvirt_vm_ovmf_efi_variable_store_path }} |
| 54 | + --qemu-binary {{ libvirt_vm_emulator }} |
| 55 | + {% if libvirt_vm_engine == 'kvm' %}--enable-kvm{% endif %} |
| 56 | + --skip-testing |
| 57 | + --no-download |
| 58 | + {{ ovmf_enrolled_variables_path }} |
| 59 | + when: not generated_ovmf.stat.exists |
0 commit comments