Skip to content

Commit 509ecab

Browse files
authored
Merge pull request #21 from sean-freeman/sap_rfc_overhaul
sap_rfc: overhaul
2 parents 9991fdd + b38e6d1 commit 509ecab

File tree

13 files changed

+230
-101
lines changed

13 files changed

+230
-101
lines changed

roles/sap_control/tasks/functions/restart_sapstartsrv.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# Stop sapstartsrv
1414
- name: SAPstartsrv - Stop sapstartsrv {{ passed_sap_sid }}-{{ passed_sap_nr }}
1515
ansible.builtin.shell: |
16-
source ~/.profile && cdexe; sapcontrol -nr {{ passed_sap_nr }} -function StopService {{ passed_sap_sid }}
16+
source ~/.profile ; sapcontrol -nr {{ passed_sap_nr }} -function StopService {{ passed_sap_sid }}
1717
args:
1818
executable: /bin/bash
1919
become: true
@@ -25,7 +25,7 @@
2525
# Start sapstartsrv
2626
- name: SAPstartsrv - Start sapstartsrv {{ passed_sap_sid }}-{{ passed_sap_nr }}
2727
ansible.builtin.shell: |
28-
source ~/.profile && cdexe; sapcontrol -nr {{ passed_sap_nr }} -function StartService {{ passed_sap_sid }}
28+
source ~/.profile ; sapcontrol -nr {{ passed_sap_nr }} -function StartService {{ passed_sap_sid }}
2929
args:
3030
executable: /bin/bash
3131
become: true

roles/sap_control/tasks/functions/sapstartsrv.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Check sapstartsrv
77
- name: SAPstartsrv - Check sapstartsrv
88
ansible.builtin.shell: |
9-
source ~/.profile && cdexe; sapcontrol -nr {{ passed_sap_nr }} -function GetSystemInstanceList
9+
source ~/.profile ; sapcontrol -nr {{ passed_sap_nr }} -function GetSystemInstanceList
1010
args:
1111
executable: /bin/bash
1212
become: true

roles/sap_control/tasks/sapcontrol.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
source ~/.profile && sapcontrol -nr {{ passed_sap_nr }} -function {{ vars['sap_control_' + funct_type] }}
1818
args:
1919
executable: /bin/bash
20-
warn: false
2120
become: true
2221
become_user: "{{ passed_sap_sid | lower }}adm"
2322
register: sapcontrol_status

roles/sap_profile_update/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
- name: SAP Profile Update - Get Instance Profile
44
ansible.builtin.shell: |
55
set -o pipefail
6-
source ~/.profile && cdexe; sapcontrol -nr {{ sap_update_profile_instance_nr }} -function ParameterValue SAPPROFILE | grep profile
6+
source ~/.profile ; sapcontrol -nr {{ sap_update_profile_instance_nr }} -function ParameterValue SAPPROFILE | grep profile
77
args:
88
executable: /bin/bash
99
become: true
1010
become_user: "{{ sap_update_profile_sid | lower }}adm"
1111
register: get_instance_profile
1212

13-
- name: setup facts
13+
- name: SAP Profile Update - Setup facts
1414
ansible.builtin.set_fact:
1515
sap_update_profile_default_profile_file_path: "/sapmnt/{{ sap_update_profile_sid }}/profile/DEFAULT.PFL"
1616
sap_update_profile_instance_profile_file_path: "{{ get_instance_profile.stdout }}"

roles/sap_rfc/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# sap_rfc Ansible Role
22

3-
The sap_rfc Ansible Role executes an SAP Remote Function Call (RFC), 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)).
3+
The sap_rfc Ansible Role executes an SAP Remote Function Call (RFC) from a server-side host with connectivity to the SAP System host/s, 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)).
44

55
## Ansible Role Overview
66

77
The sap_rfc Ansible Role uses:
88
- 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).
99
- 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).
1010

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.
11+
Appropriate target SAP System user authorizations are required for the execution 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.
1212

1313
The Ansible Role does not contain any system-altering RFCs by default when executed.
1414

@@ -60,7 +60,7 @@ These RFC parameter data elements are mapped to the equivilant Python data type
6060

6161
`Ansible Task code example for data element:`
6262
```yaml
63-
target_parameters:
63+
sap_rfc_target_parameters:
6464
VAR: 'ECHO'
6565
```
6666
@@ -71,7 +71,7 @@ target_parameters:
7171
7272
`Ansible Task code example for ABAP Struture:`
7373
```yaml
74-
target_parameters:
74+
sap_rfc_target_parameters:
7575
IMPORTSTRUCT:
7676
RFCFLOAT: 1.1
7777
RFCCHAR1: 'A'
@@ -84,7 +84,7 @@ target_parameters:
8484

8585
`Ansible Task code example for ABAP Table:`
8686
```yaml
87-
target_parameters:
87+
sap_rfc_target_parameters:
8888
RFCTABLE:
8989
- COLUMN0: SAP
9090
- COLUMN1: 1.23

roles/sap_rfc/defaults/main.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
#pyrfc_first_run: true
1+
---
22

3-
#sap_nwrfc_sdk: nwrfc750P_10-70002752.zip
3+
# sap_rfc_first_run_download_sap_user_id: ""
4+
# sap_rfc_first_run_download_sap_user_password: ""
5+
sap_rfc_first_run_download_path: /software
46

5-
#target_connection:
7+
#sap_rfc_target_connection:
68
# ashost: s4hana.poc.cloud
79
# sysid: TDT
810
# sysnr: "01"
@@ -15,7 +17,22 @@
1517
# gwhost: gateway.poc.cloud
1618
# ghserv: gateway.poc.cloud
1719

18-
target_function: STFC_CONNECTION
20+
sap_rfc_target_function: STFC_CONNECTION
1921

20-
target_parameters:
22+
sap_rfc_target_parameters:
2123
REQUTEXT: "Hello SAP!"
24+
25+
26+
# Override default for detected CPU Architecture (x86_64, ppc64le)
27+
# Contains /usr/local/sap/nwrfcsdk/lib with libsapnwrfc.so , libicuuc.so.50 , libicudata.so.50 , libicui18n.so.50 , libsapucum.so
28+
# Contains /usr/local/sap/nwrfcsdk/include with sapdecf.h , sapnwrfc.h , sapucrfc.h
29+
# sap_rfc_first_run_download_nwrfc_sdk: "" # 7.50 x86_64 = nwrfc750P_12-70002752.zip , ppc64le = nwrfc750P_12-70002761.zip
30+
31+
32+
# NOT USED:
33+
# May cause errors with additional dependency libs not available in the LD_LIBRARY_PATH '/usr/local/sap/nwrfcsdk/lib'
34+
# (e.g. libicuuc65.so, libicudata65.so, libicui18n65.so)
35+
# Not recommended as per SAP Note 3384574 - SAP NW RFC SDK 7.50 hotfix installation
36+
# Therefore Ansible Tasks code exists, but commented-out
37+
# sap_rfc_first_run_download_sapcar: "" # x86_64 = SAPCAR_1115-70006178.EXE , ppc64le = SAPCAR_1115-70006238.EXE
38+
# sap_rfc_first_run_download_nwrfc_sdk_patch: "" # 7.93 Backwards Compatible x86_64 = sapnwrfc_69-70007807.sar , ppc64le = sapnwrfc_69-70007832.sar

roles/sap_rfc/meta/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ galaxy_info:
1414
dependencies: []
1515
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
1616
collections:
17-
- community.sap_libs
18-
- community.sap_launchpad
17+
- community.sap_libs
18+
- community.sap_launchpad

roles/sap_rfc/tasks/main.yml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,47 @@
11
---
2-
- name: Initial install of Python altinstall for PyRFC
3-
ansible.builtin.include_tasks: python_pyrfc_init.yml
4-
when: pyrfc_first_run | bool
52

6-
- name: Discover Python altinstall for PyRFC
7-
ansible.builtin.include_tasks: python_pyrfc_discover.yml
8-
when: not pyrfc_first_run | bool
3+
- name: Identify SAP NW RFC Library home directory
4+
ansible.builtin.find:
5+
paths: /usr/local/sap
6+
recurse: true
7+
file_type: directory
8+
patterns: include
9+
register: __sap_rfc_nwrfc_home
10+
11+
- name: Identify SAP NW RFC Library compiled shared library (libsapnwrfc.so)
12+
ansible.builtin.find:
13+
paths: /usr/local/sap/nwrfcsdk
14+
recurse: true
15+
file_type: file
16+
patterns: libsapnwrfc.so
17+
register: __sap_rfc_nwrfc_lib
18+
19+
- name: Identify Python virtual environment for sap_rfc Ansible Role
20+
ansible.builtin.stat:
21+
path: ~/env/pyrfc_env
22+
register: __sap_rfc_python_virtual_env
23+
24+
- name: Set fact based on identified SAP NW RFC Library
25+
ansible.builtin.set_fact:
26+
__sap_rfc_first_run: "{{ true if ((__sap_rfc_nwrfc_home.files | length) == 0 or (__sap_rfc_nwrfc_lib.files | length) == 0) else false }}"
27+
28+
- name: Initial install of SAP NW RFC SDK Library
29+
ansible.builtin.include_tasks: setup/nwrfcsdk_init.yml
30+
when: __sap_rfc_first_run | bool
31+
32+
- name: Initial install of Python virtual environment for PyRFC
33+
ansible.builtin.include_tasks: setup/python_init.yml
34+
when: (__sap_rfc_first_run | bool) or (not __sap_rfc_python_virtual_env.stat.exists)
935

1036
# Use Ansible Task block to call sap_pyrfc Ansible Module in the Ansible Collection for sap_libs
1137
# RFC call using variables set by the Ansible Playbook when calling this Ansible Role
1238
- name: Execute Ansible Module to call PyRFC using the virtualenv Python3
13-
community.sap_libs.sap_pyrfc:
14-
function: "{{ target_function }}"
15-
parameters: "{{ target_parameters }}"
16-
connection: "{{ target_connection }}"
39+
environment:
40+
SAPNWRFC_HOME: "{{ __sap_rfc_nwrfc_home.files[0].path | dirname }}"
41+
LD_LIBRARY_PATH: "$LD_LIBRARY_PATH:$SAPNWRFC_HOME/lib"
1742
vars:
1843
ansible_python_interpreter: ~/env/pyrfc_env/bin/python3
44+
community.sap_libs.sap_pyrfc:
45+
function: "{{ sap_rfc_target_function }}"
46+
parameters: "{{ sap_rfc_target_parameters }}"
47+
connection: "{{ sap_rfc_target_connection }}"

roles/sap_rfc/tasks/python_pyrfc_discover.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

roles/sap_rfc/tasks/python_pyrfc_init.yml

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

0 commit comments

Comments
 (0)