community.general.rabbitmq (0.1.1) — lookup

Retrieve messages from an AMQP/AMQPS RabbitMQ queue.

Authors: John Imison <@Im0>

Install collection

Install with ansible-galaxy collection install community.general:==0.1.1


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.1.1

Description

This lookup uses a basic get to retrieve all, or a limited number C(count), messages from a RabbitMQ queue.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get all messages off a queue
  debug:
    msg: "{{ lookup('rabbitmq', url='amqp://guest:guest@192.168.0.10:5672/%2F', queue='hello') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.

# If you are intending on using the returned messages as a variable in more than
# one task (eg. debug, template), it is recommended to set_fact.

- name: Get 2 messages off a queue and set a fact for re-use
  set_fact:
    messages: "{{ lookup('rabbitmq', url='amqp://guest:guest@192.168.0.10:5672/%2F', queue='hello', count=2) }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Dump out contents of the messages
  debug:
    var: messages

Inputs

    
url:
    description:
    - An URI connection string to connect to the AMQP/AMQPS RabbitMQ server.
    - For more information refer to the URI spec U(https://www.rabbitmq.com/uri-spec.html).
    required: true

count:
    description:
    - How many messages to collect from the queue.
    - If not set, defaults to retrieving all the messages from the queue.

queue:
    description:
    - The queue to get messages from.
    required: true

Outputs

_list:
  contains:
    content_type:
      description: The content_type on the message in the queue.
      type: str
    delivery_mode:
      description: The delivery_mode on the message in the queue.
      type: str
    delivery_tag:
      description: The delivery_tag on the message in the queue.
      type: str
    exchange:
      description: The exchange the message came from.
      type: str
    headers:
      description: The headers for the message returned from the queue.
      type: dict
    json:
      description: If application/json is specified in content_type, json will be
        loaded into variables.
      type: dict
    message_count:
      description: The message_count for the message on the queue.
      type: str
    msg:
      description: The content of the message.
      type: str
    redelivered:
      description: The redelivered flag.  True if the message has been delivered before.
      type: bool
    routing_key:
      description: The routing_key on the message in the queue.
      type: str
  description:
  - A list of dictionaries with keys and value from the queue.
  type: list