From 0de11c13152f6496e4a32e7f47e243e1391d3ccf Mon Sep 17 00:00:00 2001 From: Ishan Jain <51803183+ishanjainn@users.noreply.github.com> Date: Tue, 19 Sep 2023 13:14:54 +0530 Subject: [PATCH] Add check for Curl and failure step if Agent Version is not retrieved (#104) --- roles/grafana_agent/tasks/preflight/download.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/roles/grafana_agent/tasks/preflight/download.yaml b/roles/grafana_agent/tasks/preflight/download.yaml index 5caafc35..bcedc4fd 100644 --- a/roles/grafana_agent/tasks/preflight/download.yaml +++ b/roles/grafana_agent/tasks/preflight/download.yaml @@ -1,4 +1,14 @@ --- +- name: Gather the package facts + ansible.builtin.package_facts: + manager: auto + +- name: Fail if Curl is not installed + ansible.builtin.fail: + msg: "curl is not installed!" + when: "'curl' not in ansible_facts.packages" + + - name: Get Grafana Agent version from Github when: grafana_agent_version == 'latest' and not __grafana_agent_local_install block: @@ -13,6 +23,11 @@ become: false register: _grafana_agent_version_request + - name: Fail if cannot get Grafana Agent Version + ansible.builtin.fail: + msg: Issue getting the Grafana Agent Version + when: _grafana_agent_version_request == "" + - name: Set the Grafana Agent version ansible.builtin.set_fact: grafana_agent_version: "{{ _grafana_agent_version_request.stdout }}"