Skip to content

Commit 52a97e0

Browse files
authored
Merge pull request #10 from sap-linuxlab/dev
Merge dev to main for release 1.0.0
2 parents d286cc0 + 0120ad5 commit 52a97e0

File tree

6 files changed

+91
-53
lines changed

6 files changed

+91
-53
lines changed

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,9 @@ Within this Ansible Collection, there are various Ansible Modules.
3131
| [sap_launchpad.maintenance_planner_files](./docs/module_maintenance_planner_files.md) | maintenance planner files retrieval |
3232
| [sap_launchpad.maintenance_planner_stack_xml_download](./docs/module_maintenance_planner_stack_xml_download.md) | maintenance planner stack xml download |
3333

34-
## Execution examples
34+
## Execution
3535

36-
There are various methods to execute the Ansible Collection, dependant on the use case. For more information, see [Execution examples with code samples](./docs/EXEC_EXAMPLES.md) and the summary below:
37-
38-
| Execution Scenario | Use Case | Target |
39-
| --- | --- | --- |
40-
| Ansible Playbook <br/>-> source Ansible Collection <br/>-> execute Ansible Task <br/>--> run Ansible Module <br/>---> run Python/Bash Functions | Simple executions with a few activities | Localhost or Remote |
41-
| Ansible Playbook <br/>-> source Ansible Collection <br/>-> execute Ansible Task <br/>--> run Ansible Role <br/>---> run Ansible Module <br/>----> run Python/Bash Functions <br/>--> run Ansible Role<br/>---> ... | Complex executions with various interlinked activities;<br/> run in parallel or sequentially | Localhost or Remote |
42-
| Python/Bash Functions | Simple testing or non-Ansible use cases | Localhost |
43-
44-
## Requirements, Dependencies and Testing
45-
46-
### SAP User ID credentials
36+
### Credentials - SAP User ID
4737

4838
SAP software installation media must be obtained from SAP directly, and requires valid license agreements with SAP in order to access these files.
4939

@@ -55,6 +45,22 @@ When an SAP User ID (e.g. S-User) is enabled with and part of an SAP Universal I
5545

5646
In addition, if a SAP Universal ID is used then the recommendation is to check and reset the SAP User ID ‘Account Password’ in the [SAP Universal ID Account Manager](https://account.sap.com/manage/accounts), which will help to avoid any potential conflicts.
5747

48+
For further information regarding connection errors, please see the FAQ section [Errors with prefix 'SAP SSO authentication failed - '](./docs/FAQ.md#errors-with-prefix-sap-sso-authentication-failed---).
49+
50+
### Execution examples
51+
52+
There are various methods to execute the Ansible Collection, dependant on the use case. For more information, see [Execution examples with code samples](./docs/EXEC_EXAMPLES.md) and the summary below:
53+
54+
| Execution Scenario | Use Case | Target |
55+
| --- | --- | --- |
56+
| Ansible Playbook <br/>-> source Ansible Collection <br/>-> execute Ansible Task <br/>--> run Ansible Module <br/>---> run Python/Bash Functions | Simple executions with a few activities | Localhost or Remote |
57+
| Ansible Playbook <br/>-> source Ansible Collection <br/>-> execute Ansible Task <br/>--> run Ansible Role <br/>---> run Ansible Module <br/>----> run Python/Bash Functions <br/>--> run Ansible Role<br/>---> ... | Complex executions with various interlinked activities;<br/> run in parallel or sequentially | Localhost or Remote |
58+
| Python/Bash Functions | Simple testing or non-Ansible use cases | Localhost |
59+
60+
---
61+
62+
## Requirements, Dependencies and Testing
63+
5864
### Operating System requirements
5965

6066
Designed for Linux operating systems, e.g. RHEL.

docs/EXEC_EXAMPLES.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,25 @@
4141

4242
# Use task block to call Ansible Module
4343
tasks:
44-
- name: Execute Ansible Module to download SAP software
45-
community.sap_launchpad.software_center_download:
46-
suser_id: "{{ suser_id }}"
47-
suser_password: "{{ suser_password }}"
48-
softwarecenter_search_query: "{{ item }}"
49-
dest: "/tmp/"
50-
with_items: "{{ softwarecenter_search_list }}"
44+
- name: Execute Ansible Module to download SAP software
45+
community.sap_launchpad.software_center_download:
46+
suser_id: "{{ suser_id }}"
47+
suser_password: "{{ suser_password }}"
48+
softwarecenter_search_query: "{{ item }}"
49+
dest: "/tmp/"
50+
loop: "{{ softwarecenter_search_list }}"
51+
loop_control:
52+
label: "{{ item }} : {{ download_task.msg }}"
53+
register: download_task
54+
retries: 1
55+
until: download_task is not failed
5156
```
5257
5358
**Execution of Ansible Playbook, with in-line Ansible Inventory set as localhost**
5459
5560
```shell
5661
# Install from local source directory for Ansible 2.11+
57-
ansible-galaxy collection install ./community.sap_launchpad
62+
ansible-galaxy collection install community.sap_launchpad
5863

5964
# Workaround install from local source directory for Ansible 2.9.x
6065
# mv ./community.sap_launchpad ~/.ansible/collections/ansible_collections/community
@@ -108,14 +113,20 @@ ansible-playbook --timeout 60 ./community.sap_launchpad/playbooks/sample-downloa
108113

109114
# Option 2: Use sequential parse/execution, by using include_role inside Task block
110115
tasks:
111-
- name: Execute Ansible Role to download SAP software
112-
include_role:
113-
name: { role: community.sap_launchpad.software_center_download }
114-
vars:
115-
suser_id: "{{ suser_id }}"
116-
suser_password: "{{ suser_password }}"
117-
softwarecenter_search_query: "{{ item }}"
118-
with_items: "{{ softwarecenter_search_list }}"
116+
- name: Execute Ansible Role to download SAP software
117+
include_role:
118+
name: { role: community.sap_launchpad.software_center_download }
119+
vars:
120+
suser_id: "{{ suser_id }}"
121+
suser_password: "{{ suser_password }}"
122+
softwarecenter_search_query: "{{ item }}"
123+
loop: "{{ softwarecenter_search_list }}"
124+
loop_control:
125+
label: "{{ item }} : {{ download_task.msg }}"
126+
register: download_task
127+
retries: 1
128+
until: download_task is not failed
129+
119130

120131
# Option 3: Use task block with import_roles
121132
tasks:
@@ -126,7 +137,12 @@ ansible-playbook --timeout 60 ./community.sap_launchpad/playbooks/sample-downloa
126137
suser_id: "{{ suser_id }}"
127138
suser_password: "{{ suser_password }}"
128139
softwarecenter_search_query: "{{ item }}"
129-
with_items: "{{ softwarecenter_search_list }}"
140+
loop: "{{ softwarecenter_search_list }}"
141+
loop_control:
142+
label: "{{ item }} : {{ download_task.msg }}"
143+
register: download_task
144+
retries: 1
145+
until: download_task is not failed
130146

131147
```
132148

docs/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The error HTTP 401 refers to either:
2222
- Unauthorized, the SAP User ID is part of an SAP Universal ID and must use the password of the SAP Universal ID
2323
- In addition, if a SAP Universal ID is used then the recommendation is to check and reset the SAP User ID ‘Account Password’ in the [SAP Universal ID Account Manager](https://account.sap.com/manage/accounts), which will help to avoid any potential conflicts.
2424

25-
This is documented under [Ansible Collection for SAP Launchpad - Requirements, Dependencies and Testing](https://github.com/sap-linuxlab/community.sap_launchpad#requirements-dependencies-and-testing)
25+
This is documented under [Execution - Credentials](https://github.com/sap-linuxlab/community.sap_launchpad#requirements-dependencies-and-testing).
2626

2727
### <samp>'SAP SSO authentication failed - 404 Client Error: Not Found for url: `https://origin.softwaredownloads.sap.com/tokengen/?file=___`'</samp>
2828

playbooks/sample-download-install-media.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,15 @@
3535

3636
# Use task block to call Ansible Module
3737
tasks:
38-
- name: Execute Ansible Module to download SAP software
39-
community.sap_launchpad.software_center_download:
40-
suser_id: "{{ suser_id }}"
41-
suser_password: "{{ suser_password }}"
42-
softwarecenter_search_query: "{{ item }}"
43-
dest: "/tmp/"
44-
with_items: "{{ softwarecenter_search_list }}"
38+
- name: Execute Ansible Module to download SAP software
39+
community.sap_launchpad.software_center_download:
40+
suser_id: "{{ suser_id }}"
41+
suser_password: "{{ suser_password }}"
42+
softwarecenter_search_query: "{{ item }}"
43+
dest: "/tmp/"
44+
loop: "{{ softwarecenter_search_list }}"
45+
loop_control:
46+
label: "{{ item }} : {{ download_task.msg }}"
47+
register: download_task
48+
retries: 1
49+
until: download_task is not failed

playbooks/sample-maintenance-planner-files-download.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,27 @@
2424

2525
# Use task block to call Ansible Module
2626
tasks:
27-
- name: Execute Ansible Module 'maintenance_planner_files' to get files from MP
28-
community.sap_launchpad.maintenance_planner_files:
29-
suser_id: "{{ suser_id }}"
30-
suser_password: "{{ suser_password }}"
31-
transaction_name: "{{ mp_transaction_name }}"
32-
register: sap_maintenance_planner_basket_register
27+
- name: Execute Ansible Module 'maintenance_planner_files' to get files from MP
28+
community.sap_launchpad.maintenance_planner_files:
29+
suser_id: "{{ suser_id }}"
30+
suser_password: "{{ suser_password }}"
31+
transaction_name: "{{ mp_transaction_name }}"
32+
register: sap_maintenance_planner_basket_register
3333

3434
# - debug:
3535
# msg:
3636
# - "{{ sap_maintenance_planner_basket_register.download_basket }}"
3737

38-
- name: Execute Ansible Module 'software_center_download' to download files
39-
community.sap_launchpad.software_center_download:
40-
suser_id: "{{ suser_id }}"
41-
suser_password: "{{ suser_password }}"
42-
download_link: "{{ item.DirectLink }}"
43-
download_filename: "{{ item.Filename }}"
44-
dest: "/tmp/test"
45-
loop: "{{ sap_maintenance_planner_basket_register.download_basket }}"
38+
- name: Execute Ansible Module 'software_center_download' to download files
39+
community.sap_launchpad.software_center_download:
40+
suser_id: "{{ suser_id }}"
41+
suser_password: "{{ suser_password }}"
42+
download_link: "{{ item.DirectLink }}"
43+
download_filename: "{{ item.Filename }}"
44+
dest: "/tmp/test"
45+
loop: "{{ sap_maintenance_planner_basket_register.download_basket }}"
46+
loop_control:
47+
label: "{{ item }} : {{ download_task.msg }}"
48+
register: download_task
49+
retries: 1
50+
until: download_task is not failed

plugins/modules/software_center_download.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
#########################
8484

8585
import requests
86+
import glob
8687
from ansible.module_utils.basic import AnsibleModule
8788

8889
# Import runner
@@ -132,10 +133,15 @@ def run_module():
132133
# Main run
133134

134135
try:
136+
137+
# Search directory and subdirectories for filename without file extension
135138
filename = query if query else download_filename
136-
if os.path.exists(os.path.join(dest, filename)):
137-
module.exit_json(skipped=True, msg="file {} already exists".format(filename))
139+
pattern = dest + '/**/' + os.path.splitext(filename)[0] + '*'
140+
for file in glob.glob(pattern, recursive=True):
141+
if os.path.exists(file):
142+
module.exit_json(skipped=True, msg="file {} already exists".format(file))
138143

144+
# Initiate login with given credentials
139145
sap_sso_login(username, password)
140146

141147
# EXEC: query

0 commit comments

Comments
 (0)