ansible/roles/monitoring/tasks/mqtt_exporter.yaml

47 lines
1,009 B
YAML

---
- name: Clone source
ansible.builtin.git:
repo: https://github.com/polyfloyd/mqtt-exporter.git
version: main
dest: /opt/mqtt_exporter
accept_hostkey: yes
notify: restart mqtt_exporter
- name: Install apt dependencies
ansible.builtin.apt:
name:
- jq
- python3-paho-mqtt
- python3-prometheus-client
- python3-yaml
state: present
- name: Install service
ansible.builtin.template:
src: mqtt_exporter.service
dest: /etc/systemd/system/mqtt_exporter.service
owner: root
group: root
mode: 0644
notify:
- Daemon reload
- restart mqtt_exporter
- name: Install config file
ansible.builtin.template:
src: mqtt_exporter_config.yaml
dest: /etc/mqtt_exporter.yaml
owner: root
group: root
mode: 0644
notify:
- Daemon reload
- restart mqtt_exporter
- ansible.builtin.meta: flush_handlers
- name: Start service
ansible.builtin.systemd:
name: mqtt_exporter
state: started
enabled: true