Skip to content

Commit

Permalink
Merge pull request #6 from andreygubarev/feature-qemu-shared-cache
Browse files Browse the repository at this point in the history
feature qemu shared cache
  • Loading branch information
andreygubarev authored May 30, 2023
2 parents d09f9ee + 0cecbd0 commit 313a56c
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions molecule_qemu/playbooks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) }}",

Expand Down Expand Up @@ -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/"
Expand All @@ -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
Expand Down Expand Up @@ -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 %}
Expand Down

0 comments on commit 313a56c

Please sign in to comment.