I'm a newbie to ansible
and RabbitMQ
. I'm just starting off with Hello World
. Below is my playbook for reading and retrieving messages to RabbitMQ
.
---
- hosts: localhost
name: "something"
vars:
ansible_python_interpreter: /usr/local/bin/python3.7
tasks:
- name: Publish a message to a queue with headers
vars:
ansible_python_interpreter: /usr/local/bin/python3.7
rabbitmq_publish:
url: "amqps://[email protected]/xx"
queue: 'RunningQueue'
body: "Hello world from ansible module rabbitmq_publish"
durable: yes
content_type: "text/plain"
- name: Get 2 messages off a queue and set a fact for re-use
debug:
messages: "{{ lookup('rabbitmq', url='amqps://[email protected]/xx', queue='JobQueue') }}"
After I execute the above playbook. The message is saving in the queue, but when i retrieve the message i'm getting below error.
fatal: [localhost]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'rabbitmq'. Error was a <class 'ansible.errors.AnsibleError'>, original message: pika python package is required for rabbitmq lookup."}
pika
python package is already installed on the localhost. Proof is that it is able to produce message to queue. But I'm facing error when trying to consume it. Can anyone help me with this? Google will tell me install pika
on host, but i have already done that.
ansible-playbook 2.8.12
config file = None
configured module search path = ['**', '**']
ansible python module location = **
executable location = /usr/local/opt/[email protected]/bin/ansible-playbook
python version = 3.7.9 (default, Sep 9 2020, 00:09:13) [Clang 11.0.0 (clang-1100.0.33.17)]