2021-04-03 07:36:47 +00:00
|
|
|
from bundlewrap.metadata import atomic
|
|
|
|
|
|
|
|
|
|
|
|
defaults = {
|
|
|
|
'apt': {
|
|
|
|
'packages': {
|
|
|
|
'mosquitto': {},
|
|
|
|
'mosquitto-clients': {},
|
|
|
|
},
|
|
|
|
},
|
2021-04-03 07:43:24 +00:00
|
|
|
'icinga2_api': {
|
|
|
|
'mosquitto': {
|
|
|
|
'services': {
|
|
|
|
'MOSQUITTO PROCESS': {
|
|
|
|
'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C mosquitto -c 1:',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-04-03 07:36:47 +00:00
|
|
|
'mosquitto': {
|
|
|
|
'listeners': {
|
|
|
|
'1883': {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@metadata_reactor.provides(
|
2021-06-03 11:59:15 +00:00
|
|
|
'firewall/port_rules',
|
2021-04-03 07:36:47 +00:00
|
|
|
)
|
2021-06-03 11:59:15 +00:00
|
|
|
def firewall(metadata):
|
2021-04-03 07:36:47 +00:00
|
|
|
sources = metadata.get('mosquitto/restrict-to', {'*'})
|
|
|
|
result = {}
|
|
|
|
|
|
|
|
for listener in metadata.get('mosquitto/listeners').keys():
|
|
|
|
result[listener] = atomic(sources)
|
|
|
|
|
|
|
|
return {
|
2021-06-03 11:59:15 +00:00
|
|
|
'firewall': {
|
2021-04-03 07:36:47 +00:00
|
|
|
'port_rules': result,
|
|
|
|
},
|
|
|
|
}
|
2021-05-15 06:52:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
@metadata_reactor.provides(
|
2021-05-15 06:58:15 +00:00
|
|
|
'telegraf/input_plugins/execd/tasmota',
|
2021-05-15 06:52:37 +00:00
|
|
|
)
|
|
|
|
def telegraf(metadata):
|
|
|
|
topic = metadata.get('mosquitto/tasmota-telegraf-topic', None)
|
|
|
|
|
|
|
|
if not topic:
|
|
|
|
return {}
|
|
|
|
|
|
|
|
return {
|
|
|
|
'telegraf': {
|
|
|
|
'input_plugins': {
|
|
|
|
'execd': {
|
|
|
|
'tasmota': {
|
|
|
|
'command': [
|
|
|
|
'/usr/local/bin/tasmota-telegraf-plugin',
|
|
|
|
'127.0.0.1',
|
|
|
|
topic
|
|
|
|
],
|
|
|
|
'signal': 'none',
|
|
|
|
'restart_delay': '1s',
|
|
|
|
'data_format': 'influx',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|