From 635e7a2857d4601ca1e803a16f3c52450f4fbd42 Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Wed, 14 Aug 2024 14:19:21 -0500 Subject: [PATCH] fix: ensure datadog is in good state, fix swap file path check --- salt/datadog/init.sls | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/salt/datadog/init.sls b/salt/datadog/init.sls index 41d7d691..82ccc567 100644 --- a/salt/datadog/init.sls +++ b/salt/datadog/init.sls @@ -31,12 +31,25 @@ datadog_repo: - source: salt://datadog/files {% if 'datadog_api_key' in pillar %} +check_datadog_installation: + cmd.run: + - name: | + if ! dpkg-query -W datadog-agent || ! test -f /etc/datadog-agent/datadog.yaml; then + dpkg --remove --force-remove-reinstreq datadog-agent || true + apt-get -y --fix-broken install + apt-get update + fi + - hide_output: True + datadog-agent: pkg: - installed - require: - pkgrepo: datadog_repo - - mount: {% if swap_path %}{{ swap_path }}{% endif %} + {% if swap_path %} + - mount: {{ swap_path }} + {% endif %} + - cmd: check_datadog_installation service: - running - enable: True