diff --git a/group_vars/services.yaml b/group_vars/services.yaml index e76affe..3870e5c 100644 --- a/group_vars/services.yaml +++ b/group_vars/services.yaml @@ -2,3 +2,9 @@ group_nft_input: [] # - "udp dport 4000 accept # FIXME, werkt op dit moment toch niet hoor ik van AK + +power_mqtt_targets: + - net: space + ip: 204.2.69.50 + - net: unicorndept + ip: 204.2.68.219 diff --git a/roles/services/handlers/main.yaml b/roles/services/handlers/main.yaml index fb69a73..ed04c9f 100644 --- a/roles/services/handlers/main.yaml +++ b/roles/services/handlers/main.yaml @@ -52,6 +52,7 @@ - name: Restart power-mqtt ansible.builtin.systemd: - name: power-mqtt + name: "power-mqtt@{{ item.net }}:{{ item.ip }}" state: restarted daemon_reload: true + with_items: "{{ power_mqtt_targets }}" diff --git a/roles/services/tasks/power_mqtt.yaml b/roles/services/tasks/power_mqtt.yaml index 1042844..5c18589 100644 --- a/roles/services/tasks/power_mqtt.yaml +++ b/roles/services/tasks/power_mqtt.yaml @@ -31,13 +31,8 @@ - name: Enable power-mqtt ansible.builtin.systemd: - name: "power-mqtt@{{ item.net }}/{{ item.ip }}" + name: "power-mqtt@{{ item.net }}:{{ item.ip }}" state: started enabled: true daemon_reload: true - with_items: - - net: space - ip: 0.0.0.0 - - net: unicorndept - ip: 0.0.0.0 - ignore_errors: true # FIXME + with_items: "{{ power_mqtt_targets }}" diff --git a/roles/services/templates/power-mqtt.py b/roles/services/templates/power-mqtt.py index db28aac..becccc7 100644 --- a/roles/services/templates/power-mqtt.py +++ b/roles/services/templates/power-mqtt.py @@ -5,12 +5,12 @@ import paho.mqtt.client as mqtt import paho.mqtt.subscribe as subscribe from time import sleep -import os +import sys import requests mqtt_host = '{{ mqtt_internal_host }}' -(net, sdm630_host) = os.argv[1].split('/') +(net, sdm630_host) = sys.argv[1].split(':') client = mqtt.Client()