community / community.general / 0.1.1 / module / rabbitmq_publish Publish a message to a RabbitMQ queue. Authors: John Imison (@Im0) preview | supported by communitycommunity.general.rabbitmq_publish (0.1.1) — module
Install with ansible-galaxy collection install community.general:==0.1.1
collections: - name: community.general version: 0.1.1
Publish a message on a RabbitMQ queue using a blocking connection.
- name: Publish a message to a queue with headers rabbitmq_publish: url: "amqp://guest:guest@192.168.0.32:5672/%2F" queue: 'test' body: "Hello world from ansible module rabbitmq_publish" content_type: "text/plain" headers: myHeader: myHeaderValue
- name: Publish a file to a queue rabbitmq_publish: url: "amqp://guest:guest@192.168.0.32:5672/%2F" queue: 'images' file: 'path/to/logo.gif'
- name: RabbitMQ auto generated queue rabbitmq_publish: url: "amqp://guest:guest@192.168.0.32:5672/%2F" body: "Hello world random queue from ansible module rabbitmq_publish" content_type: "text/plain"
- name: Publish with certs rabbitmq_publish: url: "amqps://guest:guest@192.168.0.32:5671/%2F" body: "Hello test queue from ansible module rabbitmq_publish via SSL certs" queue: 'test' content_type: "text/plain" cafile: 'ca_certificate.pem' certfile: 'client_certificate.pem' keyfile: 'client_key.pem'
src: aliases: - file description: - A file to upload to the queue. Automatic mime type detection is attempted if content_type is not defined (left as default). - A C(src) cannot be provided if a C(body) is specified. - The filename is added to the headers of the posted message to RabbitMQ. Key being the C(filename), value is the filename. url: description: - An URL connection string to connect to the RabbitMQ server. - I(url) and I(host)/I(port)/I(user)/I(pass)/I(vhost) are mutually exclusive, use either or but not both. body: description: - The body of the message. - A C(body) cannot be provided if a C(src) is specified. host: description: - The RabbitMQ server hostname or IP. port: description: - The RabbitMQ server port. proto: choices: - amqps - amqp description: - The protocol to use. queue: description: - The queue to publish a message to. If no queue is specified, RabbitMQ will return a random queue name. vhost: description: - The virtual host to target. - If default vhost is required, use C('%2F'). cafile: description: - CA file used during connection to the RabbitMQ server over SSL. - If this option is specified, also I(certfile) and I(keyfile) must be specified. durable: default: false description: - Set the queue to be durable. type: bool headers: default: {} description: - A dictionary of headers to post with the message. type: dict keyfile: description: - Client key to establish SSL connection. - If this option is specified, also I(cafile) and I(certfile) must be specified. certfile: description: - Client certificate to establish SSL connection. - If this option is specified, also I(cafile) and I(keyfile) must be specified. exchange: description: - The exchange to publish a message to. password: description: - The RabbitMQ password. username: description: - The RabbitMQ username. exclusive: default: false description: - Set the queue to be exclusive. type: bool auto_delete: default: false description: - Set the queue to auto delete. type: bool routing_key: description: - The routing key. content_type: default: text/plain description: - The content type of the body.
result: description: - Contains the status I(msg), content type I(content_type) and the queue name I(queue). returned: success sample: '''result'': { ''content_type'': ''text/plain'', ''msg'': ''Successfully published to queue test'', ''queue'': ''test'' } ' type: dict