Update file main.yml

This commit is contained in:
Administrator 2025-11-18 07:23:34 +00:00
parent 0e4f3ab50f
commit f2b83e9d00

View File

@ -100,8 +100,6 @@
mode: '0600' mode: '0600'
become: yes become: yes
# УБИРАЕМ проверку с --test (она не поддерживается)
- name: Create pve_exporter systemd service - name: Create pve_exporter systemd service
copy: copy:
content: | content: |
@ -137,34 +135,30 @@
daemon_reload: yes daemon_reload: yes
become: yes become: yes
- name: Wait for service to initialize - name: Wait for pve_exporter to initialize
pause: wait_for:
seconds: 10 host: localhost
port: 9223
timeout: 30
state: started
delay: 5
become: yes become: yes
failed_when: false
register: port_check
# Проверяем статус сервиса
- name: Check pve_exporter service status - name: Check pve_exporter service status
command: systemctl status pve_exporter command: systemctl status pve_exporter
register: service_status register: service_status
changed_when: false changed_when: false
become: yes become: yes
# Если сервис не активен - показываем логи - name: Show logs if service failed
- name: Show pve_exporter logs
command: journalctl -u pve_exporter --since "5 minutes ago" --no-pager command: journalctl -u pve_exporter --since "5 minutes ago" --no-pager
register: service_logs register: service_logs
changed_when: false changed_when: false
when: "'Active: failed' in service_status.stdout or 'Active: inactive' in service_status.stdout" when: port_check.failed or "'Active: failed' in service_status.stdout"
become: yes become: yes
# Проверяем открытые порты
- name: Check listening ports
command: ss -tlnp | grep ':9223'
register: port_status
changed_when: false
become: yes
# Финальная проверка
- name: Verify exporter is responding - name: Verify exporter is responding
uri: uri:
url: http://localhost:9223/metrics url: http://localhost:9223/metrics
@ -172,4 +166,5 @@
timeout: 10 timeout: 10
register: metrics_check register: metrics_check
failed_when: metrics_check.status != 200 failed_when: metrics_check.status != 200
when: not port_check.failed
become: yes become: yes