diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 137fc0d..50b6051 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,20 @@ community.sap\_launchpad Release Notes .. contents:: Topics +v1.2.1 +====== + +Release Summary +--------------- + +Various bug fixes + +Bugfixes +-------- +- software_center_download: Improved logic for skipping existing files and getting valid filename (https://github.com/sap-linuxlab/community.sap_launchpad/pull/40) +- sap_software_download: Add SLES 16 python313 support and update changelog (https://github.com/sap-linuxlab/community.sap_launchpad/pull/41) + + v1.2.0 ====== diff --git a/galaxy.yml b/galaxy.yml index 02fd643..7dfb4da 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -8,7 +8,7 @@ namespace: community name: sap_launchpad # The version of the collection. Must be compatible with semantic versioning -version: 1.2.0 +version: 1.2.1 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/plugins/module_utils/sap_launchpad_software_center_download_runner.py b/plugins/module_utils/sap_launchpad_software_center_download_runner.py index d4914fd..09a54df 100644 --- a/plugins/module_utils/sap_launchpad_software_center_download_runner.py +++ b/plugins/module_utils/sap_launchpad_software_center_download_runner.py @@ -313,12 +313,12 @@ def _get_valid_filename(software_found): """ # Check if Title contains filename and extension - if re.match(r'^[^/\\\0]+\.[^/\\\0]+$', software_found['Title']): - return software_found['Title'] - else: - # Check if Description contains filename and extension - if re.match(r'^[^/\\\0]+\.[^/\\\0]+$', software_found['Description']): + if re.match(r'^\d+$', software_found['Title']): + # Check if Description attribute exists and that it does not contain empty spaces + if software_found['Description'] and ' ' not in software_found['Description']: return software_found['Description'] else: - # Default to Title if Description does not help return software_found['Title'] + else: + # Default to Title if Description does not help + return software_found['Title'] diff --git a/plugins/modules/software_center_download.py b/plugins/modules/software_center_download.py index 5b909e8..9ec4e0f 100644 --- a/plugins/modules/software_center_download.py +++ b/plugins/modules/software_center_download.py @@ -128,9 +128,15 @@ def _check_similar_files(dest, filename): bool: True if similar files exist, False otherwise. filename_similar_names: A list of similar filenames if they exist, empty list otherwise. """ - # pattern = dest + '/**/' + os.path.splitext(filename)[0] - filename_base = os.path.splitext(filename)[0] - filename_pattern = os.path.join(dest, "**", filename_base) + + # Check if filename has has extension and remove it for search + if os.path.splitext(filename)[1]: + filename_base = os.path.splitext(filename)[0] + filename_pattern = os.path.join(dest, "**", filename_base + ".*") + else: + filename_pattern = os.path.join(dest, "**", filename + ".*") + + # Find all similar files in dest and sub-folders. filename_similar = glob.glob(filename_pattern, recursive=True) if filename_similar: @@ -217,7 +223,7 @@ def run_module(): else: # Exact file not found, search for similar files with pattern filename_similar_exists, filename_similar_names = _check_similar_files(dest, filename) - if filename_similar_exists and not (query and search_alternatives): + if filename_similar_exists: result['skipped'] = True result['msg'] = f"Similar file(s) already exist: {', '.join(filename_similar_names)}" module.exit_json(**result) diff --git a/roles/sap_software_download/vars/Suse.yml b/roles/sap_software_download/vars/SLES_15.yml similarity index 74% rename from roles/sap_software_download/vars/Suse.yml rename to roles/sap_software_download/vars/SLES_15.yml index f540820..5932303 100644 --- a/roles/sap_software_download/vars/Suse.yml +++ b/roles/sap_software_download/vars/SLES_15.yml @@ -3,14 +3,13 @@ # Variables specific to following versions: # - SUSE Linux Enterprise Server 15 -# - SUSE Linux Enterprise Server 16 # NOTE: SLES 15 SP5 introduced Python 3.11. # Set which Python version will be used on destination node. # This is python executable name, which can differ from python package name. __sap_software_download_python_interpreter: >- - {%- if ansible_distribution_major_version == '15' and ansible_distribution_version.split('.')[1] | int < 5 -%} + {%- if ansible_distribution_version.split('.')[1] | int < 5 -%} python3 {%- else -%} python3.11 @@ -18,7 +17,7 @@ __sap_software_download_python_interpreter: >- # Set which Python package will be installed on destination node. __sap_software_download_python_package: >- - {%- if ansible_distribution_major_version == '15' and ansible_distribution_version.split('.')[1] | int < 5 -%} + {%- if ansible_distribution_version.split('.')[1] | int < 5 -%} python3 {%- else -%} python311 @@ -27,7 +26,7 @@ __sap_software_download_python_package: >- # The list of required Python Modules in packages # This is required in order to avoid externally-managed-environment error. __sap_software_download_python_module_packages: >- - {%- if ansible_distribution_major_version == '15' and ansible_distribution_version.split('.')[1] | int < 5 -%} + {%- if ansible_distribution_version.split('.')[1] | int < 5 -%} [ "python3-wheel", "python3-urllib3", diff --git a/roles/sap_software_download/vars/SLES_16.yml b/roles/sap_software_download/vars/SLES_16.yml new file mode 100644 index 0000000..8dc2f90 --- /dev/null +++ b/roles/sap_software_download/vars/SLES_16.yml @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: Apache-2.0 +--- + +# Variables specific to following versions: +# - SUSE Linux Enterprise Server 16 + +# Set which Python version will be used on destination node. +# This is python executable name, which can differ from python package name. +__sap_software_download_python_interpreter: python3.13 + +# Set which Python package will be installed on destination node. +__sap_software_download_python_package: python313 + +# The list of required Python Modules in packages +# This is required in order to avoid externally-managed-environment error. +__sap_software_download_python_module_packages: + - "python313-wheel" + - "python313-urllib3" + - "python313-requests" + - "python313-beautifulsoup4" + - "python313-lxml"