-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathset-elastic-passwords.exp
executable file
·75 lines (73 loc) · 3.03 KB
/
set-elastic-passwords.exp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/expect -f
#
# This script sets the user passwords for elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user
# It uses the environment variables to set these passwords in the provided container id
#
# Requirements:
# ARGUMENTS:
# 0 - the elastic-search container id (eg. set-elastic-passwords.exp 141aba142)
#
# ENVIRONMENT VARIABLES:
# ES_ELASTIC - The elastic search super-user password
# ES_APM_SYSTEM - The password for the user the APM server uses when storing monitoring information in Elasticsearch.
# ES_KIBANA_SYSTEM - The password for the user Kibana uses to connect and communicate with Elasticsearch.
# ES_LOGSTASH_SYSTEM - The password for the user Logstash uses when storing monitoring information in Elasticsearch.
# ES_BEATS_SYSTEM - The password for the user the Beats use when storing monitoring information in Elasticsearch.
# ES_REMOTE_MONITORING_USER - The password for the user Metricbeat uses when collecting and storing monitoring information in Elasticsearch. It has the remote_monitoring_agent and remote_monitoring_collector built-in roles.
# Boilerplate
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
set elasticSearchContainerId [lindex $argv 0]
spawn docker exec -it $elasticSearchContainerId /bin/bash -c { until [[ -n $(curl localhost:9200) ]]; do sleep 0.25; done && bin/elasticsearch-setup-passwords interactive }
match_max 100000
expect -exact "Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.\r
You will be prompted to enter passwords as the process progresses.\r
Please confirm that you would like to continue \[y/N\]"
send -- "y\r"
expect -exact "y\r
\r
\r
Enter password for \[elastic\]: "
send -- "$::env(ES_ELASTIC)\r"
expect -exact "\r
Reenter password for \[elastic\]: "
send -- "$::env(ES_ELASTIC)\r"
expect -exact "\r
Enter password for \[apm_system\]: "
send -- "$::env(ES_APM_SYSTEM)\r"
expect -exact "\r
Reenter password for \[apm_system\]: "
send -- "$::env(ES_APM_SYSTEM)\r"
expect -exact "\r
Enter password for \[kibana_system\]: "
send -- "$::env(ES_KIBANA_SYSTEM)\r"
expect -exact "\r
Reenter password for \[kibana_system\]: "
send -- "$::env(ES_KIBANA_SYSTEM)\r"
expect -exact "\r
Enter password for \[logstash_system\]: "
send -- "$::env(ES_LOGSTASH_SYSTEM)\r"
expect -exact "\r
Reenter password for \[logstash_system\]: "
send -- "$::env(ES_LOGSTASH_SYSTEM)\r"
expect -exact "\r
Enter password for \[beats_system\]: "
send -- "$::env(ES_BEATS_SYSTEM)\r"
expect -exact "\r
Reenter password for \[beats_system\]: "
send -- "$::env(ES_BEATS_SYSTEM)\r"
expect -exact "\r
Enter password for \[remote_monitoring_user\]: "
send -- "$::env(ES_REMOTE_MONITORING_USER)\r"
expect -exact "\r
Reenter password for \[remote_monitoring_user\]: "
send -- "$::env(ES_REMOTE_MONITORING_USER)\r"
expect eof