--- - name: Install dependencies ansible.builtin.apt: name: [python3-paho-mqtt, python3-requests] - name: Install power-mqtt ansible.builtin.template: src: power-mqtt.py dest: /var/lib/power-mqtt.py owner: root group: root mode: 0755 notify: Restart power-mqtt - name: Remove old service ansible.builtin.file: path: /etc/systemd/system/power-mqtt.service state: absent - name: Install power-mqtt service ansible.builtin.template: src: generic.service dest: /etc/systemd/system/power-mqtt@.service owner: root group: root mode: 0644 vars: description: "SMD630 to MQTT Probe" exec: "/var/lib/power-mqtt.py %i" notify: Restart power-mqtt - name: Enable power-mqtt ansible.builtin.systemd: 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