Files
docker-elk/.github/workflows/scripts/elasticsearch-setup-passwords.exp
Antoine Cotten 25e0a5471b Ensure CI initializes passwords over localhost
Prevents the occasional connection timeout when the tool randomly picks
the IP of the ingress interface (usually 10.0.0.x/24) instead of the elk
interface (usually 10.0.1.x/24) in Swarm mode.
2020-10-14 02:37:09 +02:00

29 lines
756 B
Plaintext
Executable File

#!/usr/bin/expect -f
# List of expected users with dummy password
set user "(elastic|apm_system|kibana_system|logstash_system|beats_system|remote_monitoring_user)"
set password "testpasswd"
# Find elasticsearch container id
set MODE [lindex $argv 0]
if { [string match "swarm" $MODE] } {
set cid [exec docker ps -q -f label=com.docker.swarm.service.name=elk_elasticsearch]
} else {
set cid [exec docker ps -q -f label=com.docker.compose.service=elasticsearch]
}
set cmd "docker exec -it $cid bin/elasticsearch-setup-passwords interactive -s -b -u http://localhost:9200"
spawn {*}$cmd
expect {
-re "(E|Ree)nter password for \\\[$user\\\]: " {
send "$password\r"
exp_continue
}
eof
}
lassign [wait] pid spawnid os_error_flag value
exit $value