-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.yml
executable file
·385 lines (352 loc) · 9.96 KB
/
dev.yml
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
version: '2.2'
# x-logging: &logging
# logging:
# driver: loki
# options:
# loki-url: 'http://host.docker.internal:3100/loki/api/v1/push'
services:
exporter:
image: quay.io/prometheuscommunity/elasticsearch-exporter:latest
# <<: *logging
hostname: exporter-osd-${OS_VERSION}
profiles:
- 'server'
- 'saml'
- 'standard'
networks:
- os-dev
- mon
command:
- '--es.uri=https://admin:${PASSWORD}@os1:9200'
- '--es.ssl-skip-verify'
- '--es.all'
imposter:
image: outofcoffee/imposter:3.44.1
# <<: *logging
hostname: imposter-osd-${OS_VERSION}
networks:
- os-dev
- mon
environment:
- JAVA_OPTS="-Xmx512m -Xss512k -Dfile.encoding=UTF-8 -XX:MaxRAM=800m -XX:MaxRAMPercentage=95 -XX:MinRAMPercentage=60A"
- MALLOC_ARENA_MAX=1
volumes:
- ../imposter:/opt/imposter/config
generator:
image: cfssl/cfssl
# <<: *logging
profiles:
- 'server'
- 'saml'
- 'standard'
volumes:
- wi_certs:/certs/wi
- wd_certs:/certs/wd
- wm_certs:/certs/wm
- idp_certs:/certs/idp
- ./config/${OSD_MAJOR}/certs:/conf
- os_logs:/logs
- os_data:/data
# Included to avoid docker from creating duplicated networks
networks:
- os-dev
entrypoint: /bin/bash
command: >
-c '
export certs=/tmp/certs
mkdir $$certs
cd $$certs
echo "Generating CA"
cfssl gencert -initca /conf/ca.json | cfssljson -bare ca
echo "Generating servers certificates"
for i in os1 osd imposter; do
echo "Generating cert for $$i"
cat /conf/host.json | \
sed "s/HOST/$$i/g" | \
cfssl gencert \
-ca $$certs/ca.pem \
-ca-key $$certs/ca-key.pem \
-config /conf/cfssl.json \
-profile=server - | \
cfssljson -bare $$i
openssl pkcs8 -topk8 -inform pem -in $$i-key.pem -outform pem -nocrypt -out $$i.key
done
echo "Generating clients certificates"
for i in admin filebeat saml; do
echo "Generating cert for $$i"
cat /conf/host.json | \
sed "s/HOST/$$i/g" | \
cfssl gencert \
-ca $$certs/ca.pem \
-ca-key $$certs/ca-key.pem \
-config /conf/cfssl.json \
-profile=client - | \
cfssljson -bare $$i
openssl pkcs8 -topk8 -inform pem -in $$i-key.pem -outform pem -nocrypt -out $$i.key
done
echo "Setting up permissions"
rm /certs/wi/* /certs/wd/* /certs/wm/*
mv $$certs/os1* /certs/wi
mv $$certs/admin* /certs/wi
mv /certs/wi/admin.key /certs/wi/admin-key.pem
cp $$certs/*ca* /certs/wi
mv $$certs/osd* /certs/wd
cp $$certs/*ca* /certs/wd
mv $$certs/saml* /certs/idp
mv /certs/idp/saml.key /certs/idp/saml-key.pem
cp $$certs/*ca* /certs/idp
mv $$certs/*.* /certs/wm
chmod 640 /certs/wi/* /certs/wd/* /certs/wm/*
chown -R 1000:1000 /certs/*
ls -alR /certs/
chown 1000:1000 /data /logs
chmod 775 /data /logs
sleep 300
'
healthcheck:
test: ['CMD-SHELL', '[ -r /certs/wi/os1.pem ]']
interval: 2s
timeout: 5s
retries: 10
os1:
depends_on:
idpsetup:
condition: service_completed_successfully
required: false
image: opensearchproject/opensearch:${OS_VERSION}
# <<: *logging
profiles:
- 'server'
- 'saml'
- 'standard'
environment:
- cluster.name=os-dev-cluster
- node.name=os1
- discovery.seed_hosts=os1
- cluster.initial_master_nodes=os1
- bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
- 'OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m' # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
- OPENSEARCH_PATH_CONF=/usr/share/opensearch/config/
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536 # maximum number of open files for the OpenSearch user, set to at least 65536 on modern systems
hard: 65536
volumes:
- wi_certs:/usr/share/opensearch/config/certs/
- ./config/${OSD_MAJOR}/os/opensearch.yml:/usr/share/opensearch/config/opensearch.yml
- ./config/${OSD_MAJOR}/os/internal_users.yml:${SEC_CONFIG_PATH}/internal_users.yml
- ${SEC_CONFIG_FILE}:${SEC_CONFIG_PATH}/config.yml
- ./config/${OSD_MAJOR}/os/roles_mapping.yml:${SEC_CONFIG_PATH}/roles_mapping.yml
- ./config/${OSD_MAJOR}/os/roles.yml:${SEC_CONFIG_PATH}/roles.yml
- os_logs:/var/log/os1
- os_data:/var/lib/os1
ports:
- 9200:9200
- 9300:9300
networks:
- os-dev
- mon
healthcheck:
test:
[
'CMD-SHELL',
"curl -v --cacert config/certs/ca.pem https://os1:9200 2>&1 | grep -q '401 Unauthorized'",
]
interval: 1s
timeout: 5s
retries: 120
filebeat:
depends_on:
os1:
condition: service_healthy
image: elastic/filebeat:7.10.2
profiles:
- 'saml'
- 'standard'
hostname: filebeat
user: '0:0'
networks:
- os-dev
- mon
# <<: *logging
# restart: always
entrypoint:
- '/bin/bash'
command: >
-c '
mkdir -p /etc/filebeat
echo admin | filebeat keystore add username --stdin --force
echo ${PASSWORD}| filebeat keystore add password --stdin --force
curl -so /etc/filebeat/wazuh-template.json https://raw.githubusercontent.com/wazuh/wazuh/v4.7.2/extensions/elasticsearch/7.x/wazuh-template.json
curl -s https://packages.wazuh.com/4.x/filebeat/wazuh-filebeat-0.3.tar.gz | tar -xvz -C /usr/share/filebeat/module
# copy filebeat to preserve correct permissions without
# affecting host filesystem
cp /tmp/filebeat.yml /usr/share/filebeat/filebeat.yml
chown root.root /usr/share/filebeat/filebeat.yml
chmod go-w /usr/share/filebeat/filebeat.yml
filebeat setup -e
filebeat
'
volumes:
- wm_certs:/etc/ssl/elastic
- ./config/${OSD_MAJOR}/filebeat/filebeat.yml:/tmp/filebeat.yml
osd:
depends_on:
os1:
condition: service_healthy
image: quay.io/wazuh/osd-dev:${OSD_VERSION}
profiles:
- 'server'
- 'saml'
- 'standard'
hostname: osd
networks:
- os-dev
- devel
- mon
user: '1000:1000'
# <<: *logging
ports:
- ${OSD_PORT}:5601
environment:
- 'LOGS=/proc/1/fd/1'
entrypoint: ['tail', '-f', '/dev/null']
volumes:
- osd_cache:/home/node/.cache
- '${SRC}/main:/home/node/kbn/plugins/wazuh'
- '${SRC}/wazuh-core:/home/node/kbn/plugins/wazuh-core'
- '${SRC}/wazuh-check-updates:/home/node/kbn/plugins/wazuh-check-updates'
- wd_certs:/home/node/kbn/certs/
- ${WAZUH_DASHBOARD_CONF}:/home/node/kbn/config/opensearch_dashboards.yml
- ./config/${OSD_MAJOR}/osd/wazuh.yml:/home/node/kbn/data/wazuh/config/wazuh.yml
idpsec:
image: quay.io/keycloak/keycloak:19.0.1
depends_on:
generator:
condition: service_healthy
profiles:
- 'saml'
volumes:
- wi_certs:/certs/wi
- wd_certs:/certs/wd
- wm_certs:/certs/wm
- idp_certs:/certs/idp
# Included to avoid docker from creating duplicated networks
networks:
- os-dev
entrypoint: /bin/bash
command: >
-c '
# trust store
for i in /certs/idp/ca.pem /certs/wd/osd.pem /certs/wi/os1.pem
do
keytool -import -alias $$(basename $$i .pem) -file $$i -keystore /certs/idp/truststore.jks -storepass SecretPassword -trustcacerts -noprompt
done
sleep 300
'
healthcheck:
test: ['CMD-SHELL', '[ -r /certs/idp/truststore.jks ]']
interval: 2s
timeout: 5s
retries: 10
idp:
image: quay.io/keycloak/keycloak:19.0.1
depends_on:
idpsec:
condition: service_healthy
profiles:
- 'saml'
hostname: idp
# <<: *logging
networks:
- os-dev
- mon
ports:
- '8080:8080'
environment:
- KEYCLOAK_ADMIN=admin
- KEYCLOAK_ADMIN_PASSWORD=admin
- KC_SPI_TRUSTSTORE_FILE_PASSWORD=SecretPassword
- KC_SPI_TRUSTSTORE_FILE_FILE=/certs/truststore.jks
volumes:
- keycloak-data:/var/lib/keycloak/data
- idp_certs:/certs
command: start-dev
healthcheck:
test: curl -f http://localhost:8080/realms/master || exit 1
interval: 10s
timeout: 5s
retries: 6
idpsetup:
image: badouralix/curl-jq
depends_on:
idp:
condition: service_healthy
profiles:
- 'saml'
hostname: idpsetup
# <<: *logging
networks:
- os-dev
- mon
volumes:
- wi_certs:/certs/wi
- ./config/enable_saml.sh:/enable_saml.sh
entrypoint: /bin/sh
command: >
-c '
apk add bash
bash /enable_saml.sh
exit 0
'
wazuh.manager:
depends_on:
os1:
condition: service_healthy
image: wazuh/wazuh-manager:${WAZUH_STACK}
profiles:
- 'server'
hostname: wazuh.manager
# <<: *logging
networks:
- os-dev
- mon
environment:
- INDEXER_URL=https://os1:9200
- INDEXER_USERNAME=admin
- INDEXER_PASSWORD=admin
- FILEBEAT_SSL_VERIFICATION_MODE=full
- SSL_CERTIFICATE_AUTHORITIES=/etc/ssl/wazuh/ca.pem
- SSL_CERTIFICATE=/etc/ssl/wazuh/filebeat.pem
- SSL_KEY=/etc/ssl/wazuh/filebeat.key
- API_USERNAME=wazuh-wui
- API_PASSWORD=MyS3cr37P450r.*-
volumes:
- wm_certs:/etc/ssl/wazuh
ports:
- '514:514'
- '1514:1514'
- '1515:1515'
- '1516:1516'
- '55000:55000'
networks:
os-dev:
name: os-dev-${OS_VERSION}
driver: bridge
mon:
external: true
devel:
external: true
volumes:
osd_cache:
certs:
os_logs:
os_data:
wi_certs:
wd_certs:
wm_certs:
idp_certs:
keycloak-data: