From 6dc98dc31b98caf2dfa50c6e4ac5f779d50cd999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mart=C3=ADn?= Date: Mon, 27 Nov 2023 14:05:49 +0100 Subject: [PATCH 1/3] image_template: allow to setup template version name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- roles/image_template/README.md | 1 + roles/image_template/defaults/main.yml | 1 + roles/image_template/tasks/qcow2_image.yml | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/image_template/README.md b/roles/image_template/README.md index 16d56695..63ecca79 100644 --- a/roles/image_template/README.md +++ b/roles/image_template/README.md @@ -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: diff --git a/roles/image_template/defaults/main.yml b/roles/image_template/defaults/main.yml index db3f2234..8a6c35b5 100644 --- a/roles/image_template/defaults/main.yml +++ b/roles/image_template/defaults/main.yml @@ -16,6 +16,7 @@ template_nics: profile_name: ovirtmgmt interface: virtio template_seal: true +template_version_name: "base version" disk_resize_timeout: 60 disk_storage_domain: null diff --git a/roles/image_template/tasks/qcow2_image.yml b/roles/image_template/tasks/qcow2_image.yml index 6f2ad16e..871566e6 100644 --- a/roles/image_template/tasks/qcow2_image.yml +++ b/roles/image_template/tasks/qcow2_image.yml @@ -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 }}\"" register: template_info tags: - ovirt-template-image @@ -230,6 +231,10 @@ cluster: "{{ template_cluster }}" timeout: "{{ template_timeout }}" seal: "{{ template_seal }}" + version: + name: "{{ template_version_name }}" + description: "{{ template_description | default(omit)}}" + operating_system: "{{ template_operating_system | default(omit)}}" when: template_info.ovirt_templates | length == 0 tags: - ovirt-template-image From 213aa32b646f696cd56db804e941957f627b4ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mart=C3=ADn?= Date: Mon, 27 Nov 2023 14:07:34 +0100 Subject: [PATCH 2/3] image_template: allow to setup template OS and description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow to setup the template Operative System and the Description. Signed-off-by: Miguel Martín --- roles/image_template/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/image_template/README.md b/roles/image_template/README.md index 63ecca79..bd807ad9 100644 --- a/roles/image_template/README.md +++ b/roles/image_template/README.md @@ -50,6 +50,8 @@ 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. | | template_version_name | "base version" | Version name of the template. Allows to create different versions of a template. | +| template_description | UNDEF | Sets the template description | +| template_operating_system | UNDEF | Sets the template Operative System | The `template_disks` List of dictionaries can contain following attributes: From 25c24718c12ac3c9a0b82291d39a35688d9312ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mart=C3=ADn?= Date: Mon, 27 Nov 2023 15:42:30 +0100 Subject: [PATCH 3/3] Add changelog for #733 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miguel Martín --- .../fragments/733-enable-image-template-version-name.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/733-enable-image-template-version-name.yml diff --git a/changelogs/fragments/733-enable-image-template-version-name.yml b/changelogs/fragments/733-enable-image-template-version-name.yml new file mode 100644 index 00000000..4e371ab8 --- /dev/null +++ b/changelogs/fragments/733-enable-image-template-version-name.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - image_template - Support `template_version_name`, `template_description` and `template_operative_system`. (https://github.com/oVirt/ovirt-ansible-collection/pull/733)