|
1 | 1 | --- |
2 | | -- name: Initial install of Python altinstall for PyRFC |
3 | | - ansible.builtin.include_tasks: python_pyrfc_init.yml |
4 | | - when: pyrfc_first_run | bool |
5 | 2 |
|
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) |
9 | 35 |
|
10 | 36 | # Use Ansible Task block to call sap_pyrfc Ansible Module in the Ansible Collection for sap_libs |
11 | 37 | # RFC call using variables set by the Ansible Playbook when calling this Ansible Role |
12 | 38 | - 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" |
17 | 42 | vars: |
18 | 43 | 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 }}" |
0 commit comments