vmware_guest playbooks not working in Ansible core after RHEL upgrade

Posted on

Good Morning,

I have a RHEL 8.9 Ootpa server I use as my Ansible core server. I recently upgraded it via leapp from RHEL 7.9. I now have issues with playbooks involving VMware. These are the only playbooks I receive errors on.

When I run the playbook below (I removed all but one server for brevity and censored our personal information), I get the following error message:

---
- hosts: localhost
  vars_files:
    - vars.yml
  tasks:
    - name: log into vsphere and create snapshot
      vmware_guest_snapshot:
        hostname: xxx.xx.xxx.xxx
        username: admin
        password: "{{ adminpass }}"
        validate_certs: False
        datacenter: "CTR"
        folder: /"Discovered virtual machine"
        name: "{{ item.name }}"
        uuid: "{{ item.uuid }}"
        snapshot_name: pre_update_snap_{{ansible_date_time.date}}
        description: snapshot prior to updating the server
      loop:
        - {name: "TESTSERVER", uuid: "XXXXXX-XXXX-XXXX-XXXX-XXXXXXXX"}

- hosts: localhost
  tasks:
    - name: wait for 90 seconds
      wait_for: timeout=90
      delegate_to: localhost

- hosts: localhost
  vars_files:
    - vars.yml
  tasks:
    - name: start vm after snapshot is taken
      vmware_guest:
        hostname: xxx.xx.xxx.xxx
        username: admin
        password: "{{ adminpass }}"
        validate_certs: False
        datacenter: "CTR"
        folder: /"Discovered virtual machine"
        name: "{{ item.name }}"
        uuid: "{{ item.uuid }}"
        state: poweredon
      delegate_to: localhost
      loop:
        - {name: "TESTSERVER", uuid: "XXXXXX-XXXX-XXXX-XXXX-XXXXXXXX"}
...

This is the error message I receive:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'requests'
failed: [localhost] (item={'name': 'TESTSERVER', 'uuid': 'XXXXXX-XXXX-XXXX-XXXX-XXXXXXXX'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "TESTSERVER", "uuid": "XXXXXX-XXXX-XXXX-XXXX-XXXXXXXX"}, "msg": "Failed to import the required Python library (requests) on server.ourdomain.com's Python /usr/bin/python3.11. 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"}

I have installed 'requests' using both pip and dnf. I have also changed the interpreter path to a number of different things but nothing seems to work. Any and all suggestions are appreciated.

Thank you!

Responses