Skip to content

Commit

Permalink
Fix: select default agent policy if no enrollment token provided (#23973
Browse files Browse the repository at this point in the history
) (#24001)

* Fix: select default agent policy if no enrollment token provided

* Update CHANGELOG

(cherry picked from commit e3da3be)
  • Loading branch information
mtojek authored Feb 15, 2021
1 parent 51788fd commit bf2881c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ function enroll(){
exit $exitCode
fi
echo $enrollResp
local apikeyId=$(echo $enrollResp | jq -r '.list[0].id')
local apikeyId=$(echo $enrollResp | jq -r '.list[] | select((.name | startswith("Default ")) and (.active == true)) | .id')
echo $apikeyId

if [[ -z "${$apikeyId}" ]]; then
echo "Default agent policy was not found. Please consider using own enrollment token (FLEET_ENROLLMENT_TOKEN)."
exit 1
fi

enrollResp=$(curl ${KIBANA_HOST:-http://localhost:5601}/api/fleet/enrollment-api-keys/$apikeyId \
-H 'Content-Type: application/json' \
-H 'kbn-xsrf: true' \
Expand Down
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- Increase checkin grace period to 30 seconds {pull}23568[23568]
- Fix libbeat from reporting back degraded on config update {pull}23537[23537]
- Fix issues with dynamic inputs and conditions {pull}23886[23886]
- Select default agent policy if no enrollment token provided. {pull}23973[23973]

==== New features

Expand Down

0 comments on commit bf2881c

Please sign in to comment.