HewlettPackard / oneview-ansible

This project is no longer being developed and has limited support. Please use the newer Ansible Collection project: https://github.com/HewlettPackard/oneview-ansible-collection
Apache License 2.0
104 stars 65 forks source link

ImportError: cannot import name OneViewModule #632

Closed Sethueha closed 3 years ago

Sethueha commented 3 years ago

Scenario/Intent

I'm trying to set an virtual environment to run HPE OneView Ansible playbook from Ansible tower, but getting a ImportError.

Environment Details

Steps to Reproduce

Create a virtual environment in server and do all the perquisites as mentioned in https://github.com/HewlettPackard/oneview-ansible .

Expected Result

The playbook should run without any issue

Actual Result

<10.87.1.203> ESTABLISH LOCAL CONNECTION FOR USER: awx <10.87.1.203> EXEC /bin/sh -c 'echo ~awx && sleep 0' <10.87.1.203> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /var/lib/awx/.ansible/tmp"&& mkdir /var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338 && echo ansible-tmp-1611293846.1076467-10-103317265373338="echo /var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338" ) && sleep 0' <10.87.1.203> Attempting python interpreter discovery <10.87.1.203> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0' <10.87.1.203> EXEC /bin/sh -c '/usr/bin/python && sleep 0' Using module file /tmp/awx_355_ok6e4qa6/project/Baremetal/library/oneview_server_profile_facts.py <10.87.1.203> PUT /var/lib/awx/.ansible/tmp/ansible-local-3r82eyasf/tmp0n140ewy TO /var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338/AnsiballZ_oneview_server_profile_facts.py <10.87.1.203> EXEC /bin/sh -c 'chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338/ /var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338/AnsiballZ_oneview_server_profile_facts.py && sleep 0' <10.87.1.203> EXEC /bin/sh -c 'library=/var/lib/awx/venv/baremetal/oneview-ansible/library/ module_utils=/var/lib/awx/venv/baremetal/oneview-ansible/library/module_utils/ python_path=/var/lib/awx/venv/baremetal/oneview-ansible/library /usr/bin/python /var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338/AnsiballZ_oneview_server_profile_facts.py && sleep 0' <10.87.1.203> EXEC /bin/sh -c 'rm -f -r /var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338/ > /dev/null 2>&1 && sleep 0' The full traceback is: Traceback (most recent call last): File "/var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338/AnsiballZ_oneview_server_profile_facts.py", line 102, in _ansiballz_main() File "/var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338/AnsiballZ_oneview_server_profile_facts.py", line 94, in _ansiballz_main invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS) File "/var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338/AnsiballZ_oneview_server_profile_facts.py", line 40, in invoke_module runpy.run_module(mod_name='ansible.modules.oneview_server_profile_facts', init_globals=None, run_name='main', alter_sys=True) File "/usr/lib64/python2.7/runpy.py", line 176, in run_module fname, loader, pkg_name) File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code mod_name, mod_fname, mod_loader, pkg_name) File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/tmp/ansible_oneview_server_profile_facts_payload_aQVcyz/ansible_oneview_server_profile_facts_payload.zip/ansible/modules/oneview_server_profile_facts.py", line 244, in ImportError: cannot import name OneViewModule fatal: [10.87.1.203]: FAILED! => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338/AnsiballZ_oneview_server_profile_facts.py\", line 102, in \n _ansiballz_main()\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338/AnsiballZ_oneview_server_profile_facts.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1611293846.1076467-10-103317265373338/AnsiballZ_oneview_server_profile_facts.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible.modules.oneview_server_profile_facts', init_globals=None, run_name='main', alter_sys=True)\n File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\n fname, loader, pkg_name)\n File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\n exec code in run_globals\n File \"/tmp/ansible_oneview_server_profile_facts_payload_aQVcyz/ansible_oneview_server_profile_facts_payload.zip/ansible/modules/oneview_server_profile_facts.py\", line 244, in \nImportError: cannot import name OneViewModule\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1 }

PLAY RECAP ***** 10.87.1.203 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

nabhajit-ray commented 3 years ago

Hi ,

Can you share the pip list output and whether your environment variables contains the ANSIBLE_LIBRARY and ANSIBLE_MODULE_UTILS?

nabhajit-ray commented 3 years ago

Hi Setheha, We did not hear from you regarding the env variables. Is it is resolved now?

Sethueha commented 3 years ago

Yes, the issue is resolved after adding the environment variables in Ansible tower job settings.

nabhajit-ray commented 3 years ago

Closing as per last comment