From 69857b6b5c6ea662ea8086c5911f37d8264b41a0 Mon Sep 17 00:00:00 2001 From: weslambert Date: Tue, 8 Oct 2024 10:54:54 -0400 Subject: [PATCH] Use ID instead of name --- salt/elasticfleet/tools/sbin/so-elastic-fleet-common | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/salt/elasticfleet/tools/sbin/so-elastic-fleet-common b/salt/elasticfleet/tools/sbin/so-elastic-fleet-common index fadf18b5f..296e578fc 100644 --- a/salt/elasticfleet/tools/sbin/so-elastic-fleet-common +++ b/salt/elasticfleet/tools/sbin/so-elastic-fleet-common @@ -102,6 +102,14 @@ elastic_fleet_package_is_installed() { curl -s -K /opt/so/conf/elasticsearch/curl.config -b "sid=$SESSIONCOOKIE" -L -X GET -H 'kbn-xsrf: true' "localhost:5601/api/fleet/epm/packages/$PACKAGE" | jq -r '.item.status' } +elastic_fleet_agent_policy_ids() { + curl -s -K /opt/so/conf/elasticsearch/curl.config -b "sid=$SESSIONCOOKIE" -L -X GET "localhost:5601/api/fleet/agent_policies" | jq -r .items[].id + if [ $? -ne 0 ]; then + echo "Error: Failed to retrieve agent policies." + exit 1 + fi +} + elastic_fleet_agent_policy_names() { curl -s -K /opt/so/conf/elasticsearch/curl.config -b "sid=$SESSIONCOOKIE" -L -X GET "localhost:5601/api/fleet/agent_policies" | jq -r .items[].name if [ $? -ne 0 ]; then