Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select statement against hana runs into python error #48

Open
1 task done
woreis opened this issue Sep 4, 2024 · 3 comments
Open
1 task done

select statement against hana runs into python error #48

woreis opened this issue Sep 4, 2024 · 3 comments

Comments

@woreis
Copy link

woreis commented Sep 4, 2024

Summary

Hi,
I just wanted to test sap_hdbsql.py and immediately run into an issue.

When I run this, I get the error shown below. But of course the struct.py file can be found on the target system.

Any idea, what could cause this problem ?
Help would be appreciated,
Thanks, Wolfgang

Issue Type

Bug Report

Component Name

sap_libs, module sap_hdbsql.py

Ansible Version

ansible [core 2.16.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/bechtle/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /etc/ansible/{{ ANSIBLE_HOME ~ "/collections:/usr/share/ansible/collections:/etc/ansible/collections" }}
  executable location = /usr/bin/ansible
  python version = 3.12.1 (main, Feb 21 2024, 10:25:11) [GCC 8.5.0 20210514 (Red Hat 8.5.0-21)] (/usr/bin/python3.12)
  jinja version = 3.1.2
  libyaml = True

community.sap_libs Version

[root@vcomprdsat001 community]# ansible-galaxy collection list

# /usr/share/ansible/collections/ansible_collections
Collection                  Version
--------------------------- -------
ansible.posix               1.5.4
community.general           8.6.0
community.sap_install       1.4.0
community.sap_libs          1.4.2
redhat.rhel_system_roles    1.23.0
redhat.satellite            4.0.0
redhat.satellite_operations 2.1.0

Configuration

$ ansible-config dump --only-changed

OS / Environment

RHEL 9

Steps to Reproduce

---

- hosts: '{{ ho | default([]) }}'

  tasks:
  - name: Simple select query
    become: true
    become_user: idhadm
    become_flags: '-i'
    community.sap_libs.sap_hdbsql:
      sid: "IDH"
      database: "SYSTEMDB"
      instance: "00"
      userstore: true
      user: "USER"
      host: "some.host:port"
      query: select user_name from users

Expected Results

I expected the List of users to be shown.

Actual Results

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named '_struct'
fatal: [vintdevhdb001.fdz.internal]: FAILED! => 
{
    "changed": false,
    "module_stderr": "Shared connection to som.host closed.\r\n",
    "module_stdout": "
        Traceback (most recent call last):\r\n File "/var/tmp/ansible-tmp-1725457957.175195-2959474-12846379217444/AnsiballZ_sap_hdbsql.py",
        line 107,in \r\n _ansiballz_main()\r\n File "/var/tmp/ansible-tmp-1725457957.175195-2959474-12846379217444/AnsiballZ_sap_hdbsql.py",
        line 24,in _ansiballz_main\r\n import base64\r\n File "/usr/sap/IDH/HDB00/exe/Python3/lib/python3.8/base64.py",
        line 10,in \r\n import struct\r\n File "/usr/sap/IDH/HDB00/exe/Python3/lib/python3.8/struct.py",
        line 13,in \r\n from _struct import *\r\nModuleNotFoundError: No module named '_struct'
        \r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

But the file exists on the target:

[[email protected]] ~]# ls -l /usr/sap/IDH/HDB00/exe/Python3/lib/python3.8/struct.py
-r--r--r--. 1 idhadm sapsys 257 Jul 11 22:49 /usr/sap/IDH/HDB00/exe/Python3/lib/python3.8/struct.py

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@woreis
Copy link
Author

woreis commented Sep 4, 2024

It works, when the become_user attribute is omitted and I pass password instead of hdbuserstore.

@sean-freeman
Copy link
Member

@woreis Please first check the System Python versus the user Python. The Ansible Module sap_hdbsql does not import struct, it is imported at a much lower level and without reading your updated comment - I would have said become_user is problematic.

[root@sandbox ~]# $(which python) -c "help('modules')" | grep struct
[root@sandbox ~]# su - sbxadm
[sbxadm@sandbox ~]# $(which python) -c "help('modules')" | grep struct

@woreis
Copy link
Author

woreis commented Sep 5, 2024

Hi Sean,
I found out when I omit "become_flags: '-i'" the above playbook works.
But nevertheless the output of the above commands is:

[[email protected] ~]# $(which python) -c "help('modules')" | grep struct
_imp datetime numbers struct
_struct getpass pycparser urllib3
[[email protected] ~]# su - idhadm
[email protected]:/usr/sap/IDH/HDB00> $(which python) -c "help('modules')" | grep struct
_struct libhdbconssrv libhdbpreprocessorclient pipes
distutils libhdbexprutils libhdbsqlscriptcodegen struct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants