Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Add template disks (#50)
Browse files Browse the repository at this point in the history
* Add template disks

* add mandatory

* update docs

* update default value of tmeplate_disks in readme

* update readme
  • Loading branch information
mnecas committed Mar 20, 2020
1 parent e1f975a commit 696b627
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Role Variables
| template_memory_max | UNDEF | Upper bound of virtual machine memory up to which memory hot-plug can be performed. |
| template_cpu | 1 | Number of CPUs assigned to the template. |
| template_disk_storage | UNDEF | Name of the data storage domain where the disk must be created. If not specified, the data storage domain is selected automatically. |
| template_disks | [] | List of dictionaries specifying the additional template disks. See below for more detailed description. |
| template_disk_size | 10GiB | The size of the template disk. |
| template_disk_name | UNDEF | The name of template disk. |
| template_disk_format | UNDEF | Format of the template disk. |
Expand All @@ -68,6 +69,17 @@ Role Variables
| glance_image | UNDEF (mandatory if qcow_url is not used) | This parameter specifies the name of disk in glance provider to be imported as template. |
| template_prerequisites_tasks | UNDEF | Works only with qcow image. Specify a path to Ansible tasks file, which should be executed on virtual machine before creating a template from it. Note that qcow image must contain guest agent which reports IP address. |

The `template_disks` List of dictionaries can contain following attributes:

| Name | Default value | |
|--------------------|----------------|----------------------------------------------|
| name | UNDEF (Required) | The name of the additional disk. |
| size | UNDEF (Required) | The size of the additional disk. |
| storage_domain | UNDEF | The name of storage domain where disk should be created. If no value is passed, value is set by <i>template_disk_storage</i>. |
| interface | UNDEF | The interface of the disk. If no value is passed, value is set by <i>template_disk_interface</i>. |
| format | UNDEF | Specify format of the disk. If no value is passed, value is set by <i>template_disk_format</i>. <ul><li>cow - If set, the disk will by created as sparse disk, so space will be allocated for the volume as needed. This format is also known as thin provisioned disks</li><li>raw - If set, disk space will be allocated right away. This format is also known as preallocated disks.</li></ul> |
| bootable | UNDEF | True if the disk should be bootable. |

Dependencies
------------

Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ template_cpu: 1
template_disk_size: 10GiB
template_operating_system: rhel_7x64
template_timeout: 600
template_disks: []
template_disk_interface: virtio
template_nics:
- name: nic1
Expand Down
13 changes: 13 additions & 0 deletions tasks/qcow2_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@
interface: "{{ template_disk_interface }}"
nics: "{{ template_nics }}"

- name: Manage disks
ovirt_disk:
auth: "{{ ovirt_auth }}"
name: "{{ item.name | default(omit) }}"
size: "{{ item.size | default(omit) }}"
interface: "{{ item.interface | default(template_disk_interface) | default(omit) }}"
vm_name: "{{ vm_name }}"
format: "{{ item.format | default(template_disk_format) | default(omit) }}"
storage_domain: "{{ item.storage_domain | default(template_disk_storage) | default(omit) }}"
bootable: "{{ item.bootable | default(omit) }}"
wait: true
loop: "{{ template_disks }}"

- block:
- name: Wait for VMs IPv4
ovirt_vm_info:
Expand Down

0 comments on commit 696b627

Please sign in to comment.