Skip to content

community.rabbitmq.rabbitmq_vhost fails with ModuleNotFoundError: No module named 'requests' error #211

@hskiba

Description

@hskiba
SUMMARY

The community.rabbitmq.rabbitmq_vhost now returns an error if the target host doesn't have requests installed. This seems to be a direct result of #207.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.rabbitmq.rabbitmq_vhost

ANSIBLE VERSION
ansible [core 2.18.7]
  config file = /Users/hskiba/.ansible.cfg
  configured module search path = ['/Users/hskiba/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/hskiba/playpen/ansible/lib/python3.13/site-packages/ansible
  ansible collection location = /Users/hskiba/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/hskiba/playpen/ansible/bin/ansible
  python version = 3.13.5 (main, Jun 11 2025, 15:36:57) [Clang 17.0.0 (clang-1700.0.13.3)] (/Users/hskiba/playpen/ansible/bin/python3.13)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION

# /Users/hskiba/playpen/ansible/lib/python3.13/site-packages/ansible_collections
Collection         Version
------------------ -------
community.rabbitmq 1.6.0  

CONFIGURATION
ANSIBLE_PIPELINING(/Users/hskiba/.ansible.cfg) = True
CALLBACKS_ENABLED(/Users/hskiba/.ansible.cfg) = ['ansible.posix.profile_tasks']
CONFIG_FILE() = /Users/hskiba/.ansible.cfg
DEFAULT_FORKS(/Users/hskiba/.ansible.cfg) = 16
DEFAULT_LOAD_CALLBACK_PLUGINS(/Users/hskiba/.ansible.cfg) = True
DEFAULT_LOG_PATH(/Users/hskiba/.ansible.cfg) = /Users/hskiba/ansible.log
DEFAULT_STDOUT_CALLBACK(/Users/hskiba/.ansible.cfg) = yaml
EDITOR(env: EDITOR) = nvim
HOST_KEY_CHECKING(/Users/hskiba/.ansible.cfg) = False
PAGER(env: PAGER) = less

GALAXY_SERVERS:
OS / ENVIRONMENT
$ cat /etc/os-release
NAME="AlmaLinux"
VERSION="9.6 (Sage Margay)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.6"
PLATFORM_ID="platform:el9"
PRETTY_NAME="AlmaLinux 9.6 (Sage Margay)"
ANSI_COLOR="0;34"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:almalinux:almalinux:9::baseos"
HOME_URL="https://almalinux.org/"
DOCUMENTATION_URL="https://wiki.almalinux.org/"
BUG_REPORT_URL="https://bugs.almalinux.org/"

ALMALINUX_MANTISBT_PROJECT="AlmaLinux-9"
ALMALINUX_MANTISBT_PROJECT_VERSION="9.6"
REDHAT_SUPPORT_PRODUCT="AlmaLinux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.6"
SUPPORT_END=2032-06-01
STEPS TO REPRODUCE

Execute the following playbook on a target host with a RabbitMQ server. This assumes that the rabbitmqctl command is at /opt/rabbitmq/sbin (see the PATH environment variable that you may need to change).

- name: RabbitMQ
  hosts: rabbitmq

  environment:
    PATH: "/opt/rabbitmq/sbin:{{ ansible_env.PATH }}"

  tasks:
    - name: "Ensure the RabbitMQ vhost exists at {{ rabbitmq_vhost | default('/') }}"
      community.rabbitmq.rabbitmq_vhost:
        name: "{{ rabbitmq_vhost | default('/') }}"
        node: "{{ rabbitmq_node_name | default('rabbit') }}"
        state: present
EXPECTED RESULTS

Command uses rabbmitmqctl and is successful.

ACTUAL RESULTS
TASK [Ensure the RabbitMQ vhost exists at /] ************************************************************
Wednesday 16 July 2025  21:46:37 -0400 (0:00:02.346)       0:03:07.339 ********
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'requests'
fatal: [alma@orb]: FAILED! => changed=false
  msg: Failed to import the required Python library (requests) on alma's Python /opt/vor/python/bin/python3. 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions