homelab/nomad-job/MQTT.nomad

134 lines
2.9 KiB
Plaintext
Raw Normal View History

2022-09-18 12:49:42 +00:00
job "MQTT" {
datacenters = ["homelab"]
2022-12-10 16:10:32 +00:00
priority = 90
2022-10-29 08:40:01 +00:00
type = "service"
2022-09-18 12:49:42 +00:00
meta {
forcedeploy = "0"
}
constraint {
attribute = "${attr.unique.hostname}"
2022-10-29 08:40:01 +00:00
value = "oscar"
2022-09-18 12:49:42 +00:00
}
2022-10-29 08:40:01 +00:00
group "MQTT" {
2022-09-18 12:49:42 +00:00
network {
mode = "host"
port "zigbee2mqtt" {
to = 8090
}
port "mosquittoMQTT" {
2022-10-29 08:40:01 +00:00
static = 1883
to = 1883
2022-09-18 12:49:42 +00:00
}
port "mosquittoWS" {
2022-10-29 08:40:01 +00:00
to = 9001
static = 9001
2022-09-18 12:49:42 +00:00
}
}
task "mosquitto" {
driver = "docker"
service {
name = "mosquitto"
port = "mosquittoMQTT"
tags = [
]
}
config {
2024-03-17 17:58:24 +00:00
image = "docker.service.consul:5000/library/eclipse-mosquitto"
2022-10-29 08:40:01 +00:00
ports = ["mosquittoWS", "mosquittoMQTT"]
2022-09-18 12:49:42 +00:00
volumes = [
2022-10-29 08:40:01 +00:00
"/mnt/diskstation/nomad/mosquitto:/mosquitto/data",
2022-09-18 12:49:42 +00:00
"local/mosquitto.conf:/mosquitto/config/mosquitto.conf"
]
}
env {
TZ = "Europe/Paris"
}
template {
2022-10-29 08:40:01 +00:00
data = <<EOH
2022-09-18 12:49:42 +00:00
persistence false
log_dest stdout
listener 1883
allow_anonymous true
connection_messages true
EOH
destination = "local/mosquitto.conf"
}
resources {
memory = 100
}
}
task "Zigbee2MQTT" {
driver = "docker"
service {
name = "Zigbee2MQTT"
port = "zigbee2mqtt"
tags = [
2022-10-29 08:40:01 +00:00
"homer.enable=true",
"homer.name=zigbee.mqtt",
"homer.service=Application",
"homer.logo=https://www.zigbee2mqtt.io/logo.png",
"homer.target=_blank",
"homer.url=http://${NOMAD_ADDR_zigbee2mqtt}",
2022-09-18 12:49:42 +00:00
]
}
config {
2022-10-29 08:40:01 +00:00
image = "koenkk/zigbee2mqtt"
privileged = true
ports = ["zigbee2mqtt"]
2022-09-18 12:49:42 +00:00
volumes = [
"/mnt/diskstation/nomad/zigbee2mqtt:/app/data",
"local/configuration.yaml:/app/data/configuration.yaml",
"/run/udev:/run/udev",
"/dev/ttyACM0:/dev/ttyACM0",
]
}
env {
TZ = "Europe/Paris"
}
template {
2022-10-29 08:40:01 +00:00
data = <<EOH
2022-09-18 12:49:42 +00:00
# MQTT settings
mqtt:
# MQTT base topic for Zigbee2MQTT MQTT messages
base_topic: zigbee2mqtt
# MQTT server URL
server: 'mqtt://{{env "NOMAD_ADDR_mosquittoMQTT"}}'
# MQTT server authentication, uncomment if required:
# user: my_user
# password: my_password
frontend:
port: 8090
homeassistant: true
devices:
'0x00158d00027bf710':
friendly_name: remote_chambre
'0x00158d0003fabc52':
friendly_name: weather_chambre
'0x00158d0003cd381c':
friendly_name: weather_exterieur
'0x00158d00036d5fe8':
friendly_name: motion_sensor_chambre
# Serial settings
serial:
# Location of the adapter (see first step of this guide)
adapter: deconz
port: /dev/ttyACM0
EOH
destination = "local/configuration.yaml"
}
resources {
memory = 175
}
}
}
}