Skip to content

Commit 3955631

Browse files
authored
Merge pull request #65 from marcelmamula/sort
software_center_download: Update fuzzy search logic and deduplicate sorting
2 parents 6c00d75 + 3f9911f commit 3955631

9 files changed

Lines changed: 493 additions & 165 deletions

File tree

docs/module_software_center_download.md

Lines changed: 88 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Description
44
The Ansible Module `software_center_download` automates downloading files from the SAP Software Center.
55
- It can find a file using a search query or download it directly using a specific download link and filename.
6+
- Supports wildcard search to find and download specific versions (oldest/newest) from multiple available versions.
67
- If a file is not found via search, it can look for alternative versions.
78
- It supports checksum validation to ensure file integrity and avoid re-downloading valid files.
89
- The module can also perform a dry run to check for file availability without downloading.
@@ -18,6 +19,39 @@ This module requires the following Python modules to be installed on the target
1819

1920
## Execution
2021

22+
### Wildcard Search Format
23+
The module supports wildcard search to find files across multiple versions. This is useful when you want to download the latest (or oldest) version of a software package without knowing the exact version number.
24+
25+
**Format:** `PREFIX*-ID.EXT`
26+
27+
Where:
28+
29+
- `PREFIX`: The software name prefix (e.g., `SAPEXE`, `SAPHOSTAGENT`).
30+
- `*`: Single wildcard representing the version number.
31+
- `-`: Dash separator (required).
32+
- `ID`: File ID number (e.g., `80002630`).
33+
- `.EXT`: File extension (e.g., `.SAR`, `.EXE`).
34+
35+
> **NOTE:** File ID is unique number that represents combination of component and platform version.
36+
37+
**Requirements:**
38+
- The parameter `search_alternatives: true` must be enabled.
39+
- Only one wildcard (`*`) is allowed per query.
40+
- File format must include both dash and extension according to pattern above.
41+
- Use `deduplicate` parameter to select oldest (`first`) or newest (`last`) version.
42+
43+
**Examples:**
44+
- `SWPM20SP2*-80003424.SAR` - Matches all available SWPM20 versions starting with `2` (SWPM20SP23, SWPM20SP24, etc.) for `Linux on x86_64 64bit` (80003424).
45+
- `SAPEXE_10*-80002630.SAR` - Matches all available SAPEXE_10 versions starting with `10` (SAPEXE_10, SAPEXE_100, SAPEXE_1000, etc.) for `Linux on Power LE 64bit` (80002630).
46+
- `SAPHOSTAGENT*-80004822.SAR` - Matches all available SAPHOSTAGENT versions for `Linux on x86_64 64bit` (80004822).
47+
48+
**Special Files:**
49+
Some SAP media files don't follow the standard naming pattern and require exact filenames:
50+
51+
- `S4CORE107_INST_EXPORT_1.zip`
52+
- `KD75783.SAR`
53+
- `19118000000000009032` (SAP Media downloaded with ID instead of Title).
54+
2155
### Execution Flow
2256
The module follows a sophisticated logic flow to determine whether to download, skip, or fail. Here is a simplified breakdown of the decision-making process:
2357

@@ -88,6 +122,31 @@ Download SAP Software file using download_link and download_filename
88122
dest: "Enter download path (e.g. /software)"
89123
```
90124
125+
Download latest version of SAP Software using wildcard search
126+
```yaml
127+
---
128+
- name: Example play for Ansible Module software_center_download
129+
hosts: all
130+
tasks:
131+
- name: Download latest SAPEXE version using wildcard
132+
community.sap_launchpad.software_center_download:
133+
suser_id: "Enter SAP S-User ID"
134+
suser_password: "Enter SAP S-User Password"
135+
search_query: "SAPEXE*-80002630.SAR"
136+
dest: "Enter download path (e.g. /software)"
137+
search_alternatives: true
138+
deduplicate: "last"
139+
140+
- name: Download oldest SAPHOSTAGENT version using wildcard
141+
community.sap_launchpad.software_center_download:
142+
suser_id: "Enter SAP S-User ID"
143+
suser_password: "Enter SAP S-User Password"
144+
search_query: "SAPHOSTAGENT*-80004822.SAR"
145+
dest: "Enter download path (e.g. /software)"
146+
search_alternatives: true
147+
deduplicate: "first"
148+
```
149+
91150
Download list of SAP Software files, but search for alternatives if not found
92151
```yaml
93152
---
@@ -129,7 +188,7 @@ Download SAP Software file using Python Virtual Environment `/tmp/venv`
129188
PYTHONPATH: "/tmp/venv/lib/python3.11/site-packages"
130189
VIRTUAL_ENV: "/tmp/venv"
131190
vars:
132-
ansible_python_interpreter: "/tmp/venv/bin/python3.11 }}"
191+
ansible_python_interpreter: "/tmp/venv/bin/python3.11"
133192
```
134193

135194
Install prerequisites and download SAP Software file using existing System Python.</br>
@@ -199,7 +258,7 @@ Install prerequisites and download SAP Software file using existing Python Virtu
199258
PYTHONPATH: "/tmp/python_venv/lib/python3.11/site-packages"
200259
VIRTUAL_ENV: "/tmp/python_venv"
201260
vars:
202-
ansible_python_interpreter: "/tmp/python_venv/bin/python3.11 }}"
261+
ansible_python_interpreter: "/tmp/python_venv/bin/python3.11"
203262
```
204263

205264
### Output format
@@ -230,7 +289,15 @@ The password for the SAP S-User specified in `suser_id`.
230289
### search_query
231290
- _Type:_ `string`<br>
232291

233-
The SAP software file name to download.
292+
The SAP software file name to download.<br>
293+
Supports wildcard format for version matching when `search_alternatives` is enabled.<br>
294+
295+
**Wildcard Format:** `PREFIX*-ID.EXT`<br>
296+
- Only one wildcard (`*`) is allowed per query<br>
297+
- Example: `SAPEXE*-80002630.SAR` matches all SAPEXE versions<br>
298+
299+
**Exact Filename:** Use the complete filename without wildcards for specific files.<br>
300+
- Example: `SAPCAR_1324-80000936.EXE`
234301

235302
### download_link
236303
- _Type:_ `string`<br>
@@ -252,16 +319,30 @@ The directory where downloaded SAP software files will be stored.
252319

253320
### deduplicate
254321
- _Type:_ `string`<br>
322+
- _Choices:_ `first`, `last`, `` (empty)<br>
323+
- _Default:_ `last`<br>
324+
325+
Specifies how to handle multiple search results.<br>
326+
Only applies when `search_alternatives` is enabled and multiple versions are found.<br>
255327

256-
Specifies how to handle multiple search results for the same filename.<br>
257-
If multiple files with the same name are found, this setting determines which one to download.<br>
258-
- `first`: Download the first file found (oldest).<br>
259-
- `last`: Download the last file found (newest).<br>
328+
**Options:**<br>
329+
- `first`: Download the oldest version<br>
330+
- `last`: Download the newest version<br>
331+
- `` (empty): If multiple results are found, display all available versions and fail with an error<br>
332+
333+
Files are sorted numerically by version number, ensuring correct ordering (e.g., version 7 < 10 < 100 < 1500).<br>
260334

261335
### search_alternatives
262336
- _Type:_ `boolean`<br>
337+
- _Default:_ `false`<br>
263338

264339
Enables searching for alternative files if the requested file is not found.<br>
340+
**Required** when using wildcard queries in `search_query`.<br>
341+
342+
**Requirements:**<br>
343+
- Only works for files following the format `PREFIX-ID.EXT` (with dash and extension)<br>
344+
- Special media files without this pattern (e.g., `S4CORE107_INST_EXPORT_1.zip`) must use exact filenames<br>
345+
- Wildcard searches are not supported for files without dashes or extensions<br>
265346

266347
### dry_run
267348
- _Type:_ `boolean

0 commit comments

Comments
 (0)