Skip to content

Commit

Permalink
Merge pull request #22 from sap-linuxlab/dev
Browse files Browse the repository at this point in the history
collection: merge dev to main for release 0.9.1
  • Loading branch information
sean-freeman authored Jan 10, 2024
2 parents bfd09a5 + 509ecab commit 3405579
Show file tree
Hide file tree
Showing 18 changed files with 278 additions and 137 deletions.
8 changes: 0 additions & 8 deletions playbooks/test_restart.yml

This file was deleted.

4 changes: 2 additions & 2 deletions roles/sap_control/tasks/functions/restart_sapstartsrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Stop sapstartsrv
- name: SAPstartsrv - Stop sapstartsrv {{ passed_sap_sid }}-{{ passed_sap_nr }}
ansible.builtin.shell: |
source ~/.profile && cdexe; sapcontrol -nr {{ passed_sap_nr }} -function StopService {{ passed_sap_sid }}
source ~/.profile ; sapcontrol -nr {{ passed_sap_nr }} -function StopService {{ passed_sap_sid }}
args:
executable: /bin/bash
become: true
Expand All @@ -25,7 +25,7 @@
# Start sapstartsrv
- name: SAPstartsrv - Start sapstartsrv {{ passed_sap_sid }}-{{ passed_sap_nr }}
ansible.builtin.shell: |
source ~/.profile && cdexe; sapcontrol -nr {{ passed_sap_nr }} -function StartService {{ passed_sap_sid }}
source ~/.profile ; sapcontrol -nr {{ passed_sap_nr }} -function StartService {{ passed_sap_sid }}
args:
executable: /bin/bash
become: true
Expand Down
2 changes: 1 addition & 1 deletion roles/sap_control/tasks/functions/sapstartsrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Check sapstartsrv
- name: SAPstartsrv - Check sapstartsrv
ansible.builtin.shell: |
source ~/.profile && cdexe; sapcontrol -nr {{ passed_sap_nr }} -function GetSystemInstanceList
source ~/.profile ; sapcontrol -nr {{ passed_sap_nr }} -function GetSystemInstanceList
args:
executable: /bin/bash
become: true
Expand Down
1 change: 0 additions & 1 deletion roles/sap_control/tasks/sapcontrol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
source ~/.profile && sapcontrol -nr {{ passed_sap_nr }} -function {{ vars['sap_control_' + funct_type] }}
args:
executable: /bin/bash
warn: false
become: true
become_user: "{{ passed_sap_sid | lower }}adm"
register: sapcontrol_status
Expand Down
19 changes: 12 additions & 7 deletions roles/sap_hana_backint/tasks/setup/setup_backint_aws_s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,22 @@

# Setup

- name: SAP HANA Backint - Setup - AWS S3 - Clone hanacleaner.py
ansible.builtin.git:
repo: https://github.com/chriselswede/hanacleaner.git
dest: "$HOME/.ansible/tmp/git_hanacleaner"
# single_branch: true # Not compatible with Ansible 2.9
version: master
- name: SAP HANA Backint - Setup - AWS S3 - Download hanacleaner.py
ansible.builtin.get_url:
url: https://github.com/chriselswede/hanacleaner/archive/refs/heads/master.zip
dest: "/tmp/hanacleaner-master.zip"
mode: '0440'

- name: SAP HANA Backint - Setup - AWS S3 - Unpack hanacleaner.py
ansible.builtin.unarchive:
remote_src: true
src: "/tmp/hanacleaner-master.zip"
dest: "/tmp"

# Copy hanacleaner.py
- name: SAP HANA Backint - Setup - AWS S3 - Copy hanacleaner.py to SAP HANA backint directory
ansible.builtin.copy:
src: "$HOME/.ansible/tmp/git_hanacleaner/hanacleaner.py"
src: "/tmp/hanacleaner-master/hanacleaner.py"
dest: "{{ sap_hana_backint_setup_backint_directory }}/hanacleaner.py"
mode: "0755"
remote_src: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,22 @@

# Setup

- name: SAP HANA Backint - Setup - MS Azure Backup to MS Azure RSV - Clone hanacleaner.py
ansible.builtin.git:
repo: https://github.com/chriselswede/hanacleaner.git
dest: "$HOME/.ansible/tmp/git_hanacleaner"
# single_branch: true # Not compatible with Ansible 2.9
version: master
- name: SAP HANA Backint - Setup - Download hanacleaner.py
ansible.builtin.get_url:
url: https://github.com/chriselswede/hanacleaner/archive/refs/heads/master.zip
dest: "/tmp/hanacleaner-master.zip"
mode: '0440'

- name: SAP HANA Backint - Setup - Unpack hanacleaner.py
ansible.builtin.unarchive:
remote_src: true
src: "/tmp/hanacleaner-master.zip"
dest: "/tmp"

# Copy hanacleaner.py
- name: SAP HANA Backint - Setup - MS Azure Backup to MS Azure RSV - Copy hanacleaner.py to SAP HANA backint directory
ansible.builtin.copy:
src: "$HOME/.ansible/tmp/git_hanacleaner/hanacleaner.py"
src: "/tmp/hanacleaner-master/hanacleaner.py"
dest: "{{ sap_hana_backint_setup_backint_directory }}/hanacleaner.py"
mode: "0755"
remote_src: true
Expand Down
19 changes: 12 additions & 7 deletions roles/sap_hana_backint/tasks/setup/setup_backint_gcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@
sap_hana_backint_setup_backint_directory: "/usr/sap/{{ passed_sap_hana_sid }}/SYS/global/hdb/opt"
passed_sap_hana_instance_nr: "{{ sap_hana_instance_nr_one[0] }}"

- name: SAP HANA Backint - Setup - GCS - Clone hanacleaner.py
ansible.builtin.git:
repo: https://github.com/chriselswede/hanacleaner.git
dest: "$HOME/.ansible/tmp/git_hanacleaner"
# single_branch: true # Not compatible with Ansible 2.9
version: master
- name: SAP HANA Backint - Setup - GCS - Download hanacleaner.py
ansible.builtin.get_url:
url: https://github.com/chriselswede/hanacleaner/archive/refs/heads/master.zip
dest: "/tmp/hanacleaner-master.zip"
mode: '0440'

- name: SAP HANA Backint - Setup - GCS - Unpack hanacleaner.py
ansible.builtin.unarchive:
remote_src: true
src: "/tmp/hanacleaner-master.zip"
dest: "/tmp"

# Copy hanacleaner.py
- name: SAP HANA Backint - Setup - GCS - Copy hanacleaner.py to SAP HANA backint directory
ansible.builtin.copy:
src: "$HOME/.ansible/tmp/git_hanacleaner/hanacleaner.py"
src: "/tmp/hanacleaner-master/hanacleaner.py"
dest: "{{ sap_hana_backint_setup_backint_directory }}/hanacleaner.py"
mode: "0755"
remote_src: true
Expand Down
19 changes: 12 additions & 7 deletions roles/sap_hana_backint/tasks/setup/setup_backint_ibm_cos_s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,22 @@

# Setup

- name: SAP HANA Backint - Setup - IBM COS - Clone hanacleaner.py
ansible.builtin.git:
repo: https://github.com/chriselswede/hanacleaner.git
dest: "$HOME/.ansible/tmp/git_hanacleaner"
# single_branch: true # Not compatible with Ansible 2.9
version: master
- name: SAP HANA Backint - Setup - IBM COS - Download hanacleaner.py
ansible.builtin.get_url:
url: https://github.com/chriselswede/hanacleaner/archive/refs/heads/master.zip
dest: "/tmp/hanacleaner-master.zip"
mode: '0440'

- name: SAP HANA Backint - Setup - IBM COS - Unpack hanacleaner.py
ansible.builtin.unarchive:
remote_src: true
src: "/tmp/hanacleaner-master.zip"
dest: "/tmp"

# Copy hanacleaner.py
- name: SAP HANA Backint - Setup - IBM COS - Copy hanacleaner.py to SAP HANA backint directory
ansible.builtin.copy:
src: "$HOME/.ansible/tmp/git_hanacleaner/hanacleaner.py"
src: "/tmp/hanacleaner-master/hanacleaner.py"
dest: "{{ sap_hana_backint_setup_backint_directory }}/hanacleaner.py"
mode: "0755"
remote_src: true
Expand Down
4 changes: 2 additions & 2 deletions roles/sap_profile_update/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
- name: SAP Profile Update - Get Instance Profile
ansible.builtin.shell: |
set -o pipefail
source ~/.profile && cdexe; sapcontrol -nr {{ sap_update_profile_instance_nr }} -function ParameterValue SAPPROFILE | grep profile
source ~/.profile ; sapcontrol -nr {{ sap_update_profile_instance_nr }} -function ParameterValue SAPPROFILE | grep profile
args:
executable: /bin/bash
become: true
become_user: "{{ sap_update_profile_sid | lower }}adm"
register: get_instance_profile

- name: setup facts
- name: SAP Profile Update - Setup facts
ansible.builtin.set_fact:
sap_update_profile_default_profile_file_path: "/sapmnt/{{ sap_update_profile_sid }}/profile/DEFAULT.PFL"
sap_update_profile_instance_profile_file_path: "{{ get_instance_profile.stdout }}"
Expand Down
10 changes: 5 additions & 5 deletions roles/sap_rfc/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# sap_rfc Ansible Role

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)).
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)).

## Ansible Role Overview

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

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.
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.

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

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

`Ansible Task code example for data element:`
```yaml
target_parameters:
sap_rfc_target_parameters:
VAR: 'ECHO'
```
Expand All @@ -71,7 +71,7 @@ target_parameters:
`Ansible Task code example for ABAP Struture:`
```yaml
target_parameters:
sap_rfc_target_parameters:
IMPORTSTRUCT:
RFCFLOAT: 1.1
RFCCHAR1: 'A'
Expand All @@ -84,7 +84,7 @@ target_parameters:

`Ansible Task code example for ABAP Table:`
```yaml
target_parameters:
sap_rfc_target_parameters:
RFCTABLE:
- COLUMN0: SAP
- COLUMN1: 1.23
Expand Down
27 changes: 22 additions & 5 deletions roles/sap_rfc/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pyrfc_first_run: true
---

#sap_nwrfc_sdk: nwrfc750P_10-70002752.zip
# sap_rfc_first_run_download_sap_user_id: ""
# sap_rfc_first_run_download_sap_user_password: ""
sap_rfc_first_run_download_path: /software

#target_connection:
#sap_rfc_target_connection:
# ashost: s4hana.poc.cloud
# sysid: TDT
# sysnr: "01"
Expand All @@ -15,7 +17,22 @@
# gwhost: gateway.poc.cloud
# ghserv: gateway.poc.cloud

target_function: STFC_CONNECTION
sap_rfc_target_function: STFC_CONNECTION

target_parameters:
sap_rfc_target_parameters:
REQUTEXT: "Hello SAP!"


# Override default for detected CPU Architecture (x86_64, ppc64le)
# Contains /usr/local/sap/nwrfcsdk/lib with libsapnwrfc.so , libicuuc.so.50 , libicudata.so.50 , libicui18n.so.50 , libsapucum.so
# Contains /usr/local/sap/nwrfcsdk/include with sapdecf.h , sapnwrfc.h , sapucrfc.h
# sap_rfc_first_run_download_nwrfc_sdk: "" # 7.50 x86_64 = nwrfc750P_12-70002752.zip , ppc64le = nwrfc750P_12-70002761.zip


# NOT USED:
# May cause errors with additional dependency libs not available in the LD_LIBRARY_PATH '/usr/local/sap/nwrfcsdk/lib'
# (e.g. libicuuc65.so, libicudata65.so, libicui18n65.so)
# Not recommended as per SAP Note 3384574 - SAP NW RFC SDK 7.50 hotfix installation
# Therefore Ansible Tasks code exists, but commented-out
# sap_rfc_first_run_download_sapcar: "" # x86_64 = SAPCAR_1115-70006178.EXE , ppc64le = SAPCAR_1115-70006238.EXE
# sap_rfc_first_run_download_nwrfc_sdk_patch: "" # 7.93 Backwards Compatible x86_64 = sapnwrfc_69-70007807.sar , ppc64le = sapnwrfc_69-70007832.sar
4 changes: 2 additions & 2 deletions roles/sap_rfc/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ galaxy_info:
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
collections:
- community.sap_libs
- community.sap_launchpad
- community.sap_libs
- community.sap_launchpad
49 changes: 39 additions & 10 deletions roles/sap_rfc/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
---
- name: Initial install of Python altinstall for PyRFC
ansible.builtin.include_tasks: python_pyrfc_init.yml
when: pyrfc_first_run | bool

- name: Discover Python altinstall for PyRFC
ansible.builtin.include_tasks: python_pyrfc_discover.yml
when: not pyrfc_first_run | bool
- name: Identify SAP NW RFC Library home directory
ansible.builtin.find:
paths: /usr/local/sap
recurse: true
file_type: directory
patterns: include
register: __sap_rfc_nwrfc_home

- name: Identify SAP NW RFC Library compiled shared library (libsapnwrfc.so)
ansible.builtin.find:
paths: /usr/local/sap/nwrfcsdk
recurse: true
file_type: file
patterns: libsapnwrfc.so
register: __sap_rfc_nwrfc_lib

- name: Identify Python virtual environment for sap_rfc Ansible Role
ansible.builtin.stat:
path: ~/env/pyrfc_env
register: __sap_rfc_python_virtual_env

- name: Set fact based on identified SAP NW RFC Library
ansible.builtin.set_fact:
__sap_rfc_first_run: "{{ true if ((__sap_rfc_nwrfc_home.files | length) == 0 or (__sap_rfc_nwrfc_lib.files | length) == 0) else false }}"

- name: Initial install of SAP NW RFC SDK Library
ansible.builtin.include_tasks: setup/nwrfcsdk_init.yml
when: __sap_rfc_first_run | bool

- name: Initial install of Python virtual environment for PyRFC
ansible.builtin.include_tasks: setup/python_init.yml
when: (__sap_rfc_first_run | bool) or (not __sap_rfc_python_virtual_env.stat.exists)

# Use Ansible Task block to call sap_pyrfc Ansible Module in the Ansible Collection for sap_libs
# RFC call using variables set by the Ansible Playbook when calling this Ansible Role
- name: Execute Ansible Module to call PyRFC using the virtualenv Python3
community.sap_libs.sap_pyrfc:
function: "{{ target_function }}"
parameters: "{{ target_parameters }}"
connection: "{{ target_connection }}"
environment:
SAPNWRFC_HOME: "{{ __sap_rfc_nwrfc_home.files[0].path | dirname }}"
LD_LIBRARY_PATH: "$LD_LIBRARY_PATH:$SAPNWRFC_HOME/lib"
vars:
ansible_python_interpreter: ~/env/pyrfc_env/bin/python3
community.sap_libs.sap_pyrfc:
function: "{{ sap_rfc_target_function }}"
parameters: "{{ sap_rfc_target_parameters }}"
connection: "{{ sap_rfc_target_connection }}"
1 change: 0 additions & 1 deletion roles/sap_rfc/tasks/python_pyrfc_discover.yml

This file was deleted.

Loading

0 comments on commit 3405579

Please sign in to comment.