From 7e0d720914196e780a433eac266506e7b13db3ab Mon Sep 17 00:00:00 2001 From: Christian Iuga Date: Fri, 11 Sep 2020 16:11:04 +0200 Subject: [PATCH 1/3] for LVM disk, use `source dev=/dev//` --- templates/vm.xml.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/vm.xml.j2 b/templates/vm.xml.j2 index 67e3570..f56ed5d 100644 --- a/templates/vm.xml.j2 +++ b/templates/vm.xml.j2 @@ -40,6 +40,8 @@ {% if volume.type | default(libvirt_volume_default_type) == 'file' %} + {% elif volume.pool is defined %} + {% elif volume.type is defined and volume.type == 'network' %} {% if volume.auth.username is defined %} From 3d7ba97491074d8893d090669306e16433496bbb Mon Sep 17 00:00:00 2001 From: Christian Iuga Date: Fri, 11 Sep 2020 16:12:27 +0200 Subject: [PATCH 2/3] for lvm disk, use the Ensure the VM disk volumes exist So uptdate the when condition to avoid skiping tasks --- tasks/volumes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/volumes.yml b/tasks/volumes.yml index c9aa3db..2020219 100644 --- a/tasks/volumes.yml +++ b/tasks/volumes.yml @@ -27,7 +27,7 @@ {% endif %} -a {{ ansible_check_mode }} with_items: "{{ volumes }}" - when: item.type | default(libvirt_volume_default_type) == 'volume' + when: item.type | default(libvirt_volume_default_type) == 'volume' or ( item.type | default(libvirt_volume_default_type) == 'block' and item.pool is defined ) environment: "{{ libvirt_vm_script_env }}" register: volume_result changed_when: From ec44757929b5ec0291e66a8d876fbd77e5339f7c Mon Sep 17 00:00:00 2001 From: Christian Iuga Date: Fri, 11 Sep 2020 16:13:50 +0200 Subject: [PATCH 3/3] add a exemple to create a node with lvm backend as disk and a debian netinstall as CDROM --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f9b35f..08ccf3b 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ Example Playbook - 'mon1.example.org' - 'mon2.example.org' - 'mon3.example.org' - + interfaces: - network: 'br-datacentre' @@ -236,6 +236,22 @@ Example Playbook source: dev: 'br-datacentre' + - state: present + name: 'vm3' + memory_mb: 1024 + vcpus: 1 + volumes: + - name: 'lv_vm3' + type: 'block' + capacity: '10GB' + pool: 'lvm_pool' + format: 'raw' + - name: 'debian-10.5.0-amd64-netinst.iso' + type: 'file' + device: 'cdrom' + format: 'raw' + interfaces: + - network: 'test' Author Information ------------------