sap.sap_operations.hdbuserstore_info module – Get information from HANA user store (HANA command hdbsuserstore)
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.hdbuserstore_info
.
New in sap.sap_operations 1.0.0
Synopsis
Get information from HANA user store (HANA command hdbsuserstore) Key name is returned in case key exists (set previously)
Parameters
Parameter |
Comments |
---|---|
Custom path of the hdbuserstore binary. Default: |
|
Get info about the key |
Notes
Note
See NOTE in documentation for hdbuserstore module in regards to running ansible modules when becoming <hanasid>adm user with ‘-i’ flag. Otherwise you might face issues with ansible module executions in SAP HANA environments.”
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
Examples
---
- name: Get info about the key mykey from HDB user store (recommended way, see notes)
sap.sap_operations.hdbuserstore_info:
key: mykey
become: true
become_user: <hanasid>adm
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 |
---|---|
HDB key info Returned: always |