Skip to content

Commit 1e5cbe1

Browse files
committed
feat: change role name and structure
1 parent 7b54970 commit 1e5cbe1

File tree

8 files changed

+122
-96
lines changed

8 files changed

+122
-96
lines changed

playbooks/sample-sap-pyrfc.yml renamed to playbooks/sample-sap-rfc.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
vars:
66
suser_id: 'S00000000'
77
suser_password: 'password'
8-
sap_nwrfc_sdk: nwrfc750P_8-70002752.zip
8+
sap_nwrfc_sdk: nwrfc750P_10-70002752.zip
99
reuse_connection:
1010
ashost: s4hana.poc.cloud
1111
sysid: TDT
@@ -29,7 +29,7 @@
2929
REQUTEXT: 'Hello SAP!'
3030
target_connection: "{{ reuse_connection }}"
3131
include_role:
32-
name: community.sap_operations.sap_pyrfc
32+
name: community.sap_operations.sap_rfc
3333
register: sap_rfc_output1
3434

3535
- name: DEBUG - Output of STFC_CONNECTION
@@ -47,7 +47,7 @@
4747
- COLUMN0: test
4848
target_connection: "{{ reuse_connection }}"
4949
include_role:
50-
name: community.sap_operations.sap_pyrfc
50+
name: community.sap_operations.sap_rfc
5151
register: sap_rfc_output2
5252

5353
- name: DEBUG - Output of STFC_STRUCTURE

roles/sap_pyrfc/README.md

Lines changed: 0 additions & 74 deletions
This file was deleted.

roles/sap_rfc/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# sap_rfc Ansible Role
2+
3+
The sap_rfc Ansible Role executes SAP RFCs, and performs setup as necessary ([`PyRFC`](https://github.com/SAP/PyRFC) open source by SAP, and [`SAP NWRFC SDK`](https://support.sap.com/en/product/connectors/nwrfcsdk.html))
4+
5+
## Ansible Role Overview
6+
7+
The sap_rfc Ansible Role uses:
8+
- the Ansible Module `sap_pyrfc` from the Ansible Collection `sap_libs`, which leverages the open-source [`PyRFC`](https://github.com/SAP/PyRFC) bindings for the proprietary [`SAP NWRFC SDK`](https://support.sap.com/en/product/connectors/nwrfcsdk.html).
9+
- the Ansible Module `software_center_download` from the Ansible Collection `sap_launchpad`, which on first-run is used to download the [`SAP NWRFC SDK`](https://support.sap.com/en/product/connectors/nwrfcsdk.html).
10+
11+
Appropriate target SAP System user authorizations are required for the execute of the RFCs, and on first-run to obtain the [`SAP NWRFC SDK`](https://support.sap.com/en/product/connectors/nwrfcsdk.html) an SAP User ID with download privileges is required.
12+
13+
The Ansible Role does not contain any system-altering RFCs by default when executed.
14+
15+
The Ansible Task variables define the RFC actions to be executed. Examples are given below.
16+
17+
## Ansible Role Requirements and Dependencies
18+
19+
### Dependencies on other Ansible Roles
20+
21+
To execute successfully, this Ansible Role is dependant on the Ansible Collections:
22+
- `community.sap_launchpad` on first run
23+
- `community.sap_libs` for every run
24+
25+
The first run will setup Python altinstall, subsequent runs on the same host will re-use the Python altinstall where PyRFC enabled. This is to protect the System default Python installation from additional or altered versions of Python Packages.
26+
27+
### Operating System
28+
29+
This role has been tested on target systems using RHEL 8.x, and is designed for Linux operating systems.
30+
31+
This role has not been tested and amended for SAP NetWeaver Application Server instantiations on IBM AIX or Windows Server.
32+
33+
Assumptions for executing this role include:
34+
35+
- The target host has access to the SAP System (i.e. the SAP NetWeaver Application Server instance)
36+
- Registered OS License and OS Package repositories are available (from the relevant content delivery network of the OS vendor)
37+
38+
## Examples
39+
40+
A sample [Ansible Playbook for using the sap_rfc Ansible Role](../../playbooks/sample-sap-rfc.yml) is provided, which provides:
41+
42+
- Ansible Vars for SAP User ID with download privileges for first-run
43+
- Ansible Vars for SAP System connection details and user authorization
44+
45+
The Ansible Role is designed to provide for all different RFCs. Therefore, the RFC parameters _(IMPORTING, EXPORTING, CHANGING)_ can accept the following data types:
46+
47+
- Data elements (string, integer etc.)
48+
- ABAP Structure
49+
- ABAP Table
50+
51+
These RFC parameter data elements are mapped to the equivilant Python data type (e.g. string, integer, dictionary, list). Examples of these are shown below.
52+
53+
### Examples of Ansible Task variables for different RFC parameters
54+
55+
**RFC parameter requires a data element:**
56+
57+
- Commonly string or integer
58+
- For this input type the PyRFC Python module requires a Python string or integer
59+
- Ansible Task must declare the parameter name and use a YAML variable
60+
61+
`Ansible Task code example for data element:`
62+
```yaml
63+
target_parameters:
64+
VAR: 'ECHO'
65+
```
66+
67+
**RFC parameter requires an ABAP Structure:**
68+
69+
- For this input type the PyRFC Python module requires a Python Dictionary.
70+
- Ansible Task must declare the parameter name and use a YAML dictionary (key:value)
71+
72+
`Ansible Task code example for ABAP Struture:`
73+
```yaml
74+
target_parameters:
75+
IMPORTSTRUCT:
76+
RFCFLOAT: 1.1
77+
RFCCHAR1: 'A'
78+
```
79+
80+
**RFC requires an ABAP Table:**
81+
82+
- For this input type the PyRFC Python module requires a Python List.
83+
- The Ansible Task must declare the parameter name and use a YAML list
84+
85+
`Ansible Task code example for ABAP Table:`
86+
```yaml
87+
target_parameters:
88+
RFCTABLE:
89+
- COLUMN0: SAP
90+
- COLUMN1: 1.23
91+
```
92+
93+
## Supplementary information
94+
95+
The [Supplementary information](./SUPPLEMENTARY.md) provides:
96+
- Context of SAP NWRFC SDK and PyRFC
97+
- Explanation of samples from SAP NWRFC SDK
98+
- Brief explanation of SAP RFCs
99+
- Security concerns with RFCs and SAP Systems

roles/sap_pyrfc/SUPPLEMENTARY.md renamed to roles/sap_rfc/SUPPLEMENTARY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Supplementary information for sap_pyrfc Ansible Role
1+
# Supplementary information for sap_rfc Ansible Role
22

33
## Brief explanation of SAP RFCs
44

@@ -44,7 +44,7 @@ Other connectors/bindings to have previously existed but are infrequently used w
4444

4545
This additional context is to avoid confusion. By default the SAP NetWeaver RFC SDK includes two sample ALE programs (rfcexec or startrfc) as reference implementations which support the SAP IDoc scenario.
4646

47-
Neither of these sample programs are used by sap_pyrfc Ansible Role or the underlying PyRFC bindings.
47+
Neither of these sample programs are used by sap_rfc Ansible Role or the underlying sap_pyrfc Ansible Module and the PyRFC bindings.
4848

4949
These sample ALE programs appear in documentation available on help.sap.com under the IDoc Interface/ALE section:
5050
- Using startrfc, [SAP NetWeaver AS - IDoc Interface/ALE - Inbound: Triggering the SAP System](https://help.sap.com/viewer/8f3819b0c24149b5959ab31070b64058/7.52.3/en-US/4b4c43dd3b71265ce10000000a421937.html)
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
pyrfc_first_run: true
1+
#pyrfc_first_run: true
22

3-
sap_nwrfc_sdk: nwrfc750P_8-70002752.zip
3+
#sap_nwrfc_sdk: nwrfc750P_10-70002752.zip
44

5-
target_function: STFC_CONNECTION
6-
7-
target_parameters:
8-
REQUTEXT: "Hello SAP!"
9-
10-
target_connection:
11-
ashost: s4hana.poc.cloud
12-
sysid: TDT
13-
sysnr: "01"
14-
client: "400"
15-
user: DDIC
16-
passwd: Password1
17-
lang: EN
5+
#target_connection:
6+
# ashost: s4hana.poc.cloud
7+
# sysid: TDT
8+
# sysnr: "01"
9+
# client: "400"
10+
# user: DDIC
11+
# passwd: Password1
12+
# lang: EN
1813
# trace: 3
1914
# saprouter: /H/111.22.33.44/S/3299/W/e5ngxs/H/555.66.777.888/H/
2015
# gwhost: gateway.poc.cloud
2116
# ghserv: gateway.poc.cloud
17+
18+
target_function: STFC_CONNECTION
19+
20+
target_parameters:
21+
REQUTEXT: "Hello SAP!"

roles/sap_pyrfc/tasks/main.yml renamed to roles/sap_rfc/tasks/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
ansible.builtin.include_tasks: python_pyrfc_discover.yml
88
when: not pyrfc_first_run | bool
99

10+
# Use Ansible Task block to call sap_pyrfc Ansible Module in the Ansible Collection for sap_libs
1011
# RFC call using variables set by the Ansible Playbook when calling this Ansible Role
1112
- name: Execute Ansible Module to call PyRFC using the virtualenv Python3
12-
community.sap_operations.sap_pyrfc:
13+
community.sap_libs.sap_pyrfc:
1314
function: "{{ target_function }}"
1415
parameters: "{{ target_parameters }}"
1516
connection: "{{ target_connection }}"

roles/sap_pyrfc/tasks/python_pyrfc_init.yml renamed to roles/sap_rfc/tasks/python_pyrfc_init.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
virtualenv_command: virtualenv
3939
virtualenv_python: python3
4040

41-
# Use task block to call Ansible Module in the Ansible Collection for sap_operations
41+
# Use task block to call Ansible Module in the Ansible Collection for sap_launchpad
4242
- name: Execute Ansible Module to download SAP software
4343
community.sap_launchpad.software_center_download:
4444
suser_id: "{{ suser_id }}"

0 commit comments

Comments
 (0)