Documentation

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

Synopsis

Publish a message on an MQTT topic.

Requirements (on host that executes module)

  • mosquitto

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.

                  Examples

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

                  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.python.org/pypi/paho-mqtt).

                  This is an Extras Module

                  For more information on what this means please read Extras Modules

                  For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.