diff --git a/molecule_qemu/playbooks/create.yml b/molecule_qemu/playbooks/create.yml index 60eb590..6b432b8 100644 --- a/molecule_qemu/playbooks/create.yml +++ b/molecule_qemu/playbooks/create.yml @@ -6,6 +6,7 @@ vars: molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}" + molecule_driver_directory: "{{ ( molecule_ephemeral_directory + '/../../.qemu/' ) | realpath }}" molecule_scenario_name: "{{ lookup('env', 'MOLECULE_SCENARIO_NAME') }}" molecule_project_name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" qemu_cap_hvf: false @@ -23,6 +24,7 @@ "name": "{{ item.name }}", "image": "{{ item.image }}", + "image_checksum": "{{ item.image_checksum | default(omit) }}", "image_arch": "{{ item.image_arch | default(qemu_vm_image_arch) }}", "image_format": "{{ item.image_format | default(qemu_vm_image_format) }}", @@ -79,6 +81,13 @@ when: hv_support is defined ### prerequisites ######################################################### + + - name: Create driver directory + ansible.builtin.file: + path: "{{ molecule_driver_directory }}" + state: directory + mode: "0755" + - name: Create run directory ansible.builtin.file: path: "{{ molecule_ephemeral_directory }}/run/" @@ -94,30 +103,32 @@ - name: Fetch ARM VMs bios ansible.builtin.get_url: url: "https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd" - dest: "{{ molecule_ephemeral_directory }}/run/QEMU_EFI.fd" + checksum: "sha256:42f915c44de6858f69ae6f1ffc9eaa3884d1b2ca97a7537d81312fb0dfd712cd" + dest: "{{ molecule_driver_directory }}/QEMU_EFI.fd" mode: "0644" when: "'aarch64' in molecule_instances | map(attribute='image_arch') | list | unique" ### images ############################################################### - name: Create images directory ansible.builtin.file: - path: "{{ molecule_ephemeral_directory }}/run/images/" + path: "{{ molecule_driver_directory }}/images/" state: directory mode: "0755" - name: Fetch images ansible.builtin.get_url: - url: "{{ item }}" - dest: "{{ molecule_ephemeral_directory }}/run/images/{{ item | basename }}" + url: "{{ item[0] }}" + checksum: "{{ item[1] }}" + dest: "{{ molecule_driver_directory }}/images/{{ item[0] | basename }}" mode: "0644" - loop: "{{ molecule_instances | map(attribute='image') | list | unique }}" + loop: "{{ molecule_instances | map(attribute='image') | zip(molecule_instances | map(attribute='image_checksum')) | list | unique }}" loop_control: - label: "{{ item | basename }}" + label: "{{ item[0] | basename }}" register: images - name: Get images ansible.builtin.set_fact: - images: "{{ images.results | map(attribute='item') | list | zip(images.results | map(attribute='dest') | list) }}" + images: "{{ 0 | extract(images.results | map(attribute='item')) | list | zip(images.results | map(attribute='dest') | list) }}" images_cache: {} - name: Set images cache @@ -197,7 +208,7 @@ -daemonize -pidfile {{ item.path_pid }} {% if item.image_arch == 'aarch64' %} - -bios {{ molecule_ephemeral_directory }}/run/QEMU_EFI.fd + -bios {{ molecule_driver_directory }}/QEMU_EFI.fd -cpu cortex-a72 -machine virt,highmem=off {% if qemu_cap_hvf %}