Добавлена установка Grafana: роли, плейбуки и конфигурация
This commit is contained in:
68
roles/grafana.backup/tasks/wait_and_verify.yml
Normal file
68
roles/grafana.backup/tasks/wait_and_verify.yml
Normal file
@ -0,0 +1,68 @@
|
||||
---
|
||||
- name: Wait for Grafana to start (initial wait)
|
||||
wait_for:
|
||||
timeout: 30
|
||||
tags: grafana
|
||||
|
||||
- name: Check if Grafana is listening on port 3000 (with retries)
|
||||
wait_for:
|
||||
port: 3000
|
||||
host: 127.0.0.1
|
||||
delay: 10
|
||||
timeout: 300 # 5 минут максимум
|
||||
state: started
|
||||
register: grafana_port_check
|
||||
tags: grafana
|
||||
|
||||
- name: Debug port check result
|
||||
debug:
|
||||
msg: "Grafana port check: {{ grafana_port_check.state }} after {{ grafana_port_check.elapsed }} seconds"
|
||||
tags: grafana
|
||||
|
||||
- name: Wait for Grafana API to be ready
|
||||
uri:
|
||||
url: "http://localhost:3000/api/health"
|
||||
method: GET
|
||||
status_code: 200
|
||||
timeout: 30
|
||||
register: grafana_api_check
|
||||
until: grafana_api_check.status == 200
|
||||
retries: 30 # 30 попыток * 5 секунд = 150 секунд
|
||||
delay: 5
|
||||
tags: grafana
|
||||
|
||||
- name: Debug API check result
|
||||
debug:
|
||||
msg: "Grafana API responded with HTTP {{ grafana_api_check.status }} after {{ grafana_api_check.attempts }} attempts"
|
||||
tags: grafana
|
||||
|
||||
- name: Verify Grafana installation (final check)
|
||||
block:
|
||||
- name: Check Grafana service status
|
||||
systemd:
|
||||
name: grafana
|
||||
register: grafana_service_status
|
||||
tags: grafana
|
||||
|
||||
- name: Check Grafana version
|
||||
command: /usr/local/bin/grafana-server --version
|
||||
register: grafana_version_check
|
||||
changed_when: false
|
||||
tags: grafana
|
||||
|
||||
- name: Show installation summary
|
||||
debug:
|
||||
msg: |
|
||||
✅ Grafana успешно установлена!
|
||||
|
||||
Версия: {{ grafana_version_check.stdout_lines[-1] | regex_search('Version ([0-9.]+)') | default('12.3.2') }}
|
||||
Служба: {{ grafana_service_status.status.ActiveState }}
|
||||
Порт 3000: {{ 'открыт' if grafana_port_check.state == 'started' else 'закрыт' }}
|
||||
API: {{ 'доступен' if grafana_api_check.status == 200 else 'недоступен' }}
|
||||
Время установки: {{ grafana_port_check.elapsed | default(0) | round(2) }} секунд
|
||||
|
||||
Доступ по адресу: http://{{ inventory_hostname }}:3000
|
||||
Логин: admin
|
||||
Пароль: {{ grafana_admin_password | default('admin') }}
|
||||
tags: grafana
|
||||
tags: grafana
|
||||
Reference in New Issue
Block a user