From 52b7b73a2528dc67d0823e78a8a7615f2e8e8e2c Mon Sep 17 00:00:00 2001 From: Ludovic Cartier Date: Wed, 24 Apr 2024 17:37:33 +0200 Subject: [PATCH] proxmox - install into venv --- defaults/main.yml | 2 ++ tasks/exporter/services/proxmox.yml | 13 ++++++++++++- .../systemd/prometheus-proxmox-exporter.service.j2 | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 7dfdfbc..5fcedda 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -70,6 +70,8 @@ prometheus_postgres_exporter_user: "postgres" prometheus_postgres_exporter_password: "changeme_" prometheus_postgres_exporter_port: 5432 +prometheus_proxmox_venv_path: "/opt/venv/prometheus-pve-exporter" + prometheus_redis_exporter_addr: "redis://localhost:6379" prometheus_redis_exporter_user: "" prometheus_redis_exporter_password: "" diff --git a/tasks/exporter/services/proxmox.yml b/tasks/exporter/services/proxmox.yml index ab6d82d..76da020 100644 --- a/tasks/exporter/services/proxmox.yml +++ b/tasks/exporter/services/proxmox.yml @@ -7,11 +7,22 @@ - prometheus_proxmox_exporter_node is defined tags: ['prometheus_proxmox'] +- name: 'proxmox exporter | create dedicated venv path' + file: + path: "{{ prometheus_proxmox_venv_path | default('/opt/venv/prometheus-pve-exporter') }}" + state: directory + tags: ['prometheus_proxmox'] + +- name: 'proxmox exporter | create dedicated venv' + command: + cmd: python3 -m venv "{{ prometheus_proxmox_venv_path | default('/opt/venv/prometheus-pve-exporter') }}" + tags: ['prometheus_proxmox'] + - name: 'proxmox exporter | install package through pip3' pip: name: - prometheus-pve-exporter - executable: pip3 + venv: "{{ prometheus_proxmox_venv_path | default('/opt/venv/prometheus-pve-exporter') }}" tags: ['prometheus_proxmox'] - name: 'proxmox exporter | configuration' diff --git a/templates/systemd/prometheus-proxmox-exporter.service.j2 b/templates/systemd/prometheus-proxmox-exporter.service.j2 index d299fcd..b457c82 100644 --- a/templates/systemd/prometheus-proxmox-exporter.service.j2 +++ b/templates/systemd/prometheus-proxmox-exporter.service.j2 @@ -5,6 +5,6 @@ Wants=network.target [Service] Restart=on-failure -ExecStart=/usr/local/bin/pve_exporter --config.file /etc/default/prometheus-proxmox-exporter --web.listen-address {{ prometheus_proxmox_exporter_node }}:{{ prometheus_proxmox_exporter_port | default('9221') }} +ExecStart="{{ prometheus_proxmox_venv_path | default('/opt/venv/prometheus-pve-exporter') }}"/bin/pve_exporter --config.file /etc/default/prometheus-proxmox-exporter --web.listen-address {{ prometheus_proxmox_exporter_node }}:{{ prometheus_proxmox_exporter_port | default('9221') }} [Install] WantedBy=multi-user.target