Skip to content

Commit

Permalink
image_template: allow to setup template version name
Browse files Browse the repository at this point in the history
Allow to create templates with the same name but with
different version by setting up the `template_version_name`
variable. Creating a new version requires the base template
to exist. If not specified the value of the variable is
`base version` which is the default value for base templates.

Signed-off-by: Miguel Martín <[email protected]>
  • Loading branch information
mmartinv committed Nov 27, 2023
1 parent b23df55 commit 065d4da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions roles/image_template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Role Variables
| glance_image_provider | UNDEF (mandatory if qcow_url is not used) | Name of the glance image provider. |
| 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. |
| template_version_name | "base version" | Version name of the template. Allows to create different versions of a template. |

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

Expand Down
5 changes: 4 additions & 1 deletion roles/image_template/tasks/qcow2_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
- name: Check if template already exists
ovirt_template_info:
auth: "{{ ovirt_auth }}"
pattern: "name={{ template_name }} and datacenter={{ dc_info.ovirt_datacenters[0].name }}"
pattern: "name={{ template_name }} and datacenter={{ dc_info.ovirt_datacenters[0].name }}
and version_name={{ template_version_name | default('\"base version\"') }}"
register: template_info
tags:
- ovirt-template-image
Expand Down Expand Up @@ -230,6 +231,8 @@
cluster: "{{ template_cluster }}"
timeout: "{{ template_timeout }}"
seal: "{{ template_seal }}"
version:
name: "{{ { template_version_name | default('base version') }}"
when: template_info.ovirt_templates | length == 0
tags:
- ovirt-template-image
Expand Down

0 comments on commit 065d4da

Please sign in to comment.