From 069bf3bd20d370d8c9ef5fb50963ee7c80be8b43 Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Thu, 28 Mar 2024 15:05:56 -0600 Subject: [PATCH] Parameterize libvirt image attributes --- galaxy.yml | 2 +- molecule/common/create.yml | 5 ++++- molecule/common/templates/vm.j2.xml | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/galaxy.yml b/galaxy.yml index 7df1fb9..45c2349 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,7 +1,7 @@ --- namespace: nephelaiio name: mongodb -version: 0.2.21 +version: 0.2.22 readme: README.md authors: - Ted Cook diff --git a/molecule/common/create.yml b/molecule/common/create.yml index f4511a1..44d1390 100644 --- a/molecule/common/create.yml +++ b/molecule/common/create.yml @@ -119,7 +119,6 @@ - name: Manage KVM guests when: inventory_hostname not in guest_query.stdout_lines block: - - name: Create KVM guest disks ansible.builtin.copy: remote_src: true @@ -182,12 +181,16 @@ xml: "{{ lookup('ansible.builtin.template', 'vm.j2.xml') }}" command: define vars: + _platforms: "{{ molecule_yml.platforms }}" + _platform: "{{ _platforms | selectattr('name', 'equalto', inventory_hostname) | first }}" guest_hostname: "{{ inventory_hostname }}" guest_disk_format: qcow2 guest_disk_path: "{{ _libvirt_path }}/{{ inventory_hostname }}.img" guest_iso_path: "{{ _libvirt_path }}/{{ inventory_hostname }}.iso" guest_network: "{{ _libvirt_network }}" guest_mac: "{{ '52:54:00' | random_mac(seed=guest_hostname) }}" + guest_mem: "{{ (_platform.mem | default(2)) * 1048576 }}" + guest_cpu: "{{ _platform.cpu | default(2) }}" loop_control: label: "{{ inventory_hostname }} - {{ _libvirt_path }}/{{ inventory_hostname }}.img" diff --git a/molecule/common/templates/vm.j2.xml b/molecule/common/templates/vm.j2.xml index a314e04..7f3645e 100644 --- a/molecule/common/templates/vm.j2.xml +++ b/molecule/common/templates/vm.j2.xml @@ -1,8 +1,8 @@ {{ guest_hostname }} - 4194304 - 4194304 - 2 + {{ guest_memory }} + {{ guest_memory }} + {{ guest_cpu }} /machine