unifi: Deploy unifi_exporter

`unifi_exporter` provides Prometheus metrics for UniFi controller.
This commit is contained in:
2024-01-09 17:37:40 -06:00
parent 6f5b400f4a
commit b4fcbb8095
6 changed files with 120 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
- name: ensure unifi_exporter is configured
copy:
dest: /etc/unifi_exporter.yml
content: >-
{{ unifi_exporter_config | to_nice_yaml(indent=2) }}
mode: u=rw,g=r,o=
owner: root
group: 200
notify:
- restart unifi_exporter
tags:
- config
- name: ensure unifi_exporter container is configured
template:
src: unifi_exporter.container.j2
dest: /etc/containers/systemd/unifi_exporter.container
mode: u=rw,go=r
owner: root
group: root
notify:
- reload systemd
- restart unifi_exporter
tags:
- container
- name: ensure unifi_exporter container image is present
podman_image:
name: '{{ unifi_exporter_container_image }}:{{ unifi_exporter_version }}'
state: present
tags:
- container
- name: flush handlers
meta: flush_handlers
- name: ensure unifi_exporter service is enabled
systemd:
name: unifi_exporter
enabled: true
tags:
- service
- name: ensure unifi_exporter service is running
systemd:
name: unifi_exporter
state: started
tags:
- service
- name: ensure firewall is configured for unifi_exporter
firewalld:
port: 9130/tcp
state: enabled
permanent: true
immediate: true
when: host_uses_firewalld|d(true)
tags:
- firewalld