From c503f38bb14c9ef123d6c5be642ab7034593abcf Mon Sep 17 00:00:00 2001 From: Niek Beernink Date: Sun, 10 Nov 2024 19:16:20 +0100 Subject: [PATCH] Add support for building ova images --- .azure-pipelines/azure-pipelines.yml | 18 ++++++++++++++ .../fragments/311-add_ova_image_support.yaml | 3 +++ plugins/modules/start_compose.py | 3 +++ .../targets/compose_type-ova/aliases | 8 +++++++ .../targets/compose_type-ova/tasks/main.yml | 24 +++++++++++++++++++ .../targets/compose_type-ova/tasks/tests.yml | 17 +++++++++++++ .../targets/compose_type-ova/vars/main.yml | 12 ++++++++++ 7 files changed, 85 insertions(+) create mode 100644 changelogs/fragments/311-add_ova_image_support.yaml create mode 100644 tests/integration/targets/compose_type-ova/aliases create mode 100644 tests/integration/targets/compose_type-ova/tasks/main.yml create mode 100644 tests/integration/targets/compose_type-ova/tasks/tests.yml create mode 100644 tests/integration/targets/compose_type-ova/vars/main.yml diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 1f385756..314c2c3c 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -365,6 +365,14 @@ stages: # test: rhel/8.8/ groups: - 19 + - template: templates/matrix.yml + parameters: + testFormat: devel/{0} + targets: + - name: RHEL 9.2 ova + test: rhel/9.2/ + groups: + - 20 # https://github.com/ansible/ansible/blob/stable-2.15/test/lib/ansible_test/_data/completion/remote.txt - stage: Remote_2_16 @@ -565,6 +573,16 @@ stages: test: rhel/8.8/ groups: - 19 + - template: templates/matrix.yml + parameters: + testFormat: 2.16/{0} + targets: + - name: RHEL 9.2 ova + test: rhel/9.2/ + - name: RHEL 8.8 ova + test: rhel/8.8/ + groups: + - 20 # https://github.com/ansible/ansible/blob/stable-2.14/test/lib/ansible_test/_data/completion/remote.txt - stage: Remote_2_15 diff --git a/changelogs/fragments/311-add_ova_image_support.yaml b/changelogs/fragments/311-add_ova_image_support.yaml new file mode 100644 index 00000000..5a0241f1 --- /dev/null +++ b/changelogs/fragments/311-add_ova_image_support.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - add support for building ova images diff --git a/plugins/modules/start_compose.py b/plugins/modules/start_compose.py index 71e6ba06..19ade39b 100644 --- a/plugins/modules/start_compose.py +++ b/plugins/modules/start_compose.py @@ -64,6 +64,7 @@ - image-installer - oci - openstack + - ova - qcow2 - tar - vhd @@ -142,6 +143,7 @@ "image-installer", "oci", "openstack", + "ova", "qcow2", "tar", "vhd", @@ -299,6 +301,7 @@ def start_compose(module, weldr): compose_output_types: dict[str, list[str]] = { "tar": ["tar", "edge-commit", "iot-commit", "edge-container", "iot-container", "container"], "iso": ["edge-installer", "edge-simplified-installer", "iot-installer", "image-installer"], + "ova": ["ova"], "qcow2": ["qcow2", "openstack", "oci"], "vmdk": ["vmdk"], "vhd": ["vhd"], diff --git a/tests/integration/targets/compose_type-ova/aliases b/tests/integration/targets/compose_type-ova/aliases new file mode 100644 index 00000000..de568e0b --- /dev/null +++ b/tests/integration/targets/compose_type-ova/aliases @@ -0,0 +1,8 @@ +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +azp/posix/19 +needs/root +destructive +setup/always/role_setup_server diff --git a/tests/integration/targets/compose_type-ova/tasks/main.yml b/tests/integration/targets/compose_type-ova/tasks/main.yml new file mode 100644 index 00000000..8f083559 --- /dev/null +++ b/tests/integration/targets/compose_type-ova/tasks/main.yml @@ -0,0 +1,24 @@ +--- +#################################################################### +# WARNING: These are designed specifically for Ansible tests # +# and should not be used as examples of how to write Ansible roles # +#################################################################### + +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later +# +- name: Include variables + ansible.builtin.include_vars: + file: ../vars/main.yml + +- name: Run the infra.osbuild.builder role + ansible.builtin.import_role: + name: infra.osbuild.builder + vars: + builder_pub_key: "{{ pubkey }}" + builder_blueprint_src_path: "{{ blueprint_src_path }}" + builder_compose_type: "{{ compose_type }}" + +- name: Validate the role + ansible.builtin.include_tasks: tests.yml diff --git a/tests/integration/targets/compose_type-ova/tasks/tests.yml b/tests/integration/targets/compose_type-ova/tasks/tests.yml new file mode 100644 index 00000000..2bb71e5f --- /dev/null +++ b/tests/integration/targets/compose_type-ova/tasks/tests.yml @@ -0,0 +1,17 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +# NOTE: the compose_start_out variable comes into scope via the +# execution of the infra.osbuild.builder role and is not defined +# within these test cases (yet?). +- name: Check if image was built and served + ansible.builtin.stat: + path: "/var/www/html/{{ builder_blueprint_name }}/images/0.0.1/{{ builder_blueprint_name }}_ova.ova" # noqa yaml[line-length] + register: ova_stat_result + +- name: Assert that the image was successful and that it is available on the server. + ansible.builtin.assert: + that: + - ova_stat_result.stat.exists diff --git a/tests/integration/targets/compose_type-ova/vars/main.yml b/tests/integration/targets/compose_type-ova/vars/main.yml new file mode 100644 index 00000000..f47d59cd --- /dev/null +++ b/tests/integration/targets/compose_type-ova/vars/main.yml @@ -0,0 +1,12 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +blueprint_src_path: "/tmp/blueprint.toml" +pubkey: "ssh-rsa FAKEPUBKEY" + +builder_blueprint_distro: "{{ 'fedora' if ansible_distribution == 'Fedora' else 'centos' }}-{{ ansible_distribution_major_version }}" +builder_blueprint_ref: "{{ 'fedora' if ansible_distribution == 'Fedora' else 'centos' }}/{{ ansible_distribution_major_version }}/x86_64/{{ 'iot' if ansible_distribution == 'Fedora' else 'edge' }}" # yamllint disable-line rule:line-length + +compose_type: "ova"