configure prometheus for ubiquiti and proxmox cluster
This commit is contained in:
@@ -95,6 +95,8 @@
|
||||
- "{{ monitoring_base_dir }}/prometheus"
|
||||
- "{{ monitoring_base_dir }}/grafana"
|
||||
- "{{ monitoring_base_dir }}/alertmanager"
|
||||
- "{{ monitoring_base_dir }}/pve-exporter"
|
||||
- "{{ monitoring_base_dir }}/snmp-exporter"
|
||||
|
||||
# ── Config files ───────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -125,6 +127,56 @@
|
||||
mode: "0644"
|
||||
notify: restart monitoring
|
||||
|
||||
- name: Deploy PVE exporter credentials file
|
||||
ansible.builtin.template:
|
||||
src: pve.yml.j2
|
||||
dest: "{{ monitoring_base_dir }}/pve-exporter/pve.yml"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: docker
|
||||
mode: "0644"
|
||||
no_log: true
|
||||
notify: restart monitoring
|
||||
|
||||
# ── SNMP exporter config ───────────────────────────────────────────────────────
|
||||
# Extract the default snmp.yml from the image (contains full if_mib metrics
|
||||
# mapping) then inject the mk-labs community auth into the auths section.
|
||||
|
||||
- name: Extract default snmp.yml from snmp-exporter image
|
||||
ansible.builtin.shell:
|
||||
cmd: >
|
||||
docker run --rm --entrypoint cat prom/snmp-exporter:latest
|
||||
/etc/snmp_exporter/snmp.yml
|
||||
> {{ monitoring_base_dir }}/snmp-exporter/snmp.yml
|
||||
changed_when: true
|
||||
|
||||
- name: Inject mk_labs_v2c auth into snmp.yml
|
||||
ansible.builtin.shell:
|
||||
cmd: |
|
||||
python3 - << 'EOF'
|
||||
path = '{{ monitoring_base_dir }}/snmp-exporter/snmp.yml'
|
||||
with open(path, 'r') as f:
|
||||
content = f.read()
|
||||
auth = (
|
||||
' mk_labs_v2c:\n'
|
||||
' community: {{ vault_snmp_community }}\n'
|
||||
' security_level: noAuthNoPriv\n'
|
||||
' auth_protocol: MD5\n'
|
||||
' priv_protocol: DES\n'
|
||||
' version: 2\n'
|
||||
)
|
||||
if 'mk_labs_v2c' not in content:
|
||||
content = content.replace('\nmodules:\n', '\n' + auth + 'modules:\n', 1)
|
||||
with open(path, 'w') as f:
|
||||
f.write(content)
|
||||
print('injected')
|
||||
else:
|
||||
print('already present')
|
||||
EOF
|
||||
register: snmp_inject
|
||||
changed_when: "'injected' in snmp_inject.stdout"
|
||||
no_log: true
|
||||
notify: restart monitoring
|
||||
|
||||
# ── Compose stack ──────────────────────────────────────────────────────────────
|
||||
|
||||
- name: Deploy monitoring compose file from boilerplate
|
||||
@@ -149,4 +201,3 @@
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ monitoring_base_dir }}"
|
||||
state: present
|
||||
|
||||
|
||||
Reference in New Issue
Block a user