Skip to content

sap_software_download: Download stack XML option #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions roles/sap_software_download/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ A list of SAP software file names to download.<br>
The name or display ID of a transaction from the SAP Maintenance Planner.<br>
If provided, the role will download all files associated with this Maintenance Plan transaction.<br>

### sap_software_download_mp_stack_xml
- _Type:_ `boolean`<br>
- _Default:_ `true`<br>

Enables download of Maintenance Plan Stack XML file together with files.<br>
If set to `false`, Stack XML file will not be downloaded.<br>

### sap_software_download_find_alternatives
- _Type:_ `boolean`<br>
- _Default:_ `true`<br>
Expand Down
4 changes: 4 additions & 0 deletions roles/sap_software_download/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ sap_software_download_files: []
# If provided, the role will download all files associated with this Maintenance Plan transaction.
sap_software_download_mp_transaction: ''

# Enables download of Maintenance Plan Stack XML file together with files.
# If set to `false`, Stack XML file will not be downloaded.
sap_software_download_mp_stack_xml: true

# Enables searching for alternative files if the requested file is not found.
# Only applies to files specified in `sap_software_download_files`.
# If set to `false`, the role will not search for alternatives.
Expand Down
8 changes: 8 additions & 0 deletions roles/sap_software_download/meta/argument_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ argument_specs:
- The name or display ID of a transaction from the SAP Maintenance Planner.
- If provided, the role will download all files associated with this Maintenance Plan transaction.

sap_software_download_mp_stack_xml:
type: bool
required: false
default: true
description:
- Enables download of Maintenance Plan Stack XML file together with files.
- If set to `false`, Stack XML file will not be downloaded.

sap_software_download_find_alternatives:
type: bool
required: true
Expand Down
49 changes: 49 additions & 0 deletions roles/sap_software_download/tasks/download_stack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# SPDX-License-Identifier: Apache-2.0
---

- name: Download - Maintenance Plan Stack XML - Get file with Python venv
when: sap_software_download_use_venv | d(true)
community.sap_launchpad.maintenance_planner_stack_xml_download:
suser_id: "{{ sap_software_download_suser_id }}"
suser_password: "{{ sap_software_download_suser_password }}"
transaction_name: "{{ sap_software_download_mp_transaction }}"
dest: "{{ sap_software_download_directory }}"
register: __sap_software_download_stack_results_venv
retries: 1
environment:
PATH: "{{ __sap_software_download_venv.path }}/bin:{{ ansible_env.PATH }}"
PYTHONPATH: "{{ __sap_software_download_venv.path }}/lib/{{ sap_software_download_python_interpreter }}/site-packages"
VIRTUAL_ENV: "{{ __sap_software_download_venv.path }}"
vars:
ansible_python_interpreter: "{{ __sap_software_download_venv.path ~ '/bin/' ~ sap_software_download_python_interpreter }}"
ignore_errors: true # Errors are ignored and validated afterwards


- name: Download - Maintenance Plan Stack XML - Get file with Python system default
when: not sap_software_download_use_venv | d(true)
community.sap_launchpad.maintenance_planner_stack_xml_download:
suser_id: "{{ sap_software_download_suser_id }}"
suser_password: "{{ sap_software_download_suser_password }}"
transaction_name: "{{ sap_software_download_mp_transaction }}"
dest: "{{ sap_software_download_directory }}"
register: __sap_software_download_stack_results_default
retries: 1
vars:
ansible_python_interpreter: "{{ '/usr/bin/' ~ sap_software_download_python_interpreter }}"
ignore_errors: true # Errors are ignored and validated afterwards


- name: Download - Maintenance Plan Stack XML - Set fact with maintenance_planner_stack_xml_download output
ansible.builtin.set_fact:
__sap_software_download_stack_results: "{{ __sap_software_download_stack_results_venv
if sap_software_download_use_venv | d(true) else __sap_software_download_stack_results_default }}"

- name: Download - Maintenance Plan Stack XML - Show failed results
ansible.builtin.fail:
msg: |
Download of Stack XML failed.
Either ensure correct value in `sap_software_download_mp_transaction`
or ignore this error with `sap_software_download_ignore_plan_not_found` set to `true`.
when:
- not sap_software_download_ignore_plan_not_found | d(false)
- __sap_software_download_stack_results.failed
7 changes: 7 additions & 0 deletions roles/sap_software_download/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
- sap_software_download_validate_relationships


- name: SAP Software Download - Download - Stack XML {{ sap_software_download_mp_transaction | d('') }}
ansible.builtin.include_tasks:
file: download_stack.yml
when:
- sap_software_download_mp_transaction | length > 0
- sap_software_download_mp_stack_xml | d(true)

- name: SAP Software Download - Download - Maintenance Plan {{ sap_software_download_mp_transaction | d('') }}
ansible.builtin.include_tasks:
file: download_plan.yml
Expand Down