community / community.rabbitmq / 1.3.0 / lookup / rabbitmq Retrieve messages from an AMQP/AMQPS RabbitMQ queue. Authors: John Imison (@Im0)community.rabbitmq.rabbitmq (1.3.0) — lookup
Install with ansible-galaxy collection install community.rabbitmq:==1.3.0
collections: - name: community.rabbitmq version: 1.3.0
This lookup uses a basic get to retrieve all, or a limited number C(count), messages from a RabbitMQ queue.
- name: Get all messages off a queue debug: msg: "{{ lookup('community.rabbitmq.rabbitmq', url='amqp://guest:guest@192.168.0.10:5672/%2F', queue='hello') }}"
# 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('community.rabbitmq.rabbiotmq', url='amqp://guest:guest@192.168.0.10:5672/%2F', queue='hello', count=2) }}"
- name: Dump out contents of the messages debug: var: messages
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
_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