lnovara / ansible-mosquitto

Ansible role to install and configure Mosquitto MQTT broker.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ansible Role: Mosquitto

Build Status Ansible Galaxy

Install and configure Mosquitto MQTT message broker.

Requirements

An Ansible 2.2 or higher installation.

Role Variables

Available variables are listed below, along with default values (see defaults/main.yml).

mosquitto_packages:
  - mosquitto
  - mosquitto-clients

Packages to install for Mosquitto.

mosquitto_python_packages:
  - paho-mqtt

Python packages to install for Mosquitto.

mosquitto_user: mosquitto
mosquitto_group: mosquitto

Mosquitto system user and group.

mosquitto_home: /var/lib/mosquitto

Mosquitto user home directory.

mosquitto_add_groups: []

Additional groups for Mosquitto user.

mosquitto_config_file: /etc/mosquitto/mosquitto.conf

Path to Mosquitto configuration file

mosquitto_config: {}

Dictionary holding Mosquitto configuration. The complete Mosquitto configuration reference can be found here.
NOTE: the provided Mosquitto configuration will be merged with the default one defined in vars/main.yml.

mosquitto_listeners: []

Example:

mosquitto_listeners:
  - listener: "1883 localhost"
    protocol: mqtt
    use_username_as_clientid: true

List holding Mosquitto listeners configuration.

mosquitto_bridges: []

Example:

mosquitto_bridges:
  - connection: bridge_name
    address: exmaple.com:1883

List holding Mosquitto bridges configuration.

mosquitto_auth_anonymous: []

mosquitto_auth_users: []

mosquitto_auth_patterns: []

Examples:

mosquitto_auth_anonymous:
  - "topic read topic_name"

mosquitto_auth_users:
  - name: user_name
    state: present
    psk: zfEGZkTMPOhxNBTe # Optional. Needs mosquitto_config.psk_file set.
    acl:
      - "topic read topic1_name"
      - "topic readwrite topic2_name"

mosquitto_auth_patterns:
  - "pattern write $SYS/broker/connection/%c/state"

Lists holding Mosquitto ACLs.

Dependencies

None.

Example Playbook

- name: Install and configure Mosquitto on all hosts.
  hosts: all
  roles:
     - lnovara.mosquitto

Testing

This role uses molecule to implement automatic testing of its functionalities.

To execute the tests

pip install tox

git clone https://github.com/lnovara/ansible-mosquitto.git

cd ansible-mosquitto

# test all the scenarios
tox

License

MIT

Author Information

Luca Novara

About

Ansible role to install and configure Mosquitto MQTT broker.

License:MIT License


Languages

Language:Python 100.0%