Commvault / ansible

Ansible Library for Commvault
21 stars 11 forks source link

When running from a custom ansible-builder created EE with cvpysdk installed, module fails #15

Closed jreynolds-kcs closed 1 year ago

jreynolds-kcs commented 1 year ago

I've created a bare-bones ansible execution environment image that contains the cvpysdk module.

The EE gets pulled from docker hub into AWX, which happens fine.

I'm able to run all kinds of other code from inside the EE, and a "pip list" shows the following: "Package Version", "---------------- ------------", "ansible-core 2.12.5.post0", "ansible-runner 2.1.4.dev2", "asn1crypto 1.2.0", "Babel 2.7.0", "bcrypt 3.2.0", "cffi 1.13.2", "chardet 3.0.4", "cryptography 2.8", "cvpysdk 11.28", "decorator 5.1.1", "docutils 0.18.1", "dumb-init 1.2.5.post1", "future 0.18.2", "gssapi 1.7.3", "idna 2.8", "Jinja2 2.11.3", "krb5 0.3.0", "lockfile 0.12.2", "lxml 4.4.1", "MarkupSafe 1.1.1", "ncclient 0.6.13", "ntlm-auth 1.5.0", "packaging 21.3", "paramiko 2.10.4", "pexpect 4.8.0", "pip 22.3.1", "ply 3.11", "ptyprocess 0.7.0", "pycparser 2.19", "pykerberos 1.2.4", "PyNaCl 1.5.0", "pyOpenSSL 19.1.0", "pyparsing 3.0.8", "pypsrp 0.8.1", "PySocks 1.7.1", "pyspnego 0.5.2", "python-daemon 2.3.0", "pytz 2019.3", "pywinrm 0.4.3", "PyYAML 5.4.1", "requests 2.22.0", "requests-credssp 2.0.0", "requests-ntlm 1.1.0", "resolvelib 0.5.4", "setuptools 65.6.3", "six 1.12.0", "toml 0.10.2", "urllib3 1.25.7", "xmltodict 0.12.0"

When trying to run some ansible code that references the commvault module however, we get the following:

"module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1670443558.1911001-51-58057799035155/AnsiballZ_commvault.py\", line 107, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1670443558.1911001-51-58057799035155/AnsiballZ_commvault.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1670443558.1911001-51-58057799035155/AnsiballZ_commvault.py\", line 48, in invoke_module\n run_name='__main__', alter_sys=True)\n File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_commvault_payload_7vc4w59x/ansible_commvault_payload.zip/ansible/modules/commvault.py\", line 223, in <module>\nModuleNotFoundError: No module named 'cvpysdk'\n",

I will add, that ansible_python_version shows: 3.8.13

RECAP: cvpysdk is installed, ansible_python_version shows: 3.8.13, but it looks like the commvault module is trying to find things related to python3.6.

Any ideas?

jreynolds-kcs commented 1 year ago

It seems that passing: interpreter_python = /usr/bin/python3.8 in ansible.cfg has fixed the issue

although... I'm not sure why :)

spakhare commented 1 year ago

Hi @jreynolds-kcs,

You can refer to doc link here on how ansible determines which python interpreter is picked for execution.

Thanks, Sachin