sap.sap_operations.hana_system_replication_info module – Get info about SAP HANA system replication configuration

Note

This module is part of the sap.sap_operations collection.

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install sap.sap_operations.

To use it in a playbook, specify: sap.sap_operations.hana_system_replication_info.

New in sap.sap_operations 2.11.0

Synopsis

  • Get information about SAP HANA system replication configuration

Notes

Note

  • This module is community supported

  • Module interface (parameters, output) expected to be stable but not guaranteed

  • Module planned to be released on Ansible Automation Hub after collecting some feedback

  • There is no guarantee that this module will be officially supported by Red Hat

  • Variable binary_path is required, because hdbuserstore command cannot be found in $PATH environment variable. If running ansible module using become directive with <hanasid>adm user and flag ‘-i’ (interactive - meaning load all environment for the user) ansible modules fail. This is due to the fact that <hanasid>adm user sets environment variables PYTHONHOME and PYTHONPATH (to use HANA python, not platform python) that confuses ansible. And also HANA python might not have all the necessary packages installed to run ansible module. In that case hdbuserstore command will not be in PATH environment variable for <hanasid>adm user and binary_path has to be provided.

  • There are several workaround around this unpleasant situation. First one is recommended.

  • Workaround 1 (recommended)

  • Run hdbsuserstore module with <hanasid>adm user with ‘-i’ (interactive) flag like so

    • name: Set the key mykey

  • sap.sap_operations.hdbuserstore:

  • key: mykey

  • env: localhost:30113

  • username: myuser

  • password: mypassword

  • become: true

  • become_user: <hanasid>adm

  • become_flags: -i

  • vars:

  • ansible_python_interpreter: ‘/usr/libexec/platform-python -E’

  • Option ‘-E’ for python interpreter will ignore all PYTHON environment variables, so ansible will run platform python without any problems. Variable ansible_python_interpreter have to be set to value “/usr/libexec/platform-python -E” on all RHEL versions for any ansible module execution when using become directive for <hanasid>adm user with become flag ‘-i’.

  • ansible_python_interpreter: “/usr/libexec/platform-python -E” can be set at task level (as above), at play level, or be set as host variable either in inventory file or as task in playbook:

  • To use other SAP HANA related ansible modules (for instances hana_system_replication_info), this is the only option, because other modules might not have parameters to accommodate for binary tool path.

  • Workaround 2 (only for hdbuserstore module)

  • Do not use interactive flag when becoming <hanasid>adm user.

    • name: Set the key mykey

  • sap.sap_operations.hdbuserstore:

  • key: mykey

  • env: localhost:30113

  • username: myuser

  • password: mypassword

  • binary_path: /usr/sap/HAN/SYS/exe/hdb

  • become: true

  • become_user: <hanasid>adm

  • In that case hdbuserstore command will not be in PATH environment variable for <hanasid>adm user and binary_path has to be provided.

  • Workaround 3 (only for hdbuserstore module)

  • Do not use interactive flag when becoming <hanasid>adm user. But do not want to provide value for variable binary_path.

  • In that case value for binary_path can be extracted from HANA parameter DIR_EXECUTABLE that one can get with parameter_info module

    • name: Get DIR_EXECUTABLE

  • sap.sap_operations.parameter_info:

  • instance_number: 00

  • name: DIR_EXECUTABLE

  • become: true

  • become_user: <hanasid>adm

  • register: __DIR_EXECUTABLE

    • name: Set the key mykey

  • sap.sap_operations.hdbuserstore:

  • key: mykey

  • env: localhost:30113

  • username: myuser

  • password: mypassword

  • binary_path: ‘{{ __DIR_EXECUTABLE.parameter_value[0] }}’

  • become: true

  • become_user: <hanasid>adm

See Also

See also

sap.sap_operations.hana_backup

Create SAP HANA database file backup.

sap.sap_operations.hana_restore

Restore SAP HANA database backup.

Examples

---
- name: Get hana system replication configuration information
  sap.sap_operations.hana_system_replication_info:
  become: true
  become_user: hsradm
  become_flags: -i
  vars:
    ansible_python_interpreter: "/usr/libexec/platform-python -E"

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

hana_system_replication_info

dictionary

Dictionary with HSR configuration info

Returned: success

Sample: {"has_secondaries_consumers_attached": false, "is_primary_suspended": false, "is_secondary_consumer_system": false, "is_source_system": true, "is_takeover_active": false, "mode": "primary", "online": true, "operation_mode": "primary", "site_id": "1", "site_name": "test"}

rc

integer

Return code of the ‘hdbnsutil -sr_state’ command

Returned: always

Sample: 0

stderr

string

Stderr of the ‘hdbnsutil -sr_state’ command

Returned: always

Sample: "Performing Final Memory Release with 8 threads.\nFinished Final Memory Release successfully.\n"

stdout

string

Stdout of the ‘hdbnsutil -sr_state’ command

Returned: always

Sample: "System Replication State\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nonline: true\n\nmode: primary\noperation mode: primary\nsite id: 1\nsite name: test\n\nis source system: true\nis secondary/consumer system: false\nhas secondaries/consumers attached: false\nis a takeover active: false\nis primary suspended: false\n\nHost Mappings:\n~~~~~~~~~~~~~~\n\n\nSite Mappings:\n~~~~~~~~~~~~~~\ntest (primary/)\n\nTier of test: 1\n\nReplication mode of test: primary\n\nOperation mode of test:\n\n\nHint based routing site:\ndone.\n"

Authors

  • Kirill Satarin (@kksat)