-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap-sesdev-monitoring.sh
237 lines (225 loc) · 8.69 KB
/
bootstrap-sesdev-monitoring.sh
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/usr/bin/env bash
reboot_required=false
install_node_exporter() {
fsid=$(ceph -s --format=json | jq -r .fsid)
ne_name="node-exporter.ceph.com"
for node in $(ceph orchestrator host ls --format=json | jq -r '.[].host') ; do
ssh $node "export CEPHADM_IMAGE='prom/node-exporter:latest'; cephadm deploy \
--name $ne_name \
--fsid $fsid"
ssh $node "systemctl status ceph-$fsid@$ne_name"
done
}
install_grafana() {
read -r -d '' grafana_json <<-EOF
{
"grafana.ini": [
"[users]",
" default_theme = light",
"[auth.anonymous]",
" enabled = true",
" org_name = 'Main Org.'",
" org_role = 'Viewer'",
"[server]",
" domain = 'bootstrap.storage.lab'",
" protocol = https",
" cert_file = /etc/grafana/certs/cert_file",
" cert_key = /etc/grafana/certs/cert_key",
" http_port = 3000",
" http_addr = localhost",
"[security]",
" admin_user = admin",
" admin_password = admin",
" allow_embedding = true"
],
"provisioning/datasources/ceph-dashboard.yml": [
"deleteDatasources:",
" - name: 'Dashboard'",
" orgId: 1",
" ",
"datasources:",
" - name: 'Dashboard'",
" type: 'prometheus'",
" access: 'proxy'",
" orgId: 1",
" url: 'http://localhost:9095'",
" basicAuth: false",
" isDefault: true",
" editable: false"
],
"certs/cert_file": [
"-----BEGIN CERTIFICATE-----",
"MIIDLTCCAhWgAwIBAgIUEH0mq6u93LKsWlNXst5pxWcuqkQwDQYJKoZIhvcNAQEL",
"BQAwJjELMAkGA1UECgwCSVQxFzAVBgNVBAMMDmNlcGgtZGFzaGJvYXJkMB4XDTIw",
"MDEwNTIyNDYyMFoXDTMwMDEwMjIyNDYyMFowJjELMAkGA1UECgwCSVQxFzAVBgNV",
"BAMMDmNlcGgtZGFzaGJvYXJkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC",
"AQEAqxh6eO0NTZJe+DoKZG/kozJCf+83eB3gWzwXoNinRmV/49f5WPR20DIxAe0R",
"saO6XynJXTrhvXT1bsARUq+LSmjWNFoYXopFuOJhGdWn4dmpuHwtpcFv2kjzNOKj",
"U2EG8j6bsRp1jFAzn7kdbSWT0UHySRXp9DPAjDiF3LjykMXiJMReccFXrB1pRi93",
"nJxED8d6oT5GazGB44svb+Zi6ABamZu5SDJC1Fr/O5rWFNQkH4hQEqDPj1817H9O",
"sm0mZiNy77ZQuAzOgZN153L3QOsyJismwNHfAMGMH9mzPKOjyhc13VlZyeEzml8p",
"ZpWQ2gi8P2r/FAr8bFL3MFnHKwIDAQABo1MwUTAdBgNVHQ4EFgQUZg3v7MX4J+hx",
"w3HENCrUkMK8tbwwHwYDVR0jBBgwFoAUZg3v7MX4J+hxw3HENCrUkMK8tbwwDwYD",
"VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAaR/XPGKwUgVwH3KXAb6+",
"s9NTAt6lCmFdQz1ngoqFSizW7KGSXnOgd6xTiUCR0Tjjo2zKCwhIINaI6mwqMbrg",
"BOjb7diaqwFaitRs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dKq9MzbuYqEcCfZOJgxoQKBgQDf+5XF+aXQz2OmSaj6",
"1Yr+3KAKdfX/AYp22X1Wy4zWcZlgujgwQ1FG0zay8HVBM0/xn4UgOtcKCoXibePh",
"ag1t8aZINdRE1JcMzKmZoSvU9Xk30CNvygizuJVEKsJFPDbPzCpauDSplzcQb4pZ",
"wepucPuowkPMBx0iU3x0qSThWwKBgQDDjYs7d30xxSqWWXyCOZshy7UtHMNfqP15",
"kDfTXIZzuHvDf6ZNci10VY1eDZbpZfHgc6x1ElbKv2H4dYsgkENJZUi1YQDpVPKq",
"4N5teNykgAuagiR7dRFltSju3S7hIE6HInTv3hShaFPymlEE7zuBMuEUcuvYz5YN",
"RjxsvypKcQKBgCuuV+Y1KqZPW8K5SNAqRyIvCrMfkCr8NPG6tpvvtHa5zsyzZHPd",
"HQOv+1HoXSWrCSM5FfBUKU3XAYdIIRH76cSQRPp+LPiDcTXY0Baa/P5aJRrCZ7bM",
"cugBznJt2FdCR/o8eeIZXIPabq2w4w1gKQUC2cFuqWQn2wGvwGzL89pTAoGAAfpx",
"mSVpT9KVzrWTC+I3To04BP/QfixAfDVYSzwZZBxOrDijXw8zpISlDHmIuE2+t62T",
"5g9Mb3qmLBRMVwT+mUR8CtGzZ6jjV5U0yti5KrTc6TA93D3f8i51/oygR8jC4p0X",
"n8GYZdWfW8nx3eHpsTHpkwJinmvjMbkvLU51yBECgYAnUAMyhNOWjbYS5QWd8i1W",
"SFQansVDeeT98RebrzmGwlgrCImHItJz0Tz8gkNB3+S2B2balqT0WHaDxQ8vCtwX",
"xB4wd+gMomgdYtHGRnRwj1UyRXDk0c1TgGdRjOn3URaezBMibHTQSbFgPciJgAuU",
"mEl75h1ToBX9yvnH39o50g==",
"-----END PRIVATE KEY-----"
]
}
EOF
echo "$grafana_json" > /tmp/grafana.json
CEPHADM_IMAGE='pcuzner/ceph-grafana-el8:latest' cephadm deploy \
--name grafana.admin.com \
--fsid $(ceph fsid) \
--config-json /tmp/grafana.json
}
install_tools() {
for node in $(ceph orchestrator host ls --format=json | jq -r '.[].host') ; do
ssh $node zypper ref
# zsh
ssh $node zypper -n in zsh vim-data
ssh $node "cd /tmp ; \
curl -O https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh && \
CHSH=no RUNZSH=no sh install.sh && \
chsh -s $(which zsh)"
ssh $node "sed -i 's/# DISABLE_AUTO_UPDATE/DISABLE_AUTO_UPDATE/g' /root/.zshrc"
# fzf
ssh $node git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
ssh $node bash ~/.fzf/install --all # --all prevents any user interaction
# ripgrep
ssh $node zypper -n in ripgrep ripgrep-bash-completion ripgrep-zsh-completion
# vim
ssh $node 'echo "ino jk <esc>\nnn H ^\nnn L $\nset ai si et sw=4 ts=4 sts=4 hlsearch\nsyntax enable" > /root/.vimrc'
done
}
install_prometheus() {
read -r -d '' prometheus_json <<-EOF
{
"prometheus.yml": [
"global:",
" scrape_interval: 5s",
" evaluation_interval: 10s",
"",
"rule_files: ",
" - '/etc/prometheus/alerting/*'",
"",
"scrape_configs:",
" - job_name: 'prometheus'",
" static_configs:",
" - targets: ['localhost:9095']",
" - job_name: 'node-exporter'",
" static_configs:",
" - targets:",
" - admin:9100",
" - node1:9100",
" - node2:9100"
]
}
EOF
nodes=(admin)
fsid=$(ceph -s --format=json | jq -r .fsid)
tmp_config_file="/tmp/prometheus.json"
prom_name="prometheus.admin.com"
for node in $nodes ; do
echo "$prometheus_json" | ssh $node -T "cat > $tmp_config_file"
ssh $node "export CEPHADM_IMAGE='prom/prometheus:latest'; cephadm deploy \
--name $prom_name \
--fsid $(ceph -s --format=json | jq -r .fsid) \
--config-json /tmp/prometheus.json"
ssh $node "systemctl status ceph-$fsid@$prom_name"
done
}
fix_apparmor() {
for node in $(ceph orchestrator host ls --format=json | jq -r '.[].host') ; do
ssh $node zypper -n in apparmor-profiles
reboot_required=true
done
}
fix_podman() {
for node in $(ceph orchestrator host ls --format=json | jq -r '.[].host') ; do
ssh $node zypper -n in podman-cni-config
reboot_required=true
done
}
activate_cgroup_memory() {
for node in $(ceph orchestrator host ls --format=json | jq -r '.[].host') ; do
cmd=$(
base64 -w0 <<-EOF
awk -i inplace '
/GRUB_CMDLINE_LINUX.*cgroup_enable=memory/{print; next}
{
gsub(/GRUB_CMDLINE_LINUX="/, "GRUB_CMDLINE_LINUX=\42cgroup_enable=memory swapaccount=1 ")
print
}
' /etc/default/grub
EOF
)
ssh $node "echo $cmd | base64 -d | bash"
reboot_required=true
done
}
reboot_all() {
for node in $(ceph orchestrator host ls --format=json | jq -r '.[].host') ; do
if [[ "$node" != "admin" ]] ; then
echo "rebooting $node"
ssh $node reboot
fi
done
echo "rebooting admin"
ssh admin reboot
}
check_reboot_required() {
if [[ "$reboot_required" == "true" ]] ; then
echo "Reboot of all machines required, do you want to reboot now?"
read a
if [[ "$a" == "yes" || "$a" == "y" ]] ; then
reboot_all
fi
fi
}
prepare_all() {
fix_apparmor
fix_podman
activate_cgroup_memory
check_reboot_required
}
deploy_all() {
install_tools
prepare_all
install_prometheus
install_node_exporter
}