From 77e0ca4c3b5974777dff00b3e3c0baf209f8ed9b Mon Sep 17 00:00:00 2001 From: Will Miller Date: Thu, 23 Aug 2018 11:38:13 +0000 Subject: [PATCH] Extract volume defaults Pull out volume defaults from templates into the defaults file, to ensure the role is kept DRY. --- defaults/main.yml | 6 ++++++ tasks/volumes.yml | 2 +- templates/vm.xml.j2 | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 909d982..027618d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,6 +4,12 @@ # file path is not given. libvirt_vm_default_console_log_dir: "/var/log/libvirt-consoles/" +# The default format for Libvirt volumes. +libvirt_volume_default_format: qcow2 + +# The default device for Libvirt volumes. +libvirt_volume_default_device: disk + # Path to cache downloaded images. libvirt_image_cache_path: "/tmp/" diff --git a/tasks/volumes.yml b/tasks/volumes.yml index 1c49872..7422d5b 100644 --- a/tasks/volumes.yml +++ b/tasks/volumes.yml @@ -19,7 +19,7 @@ {{ item.name }} {{ item.pool }} {{ item.capacity }} - {{ item.format | default('qcow2') }} + {{ item.format | default(libvirt_volume_default_format) }} {% if item.image is defined %} {{ libvirt_vm_image_cache_path }}/{{ item.image | basename }} {% endif %} diff --git a/templates/vm.xml.j2 b/templates/vm.xml.j2 index 9aed95d..987c147 100644 --- a/templates/vm.xml.j2 +++ b/templates/vm.xml.j2 @@ -19,8 +19,8 @@ {{ libvirt_vm_emulator }} {% for volume in volumes %} - - + +