0

我是ansibleand的新手RabbitMQ。我刚开始Hello World。下面是我的阅读和检索消息的剧本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://xx@roedeer.rmq.cloudamqp.com/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://xx@roedeer.rmq.cloudamqp.com/xx', queue='JobQueue') }}"

在我执行上述剧本之后。该消息正在保存在队列中,但是当我检索该消息时,我遇到了错误。

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 包。证明是它能够产生消息到队列。但是我在尝试使用它时遇到了错误。谁能帮我这个?谷歌会告诉我pika在主机上安装,但我已经这样做了。

ansible-playbook 2.8.12
  config file = None
  configured module search path = ['**', '**']
  ansible python module location = **
  executable location = /usr/local/opt/ansible@2.8/bin/ansible-playbook
  python version = 3.7.9 (default, Sep  9 2020, 00:09:13) [Clang 11.0.0 (clang-1100.0.33.17)]
4

0 回答 0