community / community.general / 0.2.1 / module / mqtt Publish a message on an MQTT topic for the IoT Authors: Jan-Piet Mens (@jpmens)community.general.mqtt (0.2.1) — module
Install with ansible-galaxy collection install community.general:==0.2.1
collections: - name: community.general version: 0.2.1
Publish a message on an MQTT topic.
- name: Publish a message on an MQTT topic mqtt: topic: 'service/ansible/{{ ansible_hostname }}' payload: 'Hello at {{ ansible_date_time.iso8601 }}' qos: 0 retain: False client_id: ans001 delegate_to: localhost
qos: choices: - '0' - '1' - '2' default: 0 description: - QoS (Quality of Service) port: default: 1883 description: - MQTT broker port number topic: description: - MQTT topic name required: true retain: default: 'no' description: - Setting this flag causes the broker to retain (i.e. keep) the message so that applications that subsequently subscribe to the topic can received the last retained message immediately. type: bool server: default: localhost description: - MQTT broker address/name ca_cert: aliases: - ca_certs description: - The path to the Certificate Authority certificate files that are to be treated as trusted by this client. If this is the only option given then the client will operate in a similar manner to a web browser. That is to say it will require the broker to have a certificate signed by the Certificate Authorities in ca_certs and will communicate using TLS v1, but will not attempt any form of authentication. This provides basic network encryption but may not be sufficient depending on how the broker is configured. payload: description: - Payload. The special string C("None") may be used to send a NULL (i.e. empty) payload which is useful to simply notify with the I(topic) or to clear previously retained messages. required: true password: description: - Password for C(username) to authenticate against the broker. username: description: - Username to authenticate against the broker. client_id: default: hostname + pid description: - MQTT client identifier client_key: aliases: - keyfile description: - The path pointing to the PEM encoded client private key. If this is not None it will be used as client information for TLS based authentication. Support for this feature is broker dependent. client_cert: aliases: - certfile description: - The path pointing to the PEM encoded client certificate. If this is not None it will be used as client information for TLS based authentication. Support for this feature is broker dependent. tls_version: choices: - tlsv1.1 - tlsv1.2 description: - Specifies the version of the SSL/TLS protocol to be used. - By default (if the python version supports it) the highest TLS version is detected. If unavailable, TLS v1 is used. type: str