mqtt - Publish a message on an MQTT topic for the IoT

Author:Jan-Piet Mens

Synopsis

New in version 1.2.

Publish a message on an MQTT topic.

Options

parameter required default choices comments
client_id no hostname + pid
    MQTT client identifier
    password no
      Password for username to authenticate against the broker.
      payload yes
        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 no 1883
          MQTT broker port number
          qos no
          • 0
          • 1
          • 2
          QoS (Quality of Service)
          retain no
            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 no localhost
              MQTT broker address/name
              topic yes
                MQTT topic name
                username no
                  Username to authenticate against the broker.

                  Note

                  Requires mosquitto

                  Examples


                  - local_action: mqtt
                                topic=service/ansible/{{ ansible_hostname }}
                                payload="Hello at {{ ansible_date_time.iso8601 }}"
                                qos=0
                                retain=false
                                client_id=ans001
                  

                  Note

                  This module requires a connection to an MQTT broker such as Mosquitto http://mosquitto.org and the Paho mqtt Python client (https://pypi.python.org/pypi/paho-mqtt).

                  Table Of Contents

                  Previous topic

                  mail - Send an email

                  Next topic

                  nexmo - Send a SMS via nexmo