47 lines
1.3 KiB
YAML
47 lines
1.3 KiB
YAML
|
|
---
|
||
|
|
- name: Install and Configure Prometheus
|
||
|
|
hosts: 192.168.0.105 # Prometheus container
|
||
|
|
become: yes
|
||
|
|
gather_facts: yes
|
||
|
|
|
||
|
|
pre_tasks:
|
||
|
|
- name: Update apt cache
|
||
|
|
apt:
|
||
|
|
update_cache: yes
|
||
|
|
cache_valid_time: 3600
|
||
|
|
|
||
|
|
- name: Install required packages
|
||
|
|
apt:
|
||
|
|
name:
|
||
|
|
- curl
|
||
|
|
- wget
|
||
|
|
- ca-certificates
|
||
|
|
state: present
|
||
|
|
|
||
|
|
roles:
|
||
|
|
- role: ../../roles/prometheus
|
||
|
|
|
||
|
|
post_tasks:
|
||
|
|
- name: Verify Prometheus is accessible from target host
|
||
|
|
uri:
|
||
|
|
url: "http://localhost:9090/metrics"
|
||
|
|
status_code: 200
|
||
|
|
|
||
|
|
- name: Check VictoriaMetrics connectivity from Prometheus
|
||
|
|
uri:
|
||
|
|
url: "http://192.168.0.104:8428/health"
|
||
|
|
status_code: 200
|
||
|
|
|
||
|
|
- name: Display access information
|
||
|
|
debug:
|
||
|
|
msg:
|
||
|
|
- "========================================="
|
||
|
|
- "Prometheus installed successfully!"
|
||
|
|
- "========================================="
|
||
|
|
- "Web UI: http://{{ ansible_host }}:9090"
|
||
|
|
- "Metrics: http://{{ ansible_host }}:9090/metrics"
|
||
|
|
- "Targets: http://{{ ansible_host }}:9090/targets"
|
||
|
|
- "Configuration: /etc/prometheus/prometheus.yml"
|
||
|
|
- "Data directory: /var/lib/prometheus"
|
||
|
|
- "========================================="
|