Files
gitlab-mirror/roles/prometheus/molecule/default/verify.yml
2025-12-12 11:44:47 +03:00

56 lines
1.8 KiB
YAML

---
- name: Verify
hosts: all
gather_facts: false
any_errors_fatal: true
tasks:
- name: "Include default vars"
ansible.builtin.include_vars:
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/"
extensions: [ 'yml' ]
- name: "Check if Prometheus is installed"
changed_when: false
ansible.builtin.command: "prometheus --version"
register: prom_installed_version
- name: "Check Prometheus version"
ansible.builtin.assert:
that: "prom_installed_version.stdout is regex('{{ prometheus_version }}')"
success_msg: "Prometheus version {{ prometheus_version }} is installed and working"
fail_msg: "Prometheus version {{ prometheus_version }} is not installed or not working correctly"
# kics-scan ignore-block
- name: "Check if Prometheus is reachable"
ansible.builtin.uri:
url: "http://localhost:9090/-/healthy"
return_content: true
status_code: 200
method: GET
body_format: json
register: prom_health
- name: "Debug Prometheus health status"
ansible.builtin.assert:
that: "prom_health.content | trim == 'Prometheus Server is Healthy.'"
success_msg: "Prometheus is healthy"
fail_msg: "Prometheus is not healthy"
# kics-scan ignore-block
- name: "Check if Prometheus is ready"
ansible.builtin.uri:
url: "http://localhost:9090/-/ready"
return_content: true
status_code: 200
method: GET
body_format: json
register: prom_ready
- name: "Debug Prometheus readiness status"
ansible.builtin.assert:
that: "prom_ready.content | trim == 'Prometheus Server is Ready.'"
success_msg: "Prometheus is ready"
fail_msg: "Prometheus is not ready"