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

vmware_host_iscsi_info: ansible can't run on esxi host with error: No module named 'requests' #1679

Closed
akoscomp opened this issue Mar 16, 2023 · 6 comments

Comments

@akoscomp
Copy link

SUMMARY

I want to configure iscsi with ansible, but I got the mentioned error.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

I try with:

  • community.vmware.vmware_host_iscsi
  • community.vmware.vmware_host_iscsi_info

with same results.

ANSIBLE VERSION
ansible [core 2.14.3]
  config file = None
  configured module search path = ['/home/xxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  ansible collection location = /home/xxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

COLLECTION VERSION
Collection       Version
---------------- -------
community.vmware 3.4.0  

# /usr/local/lib/python3.9/dist-packages/ansible_collections
Collection       Version
---------------- -------
community.vmware 3.4.0  

CONFIGURATION
CONFIG_FILE() = None
OS / ENVIRONMENT

I tested with ubuntu 22.04 clean install and debian 11 clean install
vCenter: Version: 8.0.0, Build: 21216066
Hypervisor: VMware ESXi, 8.0.0, 21203435

STEPS TO REPRODUCE

I run: ansible-playbook -i inventory.yaml playbook.yaml --ask-pass -vvv

- name: Example Playbook
  hosts: all
  gather_facts: false
  tasks:
    - name: Gather iSCSI configuration information of ESXi host
      community.vmware.vmware_host_iscsi_info:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        esxi_hostname: "{{ esxi_hostname }}"
      register: iscsi_info
EXPECTED RESULTS

To got the iscsi info.

ACTUAL RESULTS
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_community.vmware.vmware_host_iscsi_info_payload_lmu737o0/ansible_community.vmware.vmware_host_iscsi_info_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py", line 30, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'
[WARNING]: No python interpreters found for host vhost21 (tried ['python3.11', 'python3.10', 'python3.9', 'python3.8', 'python3.7', 'python3.6', 'python3.5', '/usr/bin/python3', '/usr/libexec/platform-python', 'python2.7', '/usr/bin/python', 'python'])
fatal: [vhost21]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "esxi_hostname": "vhost21.xxx.ro",
            "hostname": "vsphere.xxx.ro",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "proxy_host": null,
            "proxy_port": null,
            "username": "administrator@xxx.ro",
            "validate_certs": true
        }
    },
    "msg": "Failed to import the required Python library (requests) on vhost21.xxx.ro's Python /usr/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"
}

@mariolenz
Copy link
Collaborator

Did you install the requirements?

@akoscomp
Copy link
Author

I ckecked, and yes, I installed the requirements.
I think that ansible request "requests" module on esxi side. But I can't install python modules on the server.

@mariolenz
Copy link
Collaborator

I think that ansible request "requests" module on esxi side. But I can't install python modules on the server.

You don't need to. The modules in this collection do not run on vCenter / ESXi directly. They run on the controller and do everything through the vSphere API instead of ssh'ing to vCenter / ESXi and run there.

Could you try delegate_to: localhost:

- name: Example Playbook
  hosts: all
  gather_facts: false
  tasks:
    - name: Gather iSCSI configuration information of ESXi host
      community.vmware.vmware_host_iscsi_info:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        esxi_hostname: "{{ esxi_hostname }}"
      register: iscsi_info
      delegate_to: localhost

If this doesn't help, maybe this requirement:

git+https://github.com/vmware/vsphere-automation-sdk-python.git ; python_version >= '2.7' # Python 2.6 is not supported

didn't pull in the requirements of the vSphere Automation SDK for Python automatically and you have to install them manually.

I really wish they would provide a proper PyPI package 😩

@akoscomp
Copy link
Author

delegate_to in not a valid option for this module:
https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_host_iscsi_info_module.html

I use:

  • community.vmware.vmware_host_datastore
  • community.vmware.vmware_portgroup
  • community.vmware.vmware_vswitch
  • community.vmware.vmware_vmkernel
    without any problem, I have problem only with iscsi module.

@mariolenz
Copy link
Collaborator

delegate_to in not a valid option for this module: https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_host_iscsi_info_module.html

delegate_to isn't a module option, it tells Ansible where to run the task. Look at the indentation ;-)

I use:

* community.vmware.vmware_host_datastore
* community.vmware.vmware_portgroup
* community.vmware.vmware_vswitch
* community.vmware.vmware_vmkernel

  without any problem, I have problem only with iscsi module.

With or without delegation to localhost?

@akoscomp
Copy link
Author

Thanks, and sorry for ticket. It's my two space bug.

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