From b4cd8ad1adb72c5ac93afeaddbf8e2479445cebf Mon Sep 17 00:00:00 2001 From: Alberto Florez Date: Mon, 15 Jun 2026 00:00:45 +0200 Subject: [PATCH 1/2] Fix storage map accumulation and optimize datastore filtering --- .../mtv_management/tasks/_mtv_storage_map.yml | 50 +++++++++++++++++-- .../_mtv_storage_map_process_datastore.yml | 6 +-- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/roles/mtv_management/tasks/_mtv_storage_map.yml b/roles/mtv_management/tasks/_mtv_storage_map.yml index ab05c6c..ade482b 100644 --- a/roles/mtv_management/tasks/_mtv_storage_map.yml +++ b/roles/mtv_management/tasks/_mtv_storage_map.yml @@ -2,7 +2,7 @@ - name: _mtv_storage_map | Initialize data structures ansible.builtin.set_fact: - mtv_management_mtv_storagemaps: {} + mtv_management_mtv_storagemap_maps: {} - name: _mtv_storage_map | Verify Storage Map Overrides do not contain both includes and excludes ansible.builtin.fail: @@ -41,9 +41,46 @@ mtv_management_inventory_query_result_var: mtv_destination_datastores when: "'vsphere' in provider" +- name: _mtv_storage_map | Extract included datastore IDs from overrides + ansible.builtin.set_fact: + mtv_management_mtv_allowed_datastore_ids: >- + {{ + mtv_management_storage_map_overrides + | selectattr('include', 'defined') + | selectattr('include', 'equalto', true) + | map(attribute='id') + | list + }} + when: + - mtv_management_storage_map_overrides is defined + - mtv_management_storage_map_overrides | length > 0 + - mtv_management_storage_map_overrides | selectattr('include', 'defined') | list | length > 0 + +- name: _mtv_storage_map | Extract excluded datastore IDs from overrides + ansible.builtin.set_fact: + mtv_management_mtv_excluded_datastore_ids: >- + {{ + mtv_management_storage_map_overrides + | selectattr('exclude', 'defined') + | selectattr('exclude', 'equalto', true) + | map(attribute='id') + | list + }} + when: + - mtv_management_storage_map_overrides is defined + - mtv_management_storage_map_overrides | length > 0 + - mtv_management_storage_map_overrides | selectattr('exclude', 'defined') | list | length > 0 + - name: _mtv_storage_map | Process VMware Datastores ansible.builtin.include_tasks: _mtv_storage_map_process_datastore.yml - loop: "{{ mtv_destination_datastores }}" + loop: >- + {{ + (mtv_destination_datastores | selectattr('id', 'in', mtv_management_mtv_allowed_datastore_ids) | list) + if (mtv_management_mtv_allowed_datastore_ids | default([]) | length > 0) + else (mtv_destination_datastores | rejectattr('id', 'in', mtv_management_mtv_excluded_datastore_ids | default([])) | list) + if (mtv_management_mtv_excluded_datastore_ids | default([]) | length > 0) + else mtv_destination_datastores + }} loop_control: loop_var: mtv_vmware_datastore when: @@ -53,7 +90,14 @@ - name: _mtv_storage_map | Process Ovirt Datastores ansible.builtin.include_tasks: _mtv_storage_map_process_datastore.yml - loop: "{{ mtv_destination_datastores }}" + loop: >- + {{ + (mtv_destination_datastores | selectattr('id', 'in', mtv_management_mtv_allowed_datastore_ids) | list) + if (mtv_management_mtv_allowed_datastore_ids | default([]) | length > 0) + else (mtv_destination_datastores | rejectattr('id', 'in', mtv_management_mtv_excluded_datastore_ids | default([])) | list) + if (mtv_management_mtv_excluded_datastore_ids | default([]) | length > 0) + else mtv_destination_datastores + }} loop_control: loop_var: mtv_ovirt_datastore when: diff --git a/roles/mtv_management/tasks/_mtv_storage_map_process_datastore.yml b/roles/mtv_management/tasks/_mtv_storage_map_process_datastore.yml index 453da6d..a74f877 100644 --- a/roles/mtv_management/tasks/_mtv_storage_map_process_datastore.yml +++ b/roles/mtv_management/tasks/_mtv_storage_map_process_datastore.yml @@ -54,15 +54,13 @@ - name: _mtv_storage_map_process_datastore | Add VMware StorageMap Map to Dict ansible.builtin.set_fact: - mtv_management_mtv_storagemap_maps: "{{ mtv_management_mtv_storagemap_maps | default({}) | ansible.builtin.combine({mtv_vmware_datastore.selfLink: mtv_management_storage_map_map}, recursive=true) }}" # noqa: yaml[line-length] + mtv_management_mtv_storagemap_maps: "{{ mtv_management_mtv_storagemap_maps | default({}) | ansible.builtin.combine({(mtv_vmware_datastore.selfLink + '-' + _mtv_management_storage_map_storage_class): mtv_management_storage_map_map}, recursive=true) }}" # noqa: yaml[line-length] when: - mtv_vmware_datastore is defined - - "(('include' in mtv_management_mtv_vmware_datastore_overrides and mtv_management_storage_map_overrides | selectattr('include', 'defined') | list | length > 0) or (mtv_management_storage_map_overrides | selectattr('include', 'defined') | list | length == 0 and mtv_management_storage_map_overrides | selectattr('exclude', 'defined') | list | length == 0)) or ('exclude' not in mtv_management_mtv_vmware_datastore_overrides and mtv_management_storage_map_overrides | selectattr('exclude', 'defined') | list | length > 0)" # noqa: yaml[line-length] - name: _mtv_storage_map_process_datastore | Add Ovirt StorageMap Map to Dict ansible.builtin.set_fact: - mtv_management_mtv_storagemap_maps: "{{ mtv_management_mtv_storagemap_maps | default({}) | ansible.builtin.combine({mtv_ovirt_datastore.selfLink: mtv_management_storage_map_map}, recursive=true) }}" # noqa: yaml[line-length] + mtv_management_mtv_storagemap_maps: "{{ mtv_management_mtv_storagemap_maps | default({}) | ansible.builtin.combine({(mtv_ovirt_datastore.selfLink + '-' + _mtv_management_storage_map_storage_class): mtv_management_storage_map_map}, recursive=true) }}" # noqa: yaml[line-length] when: - mtv_ovirt_datastore is defined - - "(('include' in mtv_management_mtv_ovirt_datastore_overrides and mtv_management_storage_map_overrides | selectattr('include', 'defined') | list | length > 0) or (mtv_management_storage_map_overrides | selectattr('include', 'defined') | list | length == 0 and mtv_management_storage_map_overrides | selectattr('exclude', 'defined') | list | length == 0)) or ('exclude' not in mtv_management_mtv_ovirt_datastore_overrides and mtv_management_storage_map_overrides | selectattr('exclude', 'defined') | list | length > 0)" # noqa: yaml[line-length] ... From a9a16096fe3abbddcfacba7306b624f93f739a7d Mon Sep 17 00:00:00 2001 From: Alberto Florez Date: Wed, 24 Jun 2026 23:57:39 +0200 Subject: [PATCH 2/2] docs: update generated documentation --- README.md | 137 ------------------------------------------------------ 1 file changed, 137 deletions(-) diff --git a/README.md b/README.md index fafc433..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,137 +0,0 @@ -# Ansible for OpenShift Virtualization Migration - -![GitHub Release](https://img.shields.io/github/v/release/redhat-cop/openshift_virtualization_migration?include_prereleases&style=flat-square) -[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/redhat-cop/openshift_virtualization_migration/ci.yml?style=flat-square&label=release)](https://github.com/redhat-cop/openshift_virtualization_migration/actions) -[![Semantic Versioning](https://img.shields.io/badge/semver-2.0.0-blue?style=flat-square)](https://semver.org/) -[![License](https://img.shields.io/github/license/redhat-cop/openshift_virtualization_migration?style=flat-square)](LICENSE) - - - -- [Ansible for OpenShift Virtualization Migration](#ansible-for-openshift-virtualization-migration) - - [Description](#description) - - [Documentation](#documentation) - - [Release Notes](#release-notes) - - [Roles](#roles) - - [Requirements](#requirements) - - [Installation](#installation) - - [Use Cases](#use-cases) - - [Testing](#testing) - - [Support](#support) - - [License](#license) - - - -## Description - -This collection enables the migration journey of Virtual Machine (VM) workloads from existing hypervisors to Red Hat OpenShift Virtualization using Ansible Automation Platform. Additionally it provides content for the management and maintenance of VM workloads within Red Hat OpenShift Virtualization. - -## Documentation - -* [Contributing Guide](CONTRIBUTING.md) -* [Disconnected Environment Setup](docs/disconnected_environment_guide.md) -* [Secure Credential Management](docs/secure_credential_management.md) -* [Secure Credential Practices](docs/secure_credential_practices.md) - -## Release Notes - -See [CHANGELOG.md](CHANGELOG.md) for release history and changes. - -## Roles - -This collection includes the following roles for managing OpenShift Virtualization migrations: - - - - - -## Requirements - -The following Ansible Collections are required: - -```yaml ---- -collections: - - name: redhat.openshift_virtualization - - name: redhat.openshift - - name: vmware.vmware_rest - - name: ansible.posix - - name: infra.aap_utilities - - name: kubernetes.core - - name: community.crypto - - name: community.general - - name: community.vmware - - # AAP <=2.4 - - name: infra.controller_configuration - - name: ansible.controller - version: "<=4.5.12" - - # AAP 2.5+ - - name: ansible.platform - - name: ansible.controller - - name: infra.aap_configuration -... -``` - -## Installation - -You can install the `infra.openshift_virtualization_migration` collection with the Ansible Galaxy CLI: - -```shell -ansible-galaxy collection install infra.openshift_virtualization_migration -``` - -Note that if you install any collections from Ansible Galaxy, they will not be upgraded automatically when you upgrade the Ansible package. - -To upgrade the collection to the latest available version, run the following command: - -``` -ansible-galaxy collection install infra.openshift_virtualization_migration --upgrade -``` - -You can also include it in a `requirements.yml` file and install it with `ansible-galaxy collection install -r requirements.yml`, using the format: - -```yaml ---- -collections: - - name: infra.openshift_virtualization_migration - # If you need a specific version of the collection, you can specify like this: - # version: ... -``` - -See [using Ansible collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html) for more details. - -## Use Cases - -This collection is ideal for accomplishing the following using Ansible automation: - -* Analyzing existing Virtual Machine hypervisor environments. -* Installing and configuring Ansible Automation Platform. -* Preparing OpenShift environments to support Virtual Machines and migrating Virtual Machines from existing hypervisors using the Migration Toolkit for Virtualization (MTV). -* Migrating Virtual Machines using the Migration Toolkit for Virtualization (MTV). - -## Testing - -[tox](https://tox.wiki) is used to perform tests and verification of this collection. - -The following commands can be used to execute the various types of tests implemented: - -```shell -tox -av # lists all tests - -tox # run them all - -tox -e # run specific one - -tox -f sanity --ansible -c tox-ansible.ini # run tox-ansible that does our ansible-test sanity suite -``` - -## Support - -The [Ansible Forum](https://forum.ansible.com/tag/openshift_migrate) can be used for additional questions and issues related to this collection. - -## License - -GNU General Public License v3.0 or later. - -See the [LICENSE](https://www.gnu.org/licenses/gpl-3.0.en.html) to see the full text.