Last active
June 6, 2023 22:23
-
-
Save peasead/0667e516dc5066335c95c3aa71ba0313 to your computer and use it in GitHub Desktop.
Updates Fleet-managed Elastic agents that are stuck in an "Updating" status.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shell script to update Elastic Agents that are stuck in an "Updating" state in Fleet. | |
# Example : | |
# KIBANA_URL="https://my-kibana-host:5601" | |
# PASSWORD="secret-password" | |
# ./update-agents.sh | |
KIBANA_URL="https://kibana-url:port" | |
PASSWORD="elastic-user-password" | |
AGENT_IDS=` | |
curl --request GET \ | |
--url ${KIBANA_URL}/api/fleet/agents \ | |
--user "elastic:${PASSWORD}" \ | |
--header 'Content-Type: application/json' \ | |
--header 'kbn-xsrf: as' \ | |
| jq '.list | map(select(.status == "updating")) | map(.agent.id)' | |
` | |
curl --request POST \ | |
--url ${KIBANA_URL}/api/fleet/agents/bulk_upgrade \ | |
--user "elastic:${PASSWORD}" \ | |
--header 'Content-Type: application/json' \ | |
--header 'kbn-xsrf: as' \ | |
--data '{"version": "8.8.0","force": true,"agents":"$AGENT_IDS"}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment