Puppet Class: mqtt

Defined in:
manifests/init.pp

Summary

Configure MQTT instance

Overview

Parameters:

  • datadir (String)

    handles storage of MQTT data

  • ip (String) (defaults to: '172.17.0.4')

    sets the IP of the mqtt container



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'manifests/init.pp', line 5

class mqtt (
  String $datadir,
  String $ip = '172.17.0.4',
) {
  firewall { '100 dnat for mqtt':
    chain  => 'DOCKER_EXPOSE',
    jump   => 'DNAT',
    proto  => 'tcp',
    dport  => 1883,
    todest => "${ip}:1883",
    table  => 'nat',
  }

  file { [
      $datadir,
      "${datadir}/mqtt_config",
      "${datadir}/mqtt_data",
    ]:
      ensure => directory,
  }

  docker::container { 'mqtt':
    image   => 'eclipse-mosquitto:2',
    args    => [
      "--ip ${ip}",
      "-v ${datadir}/mqtt_data:/mosquitto/data",
      "-v ${datadir}/mqtt_config:/mosquitto/config",
    ],
    cmd     => 'mosquitto -c /mosquitto-no-auth.conf',
    require => [File["${datadir}/mqtt_config"], File["${datadir}/mqtt_data"]],
  }
}