--- - name: Verify hosts: all gather_facts: false any_errors_fatal: true vars_files: - admin_cred.yml tasks: - name: "Include default vars" ansible.builtin.include_vars: dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/" extensions: ['yml'] - name: "Check if Grafana is installed" changed_when: false ansible.builtin.command: "grafana-server -v" register: grafana_installed_version - name: "Check Grafana version" ansible.builtin.assert: that: "grafana_installed_version.stdout is regex('{{ grafana_version }}')" success_msg: "grafana version {{ grafana_version }} is installed and working" fail_msg: "grafana version {{ grafana_version }} is not installed or not working correctly" # kics-scan ignore-block - name: "Check if Grafana login page is reachable" ansible.builtin.uri: url: "http://localhost:{{ grafana_port }}/api/health" return_content: true status_code: 200 method: GET body_format: json register: grafana_health - name: "Debug Grafana health status" ansible.builtin.assert: that: grafana_health.json.database == "ok" success_msg: "Grafana is healthy" fail_msg: "Grafana is not healthy"