forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Agent] Docker image for integration tests (elastic#16898)
[Agent] Docker image for integration tests (elastic#16898)
- Loading branch information
1 parent
c66cfbf
commit dc22e9f
Showing
4 changed files
with
109 additions
and
8 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
dev-tools/packaging/templates/docker/docker-entrypoint.agent.tmpl
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
# Environment variables used | ||
# FLEET_ADMIN_PASSWORD - used for new fleet user [elastic] | ||
# FLEET_ADMIN_USERNAME - used for new fleet user [changeme] | ||
# FLEET_CONFIG_ID - config related to new token [defaul] | ||
# FLEET_ENROLLMENT_TOKEN - existing enrollment token to be used for enroll | ||
# FLEET_ENROLL - if set to 1 enroll will be performed | ||
# FLEET_SETUP - if set to 1 fleet setup will be performed | ||
# FLEET_TOKEN_NAME - token name for a token to be created | ||
# KIBANA_HOST - actual kibana host [http://localhost:5601] | ||
# KIBANA_PASSWORD - password for accessing kibana API [changeme] | ||
# KIBANA_USERNAME - username for accessing kibana API [elastic] | ||
|
||
function setup(){ | ||
curl -X POST ${KIBANA_HOST:-http://localhost:5601}/api/ingest_manager/setup -H 'kbn-xsrf: true' -u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} | ||
curl -X POST ${KIBANA_HOST:-http://localhost:5601}/api/ingest_manager/fleet/setup \ | ||
-H 'Content-Type: application/json' \ | ||
-H 'kbn-xsrf: true' \ | ||
-d '{"admin_username":"'"${FLEET_ADMIN_USERNAME:-elastic}"'","admin_password":"'"${FLEET_ADMIN_PASSWORD:-changeme}"'"}' \ | ||
-u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} | ||
} | ||
|
||
function enroll(){ | ||
local enrollResp | ||
local apiKey | ||
|
||
if [[ -n "${FLEET_ENROLLMENT_TOKEN}" ]] && [[ ${FLEET_ENROLLMENT_TOKEN} == 1 ]]; then | ||
apikey = "${FLEET_ENROLLMENT_TOKEN}" | ||
else | ||
enrollResp=$(curl -X POST ${KIBANA_HOST:-http://localhost:5601}/api/ingest_manager/fleet/enrollment-api-keys \ | ||
-H 'Content-Type: application/json' \ | ||
-H 'kbn-xsrf: true' \ | ||
-u ${KIBANA_USERNAME:-elastic}:${KIBANA_PASSWORD:-changeme} \ | ||
-d '{"name":"'"${FLEET_TOKEN_NAME:-demotoken}"'","config_id":"'"${FLEET_CONFIG_ID:-default}"'"}') | ||
|
||
local exitCode=$? | ||
if [ $exitCode -ne 0 ]; then | ||
exit $exitCode | ||
fi | ||
|
||
apikey=$(echo $enrollResp | jq -r '.item.api_key') | ||
fi | ||
|
||
./{{ .BeatName }} enroll ${KIBANA_HOST:-http://localhost:5601} $apikey -f | ||
} | ||
yum install -y epel-release | ||
yum install -y jq | ||
|
||
if [[ -n "${FLEET_SETUP}" ]] && [[ ${FLEET_SETUP} == 1 ]]; then setup; fi | ||
if [[ -n "${FLEET_ENROLL}" ]] && [[ ${FLEET_ENROLL} == 1 ]]; then enroll; fi | ||
|
||
exec {{ .BeatName }} run "$@" |
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
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