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 ------------------ 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: 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 %}