Skip to content

Commit 5f70b2c

Browse files
committed
feat: Download stack XML option
1 parent e5eab87 commit 5f70b2c

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

roles/sap_software_download/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ A list of SAP software file names to download.<br>
256256
The name or display ID of a transaction from the SAP Maintenance Planner.<br>
257257
If provided, the role will download all files associated with this Maintenance Plan transaction.<br>
258258

259+
### sap_software_download_mp_stack_xml
260+
- _Type:_ `boolean`<br>
261+
- _Default:_ `true`<br>
262+
263+
Enables download of Maintenance Plan Stack XML file together with files.<br>
264+
If set to `false`, Stack XML file will not be downloaded.<br>
265+
259266
### sap_software_download_find_alternatives
260267
- _Type:_ `boolean`<br>
261268
- _Default:_ `true`<br>

roles/sap_software_download/defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ sap_software_download_files: []
4343
# If provided, the role will download all files associated with this Maintenance Plan transaction.
4444
sap_software_download_mp_transaction: ''
4545

46+
# Enables download of Maintenance Plan Stack XML file together with files.
47+
# If set to `false`, Stack XML file will not be downloaded.
48+
sap_software_download_mp_stack_xml: true
49+
4650
# Enables searching for alternative files if the requested file is not found.
4751
# Only applies to files specified in `sap_software_download_files`.
4852
# If set to `false`, the role will not search for alternatives.

roles/sap_software_download/meta/argument_spec.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ argument_specs:
8282
- The name or display ID of a transaction from the SAP Maintenance Planner.
8383
- If provided, the role will download all files associated with this Maintenance Plan transaction.
8484

85+
sap_software_download_mp_stack_xml:
86+
type: bool
87+
required: false
88+
default: true
89+
description:
90+
- Enables download of Maintenance Plan Stack XML file together with files.
91+
- If set to `false`, Stack XML file will not be downloaded.
92+
8593
sap_software_download_find_alternatives:
8694
type: bool
8795
required: true
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
---
3+
4+
- name: Download - Maintenance Plan Stack XML - Get file with Python venv
5+
when: sap_software_download_use_venv | d(true)
6+
community.sap_launchpad.maintenance_planner_stack_xml_download:
7+
suser_id: "{{ sap_software_download_suser_id }}"
8+
suser_password: "{{ sap_software_download_suser_password }}"
9+
transaction_name: "{{ sap_software_download_mp_transaction }}"
10+
dest: "{{ sap_software_download_directory }}"
11+
register: __sap_software_download_stack_results_venv
12+
retries: 1
13+
environment:
14+
PATH: "{{ __sap_software_download_venv.path }}/bin:{{ ansible_env.PATH }}"
15+
PYTHONPATH: "{{ __sap_software_download_venv.path }}/lib/{{ sap_software_download_python_interpreter }}/site-packages"
16+
VIRTUAL_ENV: "{{ __sap_software_download_venv.path }}"
17+
vars:
18+
ansible_python_interpreter: "{{ __sap_software_download_venv.path ~ '/bin/' ~ sap_software_download_python_interpreter }}"
19+
ignore_errors: true # Errors are ignored and validated afterwards
20+
21+
22+
- name: Download - Maintenance Plan Stack XML - Get file with Python system default
23+
when: not sap_software_download_use_venv | d(true)
24+
community.sap_launchpad.maintenance_planner_stack_xml_download:
25+
suser_id: "{{ sap_software_download_suser_id }}"
26+
suser_password: "{{ sap_software_download_suser_password }}"
27+
transaction_name: "{{ sap_software_download_mp_transaction }}"
28+
dest: "{{ sap_software_download_directory }}"
29+
register: __sap_software_download_stack_results_default
30+
retries: 1
31+
vars:
32+
ansible_python_interpreter: "{{ '/usr/bin/' ~ sap_software_download_python_interpreter }}"
33+
ignore_errors: true # Errors are ignored and validated afterwards
34+
35+
36+
- name: Download - Maintenance Plan Stack XML - Set fact with maintenance_planner_stack_xml_download output
37+
ansible.builtin.set_fact:
38+
__sap_software_download_stack_results: "{{ __sap_software_download_stack_results_venv
39+
if sap_software_download_use_venv | d(true) else __sap_software_download_stack_results_default }}"
40+
41+
- name: Download - Maintenance Plan Stack XML - Show failed results
42+
ansible.builtin.fail:
43+
msg: |
44+
Download of Stack XML failed.
45+
Either ensure correct value in `sap_software_download_mp_transaction`
46+
or ignore this error with `sap_software_download_ignore_plan_not_found` set to `true`.
47+
when:
48+
- not sap_software_download_ignore_plan_not_found | d(false)
49+
- __sap_software_download_stack_results.failed

roles/sap_software_download/tasks/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
- sap_software_download_validate_relationships
3030

3131

32+
- name: SAP Software Download - Download - Stack XML {{ sap_software_download_mp_transaction | d('') }}
33+
ansible.builtin.include_tasks:
34+
file: download_stack.yml
35+
when:
36+
- sap_software_download_mp_transaction | length > 0
37+
- sap_software_download_mp_stack_xml | d(true)
38+
3239
- name: SAP Software Download - Download - Maintenance Plan {{ sap_software_download_mp_transaction | d('') }}
3340
ansible.builtin.include_tasks:
3441
file: download_plan.yml

0 commit comments

Comments
 (0)