mqtt – Publish a message on an MQTT topic for the IoT¶
Parameters¶
Parameter | Choices/Defaults | Comments |
---|---|---|
ca_certs
-
added in 2.3 |
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.
|
|
certfile
-
added in 2.3 |
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.
|
|
client_id
-
|
Default: "hostname + pid"
|
MQTT client identifier
|
keyfile
-
added in 2.3 |
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.
|
|
password
-
|
Password for
username to authenticate against the broker. |
|
payload
-
/ required
|
Payload. The special string
"None" may be used to send a NULL (i.e. empty) payload which is useful to simply notify with the topic or to clear previously retained messages. |
|
port
-
|
Default: 1883
|
MQTT broker port number
|
qos
-
|
0
|
QoS (Quality of Service)
|
retain
boolean
|
|
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.
|
server
-
|
Default: "localhost"
|
MQTT broker address/name
|
topic
-
/ required
|
MQTT topic name
|
|
username
-
|
Username to authenticate against the broker.
|
Notes¶
Note
- This module requires a connection to an MQTT broker such as Mosquitto http://mosquitto.org and the Paho
mqtt
Python client (https://pypi.org/project/paho-mqtt/).
Examples¶
- mqtt:
topic: 'service/ansible/{{ ansible_hostname }}'
payload: 'Hello at {{ ansible_date_time.iso8601 }}'
qos: 0
retain: False
client_id: ans001
delegate_to: localhost
Status¶
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors¶
- Jan-Piet Mens (@jpmens)
Hint
If you notice any issues in this documentation you can edit this document to improve it.