-
Notifications
You must be signed in to change notification settings - Fork 2
/
build
executable file
·612 lines (584 loc) · 33.9 KB
/
build
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
#!/bin/bash
VERSION="0.1"
local_admin_user="local-admin"
nexus_keycloak_plugin="0.5.0"
nexus_apk_plugin="0.0.25"
netcicd_pwd="netcicd"
keycloak_pwd="Pa55w0rd"
keycloak_storepass="password"
freeipa_pwd="Pa55w0rd"
jenkins_storepass="changeit"
nexus_storepass="password"
sp="/-\|"
sc=0
spin() {
printf -- "${sp:sc++:1} ( ${t} sec.) \r"
((sc==${#sp})) && sc=0
sleep 1
let t+=1
}
endspin() {
printf "\r%s\n" "$@"
}
echo "****************************************************************************************************************"
echo " Start clean"
echo "****************************************************************************************************************"
docker-compose down --remove-orphans
docker-compose rm -f
docker volume rm $(docker volume ls -q)
rm -f *_token
rm -f install_tests/log.html
rm -f install_tests/output.xml
rm -f install_tests/report.html
rm -f install_tests/*.png
rm -f install_tests/*.log
rm -f install_log/*
rm -f freeipa/certs/*
rm -f freeipa/hostcerts/*
rm -f nexus/keystore.jks
rm -f cicdtoolbox-db/docker-entrypoint-initdb-resources/*
rm -f gitea/gitea.tooling.provider.test*
rm -f jenkins/jenkins.tooling*
rm -f jenkins_buildnode/*_secret
rm -f jenkins_buildnode/agent.jar
rm -f jenkins_buildnode/jenkins-cli.jar
echo " "
echo "****************************************************************************************************************"
echo " Cleaning Gitea"
echo "****************************************************************************************************************"
sudo rm -rf gitea/data/*
echo " "
echo "****************************************************************************************************************"
echo " Cleaning Nexus"
echo "****************************************************************************************************************"
sudo rm -rf nexus/data/*
sudo rm -rf nexus/*.kar
echo " "
echo "****************************************************************************************************************"
echo " Cleaning Argos"
echo "****************************************************************************************************************"
cp -p argos/compose-application.yml argos/application.yml
echo "****************************************************************************************************************"
echo " Making sure all containers are reachable locally with the name in the"
echo " hosts file."
echo "****************************************************************************************************************"
echo " "
sudo chmod o+w /etc/hosts
if grep -q "ipa-ca" /etc/hosts; then
echo " ipa-ca exists in /etc/hosts, removing..."
sudo sed -i '/ipa-ca.tooling.provider.test/d' /etc/hosts
fi
echo " Add ipa-ca /etc/hosts"
sudo echo "172.16.8.12 ipa-ca.tooling.provider.test" >> /etc/hosts
if grep -q "freeipa" /etc/hosts; then
echo " FreeIPA exists in /etc/hosts, removing..."
sudo sed -i '/freeipa.iam.provider.test/d' /etc/hosts
fi
echo " Add FreeIPA to /etc/hosts"
sudo echo "172.16.8.12 freeipa.iam.provider.test" >> /etc/hosts
if grep -q "cicdtoolbox-db" /etc/hosts; then
echo " CICDtoolbox-db exists in /etc/hosts, removing..."
sudo sed -i '/cicdtoolbox-db.internal.provider.test/d' /etc/hosts
fi
echo " Add CICDtoolbox-db to /etc/hosts"
sudo echo "172.16.9.2 cicdtoolbox-db.internal.provider.test" >> /etc/hosts
if grep -q "mongodb" /etc/hosts; then
echo " mongodb exists in /etc/hosts, removing..."
sudo sed -i '/mongodb.internal.provider.test/d' /etc/hosts
fi
echo " Add mongodb to /etc/hosts"
sudo echo "172.16.9.3 mongodb.internal.provider.test" >> /etc/hosts
if grep -q "restportal" /etc/hosts; then
echo " Provider REST portal exists in /etc/hosts, removing..."
sudo sed -i '/restportal.services.provider.test/d' /etc/hosts
fi
echo " Add Provider REST portal to /etc/hosts"
sudo echo "172.16.10.2 restportal.services.provider.test" >> /etc/hosts
if grep -q "argos.services.provider.test" /etc/hosts; then
echo " Argos Notray Portal exists in /etc/hosts, removing..."
sudo sed -i '/argos.services.provider.test/d' /etc/hosts
fi
echo " Add Provider REST portal to /etc/hosts"
sudo echo "172.16.10.4 argos.services.provider.test" >> /etc/hosts
if grep -q "keycloak" /etc/hosts; then
echo " Keycloak exists in /etc/hosts, removing..."
sudo sed -i '/keycloak.services.provider.test/d' /etc/hosts
fi
echo " Add Keycloak to /etc/hosts"
sudo echo "172.16.10.11 keycloak.services.provider.test" >> /etc/hosts
if grep -q "gitea" /etc/hosts; then
echo " Gitea exists in /etc/hosts, removing..."
sudo sed -i '/gitea.tooling.provider.test/d' /etc/hosts
fi
echo " Add Gitea to /etc/hosts"
sudo echo "172.16.11.3 gitea.tooling.provider.test" >> /etc/hosts
if grep -q "argos-service.tooling.provider.test" /etc/hosts; then
echo " Argos Service exists in /etc/hosts, removing..."
sudo sed -i '/argos-service.tooling.provider.test/d' /etc/hosts
fi
echo " Add Gitea to /etc/hosts"
sudo echo "172.16.11.4 argos-service.tooling.provider.test" >> /etc/hosts
if grep -q "jenkins" /etc/hosts; then
echo " Jenkins exists in /etc/hosts, removing..."
sudo sed -i '/jenkins.tooling.provider.test/d' /etc/hosts
fi
echo " Add Jenkins to /etc/hosts"
sudo echo "172.16.11.8 jenkins.tooling.provider.test" >> /etc/hosts
if grep -q "nexus" /etc/hosts; then
echo " Nexus exists in /etc/hosts, removing..."
sudo sed -i '/nexus.tooling.provider.test/d' /etc/hosts
fi
echo " Add Nexus to /etc/hosts"
sudo echo "172.16.11.9 nexus.tooling.provider.test" >> /etc/hosts
if grep -q "build-dev" /etc/hosts; then
echo " Jenkins build-dev node exists in /etc/hosts, removing..."
sudo sed -i '/build-dev.delivery.provider.test/d' /etc/hosts
fi
echo " Add Jenkins build-dev node to /etc/hosts"
sudo echo "172.16.12.3 build-dev.delivery.provider.test" >> /etc/hosts
if grep -q "build-test" /etc/hosts; then
echo " Jenkins build-test node exists in /etc/hosts, removing..."
sudo sed -i '/build-test.delivery.provider.test/d' /etc/hosts
fi
echo " Add Jenkins build-test node to /etc/hosts"
sudo echo "172.16.12.3 build-test.delivery.provider.test" >> /etc/hosts
if grep -q "build-acc" /etc/hosts; then
echo " Jenkins build-acc node exists in /etc/hosts, removing..."
sudo sed -i '/build-acc.delivery.provider.test/d' /etc/hosts
fi
echo " Add Jenkins build-acc node to /etc/hosts"
sudo echo "172.16.12.3 build-acc.delivery.provider.test" >> /etc/hosts
if grep -q "build-prod" /etc/hosts; then
echo " Jenkins build-prod node exists in /etc/hosts, removing..."
sudo sed -i '/build-prod.delivery.provider.test/d' /etc/hosts
fi
echo " Add Jenkins build-prod node to /etc/hosts"
sudo echo "172.16.12.3 build-prod.delivery.provider.test" >> /etc/hosts
if grep -q "portainer" /etc/hosts; then
echo " Portainer exists in /etc/hosts, removing..."
sudo sed -i '/portainer.monitoring.provider.test/d' /etc/hosts
fi
echo " Add Portainer to /etc/hosts"
sudo echo "172.16.13.3 portainer.monitoring.provider.test" >> /etc/hosts
if grep -q "loki" /etc/hosts; then
echo " Loki exists in /etc/hosts, removing..."
sudo sed -i '/loki.monitoring.provider.test/d' /etc/hosts
fi
echo " Add Loki to /etc/hosts"
sudo echo "172.16.13.4 loki.monitoring.provider.test" >> /etc/hosts
if grep -q "promtail" /etc/hosts; then
echo " Promtail exists in /etc/hosts, removing..."
sudo sed -i '/promtail.monitoring.provider.test/d' /etc/hosts
fi
echo " Add Promtail to /etc/hosts"
sudo echo "172.16.13.5 promtail.monitoring.provider.test" >> /etc/hosts
if grep -q "grafana" /etc/hosts; then
echo " Grafana exists in /etc/hosts, removing..."
sudo sed -i '/grafana.monitoring.provider.test/d' /etc/hosts
fi
echo " Add Grafana to /etc/hosts"
sudo echo "172.16.13.6 grafana.monitoring.provider.test" >> /etc/hosts
if grep -q "vault" /etc/hosts; then
echo " Hashicorp Vault exists in /etc/hosts, removing..."
sudo sed -i '/vault.tooling.provider.test/d' /etc/hosts
fi
echo " Add Hashicorp Vault to /etc/hosts"
sudo echo "172.16.11.10 vault.tooling.provider.test" >> /etc/hosts
if grep -q "redis" /etc/hosts; then
echo " Redis exists in /etc/hosts, removing..."
sudo sed -i '/redis.tooling.provider.test/d' /etc/hosts
fi
echo " Add Redis to /etc/hosts"
sudo echo "172.16.11.11 redis.tooling.provider.test" >> /etc/hosts
if grep -q "netbox" /etc/hosts; then
echo " Netbox exists in /etc/hosts, removing..."
sudo sed -i '/netbox.tooling.provider.test/d' /etc/hosts
fi
echo " Add Netbox to /etc/hosts"
sudo echo "172.16.11.12 netbox.tooling.provider.test" >> /etc/hosts
if grep -q "cml" /etc/hosts; then
echo " Cisco Modeling Labs exists in /etc/hosts, removing..."
sudo sed -i '/cml.tooling.provider.test/d' /etc/hosts
fi
echo " Add Cisco Modeling Labs to /etc/hosts"
sudo echo "10.10.20.161 cml.tooling.provider.test" >> /etc/hosts
sudo chmod o-w /etc/hosts
echo " "
echo "****************************************************************************************************************"
echo " Collecting Nexus Keycloak plugin"
echo "****************************************************************************************************************"
if [ -f "nexus/nexus3-keycloak-plugin-$nexus_keycloak_plugin-bundle.kar" ]; then
echo " Nexus Keycloak plugin exists"
else
echo " Get Nexus Keycloak plugin"
wget --directory-prefix=nexus https://github.com/flytreeleft/nexus3-keycloak-plugin/releases/download/v$nexus_keycloak_plugin/nexus3-keycloak-plugin-$nexus_keycloak_plugin-bundle.kar
fi
echo " "
echo "****************************************************************************************************************"
echo " Collecting Nexus APK plugin and build .kar file"
echo "****************************************************************************************************************"
if [ -f "nexus/nexus-repository-apk-$nexus_apk_plugin-bundle.kar" ]; then
echo " Nexus apk plugin exists"
else
echo " Get Nexus apk plugin"
wget -O nexus/nexus-repository-apk-$nexus_apk_plugin-bundle.kar https://search.maven.org/remotecontent?filepath=org/sonatype/nexus/plugins/nexus-repository-apk/$nexus_apk_plugin/nexus-repository-apk-$nexus_apk_plugin-bundle.kar
fi
echo " "
echo "****************************************************************************************************************"
echo " git clone Nexus CasC plugin and build .kar file"
echo "****************************************************************************************************************"
if [ ! -f ./nexus/nexus-casc* ]; then
git clone https://github.com/AdaptiveConsulting/nexus-casc-plugin.git
cd nexus-casc-plugin
mvn package
cp target/*.kar ../nexus/
cd ..
rm -rf nexus-casc-plugin/
else
echo "Casc plugin exists, no need to build"
fi
echo " "
echo "****************************************************************************************************************"
echo " Creating CSR for all containers, so they can be copied in in the Dockerfile"
echo "****************************************************************************************************************"
freeipa/create-certificates.sh cicdtoolbox-db.internal
freeipa/create-certificates.sh keycloak.services
freeipa/create-certificates.sh argos.services
freeipa/create-certificates.sh argos-service.tooling
freeipa/create-certificates.sh mongodb.internal
freeipa/create-certificates.sh restportal.services
freeipa/create-certificates.sh portal.services
freeipa/create-certificates.sh gitea.tooling
freeipa/create-certificates.sh jenkins.tooling
freeipa/create-certificates.sh nexus.tooling
freeipa/create-certificates.sh build-dev.delivery
freeipa/create-certificates.sh build-test.delivery
freeipa/create-certificates.sh build-acc.delivery
freeipa/create-certificates.sh build-prod.delivery
freeipa/create-certificates.sh portainer.monitoring
freeipa/create-certificates.sh loki.monitoring
freeipa/create-certificates.sh promtail.monitoring
freeipa/create-certificates.sh grafana.monitoring
echo "****************************************************************************************************************"
echo " Creating freeIPA"
echo "****************************************************************************************************************"
docker-compose pull
docker-compose up -d --build --remove-orphans freeipa.iam.provider.test
echo "****************************************************************************************************************"
echo " Wait until FreeIPA has self-installed (~375 sec)"
echo "****************************************************************************************************************"
let t=0
until docker logs freeipa.iam.provider.test 2>&1 | grep "ipa-server-install command was successful"; do
spin
done
endspin
echo " "
echo "****************************************************************************************************************"
echo " Saving FreeIPA self-signed certificate"
echo "****************************************************************************************************************"
docker cp freeipa.iam.provider.test:/etc/ipa/ca.crt ca.crt
cp ca.crt argos/ca.crt
cp ca.crt jenkins/ca.crt
cp ca.crt gitea/ca.crt
cp ca.crt keycloak/ca.crt
cp ca.crt restportal/ca.crt
cp ca.crt nexus/ca.crt
cp ca.crt cicdtoolbox-db/ca.crt
cp ca.crt loki/ca.crt
cp ca.crt promtail/ca.crt
cp ca.crt grafana/ca.crt
cp ca.crt jenkins_buildnode/ca.crt
echo "****************************************************************************************************************"
echo " Copy csr files to FreeIPA for signing"
echo "****************************************************************************************************************"
docker cp freeipa/cert* freeipa.iam.provider.test:/tmp
echo "****************************************************************************************************************"
echo " Creating FreeIPA setup. This will take time..."
echo "****************************************************************************************************************"
docker exec -it freeipa.iam.provider.test sh -c "/root/freeipa-install.sh ${netcicd_pwd} ${freeipa_pwd}" | tee install_log/freeipa_create.log
echo " "
echo "****************************************************************************************************************"
echo " Saving host certificates"
echo "****************************************************************************************************************"
docker cp freeipa.iam.provider.test:/tmp/certs freeipa/
chmod 644 freeipa/certs/*
cp freeipa/certs/cicdtoolbox-db.internal.provider.test.key cicdtoolbox-db/docker-entrypoint-initdb-resources/server.key
cp freeipa/certs/cicdtoolbox-db.internal.provider.test.pem cicdtoolbox-db/docker-entrypoint-initdb-resources/server.crt
cp ca.crt cicdtoolbox-db/docker-entrypoint-initdb-resources/root.crt
cp freeipa/certs/gitea* gitea/
docker exec freeipa.iam.provider.test rm -rf /tmp/host*
echo " "
echo "****************************************************************************************************************"
echo " Creating database"
echo "****************************************************************************************************************"
DOCKER_BUILDKIT=1 docker-compose up -d --build cicdtoolbox-db.internal.provider.test
sleep 10
echo " "
echo "****************************************************************************************************************"
echo " Starting Keycloak "
echo "****************************************************************************************************************"
docker-compose up -d --build --no-deps keycloak.services.provider.test
echo "****************************************************************************************************************"
echo " Wait until keycloak is running (~45 sec.)"
echo "****************************************************************************************************************"
let t=0
until $(curl --output /dev/null --insecure --silent --head --fail https://keycloak.services.provider.test:8443); do
spin
done
endspin
echo " "
echo "****************************************************************************************************************"
echo " Creating keycloak setup. This will take time..."
echo "****************************************************************************************************************"
docker exec -it keycloak.services.provider.test sh -c "/opt/jboss/keycloak/bin/create-realm.sh ${keycloak_pwd} ${keycloak_storepass} ${freeipa_pwd} ${local_admin_user}" | tee install_log/keycloak_create.log
echo " "
docker restart keycloak.services.provider.test
echo "****************************************************************************************************************"
echo " Wait until keycloak is running (~5 sec.)"
echo "****************************************************************************************************************"
let t=0
until $(curl --output /dev/null --insecure --silent --head --fail https://keycloak.services.provider.test:8443); do
spin
done
endspin
echo " "
# echo "****************************************************************************************************************"
# echo " Creating Grafana Keycloak Client secret"
# echo "****************************************************************************************************************"
# export Grafana_CLIENT_SECRET=$(grep Grafana_token install_log/keycloak_create.log | cut -d' ' -f2 | tr -d '\r')
# echo $Grafana_CLIENT_SECRET
# echo "****************************************************************************************************************"
# echo " Copying Grafana certificates"
# echo "****************************************************************************************************************"
# cp freeipa/certs/grafana.monitoring.provider.test.key grafana/grafana.monitoring.provider.test.key
# cp freeipa/certs/grafana.monitoring.provider.test.pem grafana/grafana.monitoring.provider.test.pem
echo "****************************************************************************************************************"
echo " Creating keycloak-nexus json"
echo "****************************************************************************************************************"
docker cp keycloak.services.provider.test:/opt/jboss/keycloak/bin/keycloak-nexus.json nexus/keycloak-nexus.json
echo "****************************************************************************************************************"
echo " Booting the remainder of the containers"
echo "****************************************************************************************************************"
DOCKER_BUILDKIT=1 docker-compose up -d --build --no-deps gitea.tooling.provider.test
#docker-compose up -d --build --no-deps restportal.services.provider.test
docker-compose up -d --build --no-deps nexus.tooling.provider.test
echo "****************************************************************************************************************"
echo " Copying Jenkins certificates"
echo "****************************************************************************************************************"
cp freeipa/certs/jenkins.tooling.provider.test.key jenkins/jenkins.tooling.provider.test.key
cp freeipa/certs/jenkins.tooling.provider.test.pem jenkins/jenkins.tooling.provider.test.pem
echo " "
echo "****************************************************************************************************************"
echo " Starting Jenkins"
echo "****************************************************************************************************************"
jenkins/jenkins-install.sh ${jenkins_storepass}
echo " "
echo "****************************************************************************************************************"
echo " Creating gitea setup"
echo "****************************************************************************************************************"
gitea/gitea_install.sh ${netcicd_pwd} ${local_admin_user} | tee install_log/gitea_create.log
gitea/gitea_users.sh ${netcicd_pwd} ${local_admin_user} | tee install_log/gitea_users.log
echo " "
echo "****************************************************************************************************************"
echo " Creating nexus setup (~ 115 sec.)"
echo "****************************************************************************************************************"
openssl pkcs12 -export -in ./freeipa/certs/nexus.tooling.provider.test.pem -inkey ./freeipa/certs/nexus.tooling.provider.test.key -name nexus.tooling.provider.test -out ./nexus/nexus.p12 -password pass:${nexus_storepass}
chmod 644 ./nexus/nexus.p12
docker cp nexus/nexus.p12 nexus.tooling.provider.test:/nexus-data/etc/nexus.p12
docker exec --user root -it nexus.tooling.provider.test sh -c "/usr/bin/keytool -importkeystore -deststorepass ${nexus_storepass} -destkeystore /nexus-data/etc/ssl/keystore.jks -srckeystore /nexus-data/etc/nexus.p12 -srcstoretype PKCS12 -srcstorepass ${nexus_storepass} -deststoretype pkcs12"
echo "Reloading Nexus"
docker restart nexus.tooling.provider.test
let t=0
until $(curl --output /dev/null --insecure --silent --head --fail https://nexus.tooling.provider.test:8443); do
spin
done
endspin
# echo " "
# echo "****************************************************************************************************************"
# echo " Copying Jenkins Keystore to Argos node"
# echo "****************************************************************************************************************"
# cp ./jenkins/keystore/cacerts ./argos/cacerts
# cp ./jenkins/keystore/cacerts ./argos-service/cacerts
echo "Reloading "
docker restart jenkins.tooling.provider.test
let t=0
until $(curl --output /dev/null --insecure --silent --head --fail https://jenkins.tooling.provider.test:8084/whoAmI); do
spin
done
endspin
# echo " "
# echo "****************************************************************************************************************"
# echo " Creating Argos setup"
# echo "****************************************************************************************************************"
# argos_client_id=$(grep ARGOS_token install_log/keycloak_create.log | cut -d' ' -f2 | tr -d '\r' )
# sed -i -e "s/argos_secret/$argos_client_id/" argos/application.yml
# echo "****************************************************************************************************************"
# echo " Starting Argos"
# echo "****************************************************************************************************************"
# docker-compose up -d --build --no-deps mongodb.internal.provider.test
# docker-compose up -d --build --no-deps argos-service.tooling.provider.test
# docker-compose up -d --build --no-deps argos.services.provider.test
echo "****************************************************************************************************************"
echo " Preparing for finalizing install via ROBOT"
echo "****************************************************************************************************************"
sudo pip3 install robotframework robotframework-selenium2library
sudo cp geckodriver /usr/local/bin/
source ~/.bashrc
robot --variable VALID_PASSWORD:${netcicd_pwd} -d install_log finalize_install.robot
echo " "
# echo "****************************************************************************************************************"
# echo " Starting Loki, Promtail and Grafana..."
# echo "****************************************************************************************************************"
# docker-compose up -d --build --no-deps portainer.monitoring.provider.test
# docker-compose up -d --build --no-deps loki.monitoring.provider.test
# docker-compose up -d --build --no-deps promtail.monitoring.provider.test
# docker-compose up -d --build --no-deps grafana.monitoring.provider.test
# echo " "
echo "****************************************************************************************************************"
echo " Copying Jenkins Keystore to Jenkins buildnodes"
echo "****************************************************************************************************************"
cp ./jenkins/keystore/cacerts ./jenkins_buildnode/cacerts
echo " "
echo "****************************************************************************************************************"
echo " Retrieving Jenkins CSRF"
echo "****************************************************************************************************************"
jtoken=`cat jtoken.txt`
crumb=`curl -u "jenkins-jenkins:${jtoken}" --insecure 'https://jenkins.tooling.provider.test:8084/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'`
csrf=$( echo $crumb | awk -F',' '{print $(1)}' | awk -F':' '{print $2}' )
echo $csrf
#rm -f jtoken.txt
echo " "
echo "****************************************************************************************************************"
echo " Retrieving Jenkins Agent secrets"
echo "****************************************************************************************************************"
curl -L --insecure -u "jenkins-jenkins:${jtoken}" -H "Jenkins-Crumb:${csrf}" https://jenkins.tooling.provider.test:8084/computer/Dev/jenkins-agent.jnlp -s | sed "s/.*<jnlp><application-desc><argument>\([a-z0-9]*\).*/\1/" > ./jenkins_buildnode/Dev_secret
# curl -L --insecure -u "jenkins-jenkins:${jtoken}" -H "Jenkins-Crumb:${csrf}" https://jenkins.tooling.provider.test:8084/computer/Acc/jenkins-agent.jnlp -s | sed "s/.*<jnlp><application-desc><argument>\([a-z0-9]*\).*/\1/" > ./jenkins_buildnode/Acc_secret
# curl -L --insecure -u "jenkins-jenkins:${jtoken}" -H "Jenkins-Crumb:${csrf}" https://jenkins.tooling.provider.test:8084/computer/Test/jenkins-agent.jnlp -s | sed "s/.*<jnlp><application-desc><argument>\([a-z0-9]*\).*/\1/" > ./jenkins_buildnode/Test_secret
# curl -L --insecure -u "jenkins-jenkins:${jtoken}" -H "Jenkins-Crumb:${csrf}" https://jenkins.tooling.provider.test:8084/computer/Prod/jenkins-agent.jnlp -s | sed "s/.*<jnlp><application-desc><argument>\([a-z0-9]*\).*/\1/" > ./jenkins_buildnode/Prod_secret
echo "****************************************************************************************************************"
echo " Building Jenkins build nodes"
echo "****************************************************************************************************************"
docker-compose up -d --build --no-deps build-dev.delivery.provider.test
# docker-compose up -d --build --no-deps build-test.delivery.provider.test
# docker-compose up -d --build --no-deps build-acc.delivery.provider.test
# docker-compose up -d --build --no-deps build-prod.delivery.provider.test
# echo "****************************************************************************************************************"
# echo " Installing Hashicorp Vault"
# echo "****************************************************************************************************************"
# docker-compose up -d --build --no-deps vault.tooling.provider.test
# echo " " echo "****************************************************************************************************************"
# echo " Installing Netbox"
# echo "****************************************************************************************************************"
# docker-compose up -d --build --no-deps redis.tooling.provider.test
# docker-compose up -d --build --no-deps netbox.tooling.provider.test
# echo " "
echo "****************************************************************************************************************"
echo " Validating install"
echo "****************************************************************************************************************"
robot --variable VALID_PASSWORD:${netcicd_pwd} -d install_tests/ install_tests
echo " "
echo "****************************************************************************************************************"
echo " Running trivy vulnerability scanner (https://github.com/aquasecurity/trivy)"
echo "****************************************************************************************************************"
if command -v trivy &> /dev/null
then
echo "****************************************************************************************************************"
echo " Toolbox files"
echo "****************************************************************************************************************"
trivy fs --security-checks vuln,config . | tee install_log/trivy_create.log
echo "****************************************************************************************************************"
echo " FreeIPA"
echo "****************************************************************************************************************"
# trivy image freeipa/freeipa-server:centos-8-stream | tee -a install_log/trivy_create.log
echo "****************************************************************************************************************"
echo " Gitea"
echo "****************************************************************************************************************"
# trivy image gitea/gitea:rootless | tee -a install_log/trivy_create.log
echo "****************************************************************************************************************"
echo " Jenkins"
echo "****************************************************************************************************************"
# trivy image jenkins/jenkins:lts | tee -a install_log/trivy_create.log
echo "****************************************************************************************************************"
echo " Keycloak"
echo "****************************************************************************************************************"
# trivy image jboss/keycloak:latest | tee -a install_log/trivy_create.log
echo "****************************************************************************************************************"
echo " PostgreSQL"
echo "****************************************************************************************************************"
# trivy image postgres:latest | tee -a install_log/trivy_create.log
echo "****************************************************************************************************************"
echo " Nexus"
echo "****************************************************************************************************************"
# trivy image sonatype/nexus3:latest | tee -a install_log/trivy_create.log
echo "****************************************************************************************************************"
echo " Portainer"
echo "****************************************************************************************************************"
# trivy image portainer/portainer-ce | tee -a install_log/trivy_create.log
else
echo "trivy is not installed"
fi
echo "****************************************************************************************************************"
echo " building images "
echo "****************************************************************************************************************"
docker container commit freeipa.iam.provider.test netarch/cicdtoolbox:freeipa-$VERSION
docker push netarch/cicdtoolbox:freeipa-$VERSION
echo " "
docker container commit cicdtoolbox-db.internal.provider.test netarch/cicdtoolbox:cicdtoolbox-db-$VERSION
docker push netarch/cicdtoolbox:cicdtoolbox-db-$VERSION
echo " "
docker container commit keycloak.services.provider.test netarch/cicdtoolbox:keycloak-$VERSION
docker push netarch/cicdtoolbox:keycloak-$VERSION
# echo " "
# docker container commit argos.services.provider.test netarch/cicdtoolbox:argos-$VERSION
# docker push netarch/cicdtoolbox:argos-$VERSION
# echo " "
# docker container commit argos-service.tooling.provider.test netarch/cicdtoolbox:argos-service-$VERSION
# docker push netarch/cicdtoolbox:argos-service-$VERSION
# echo " "
# docker container commit mongodb.internal.provider.test netarch/cicdtoolbox:mongo-$VERSION
# docker push netarch/cicdtoolbox:mongo-$VERSION
# echo " "
# docker container commit restportal.services.provider.test netarch/cicdtoolbox:restportal-$VERSION
# docker push netarch/cicdtoolbox:restportal-$VERSION
echo " "
docker container commit gitea.tooling.provider.test netarch/cicdtoolbox:gitea-$VERSION
docker push netarch/cicdtoolbox:gitea-$VERSION
echo " "
docker container commit jenkins.tooling.provider.test netarch/cicdtoolbox:jenkins-$VERSION
docker push netarch/cicdtoolbox:jenkins-$VERSION
echo " "
docker container commit nexus.tooling.provider.test netarch/cicdtoolbox:nexus-$VERSION
docker push netarch/cicdtoolbox:nexus-$VERSION
echo " "
docker container commit build-dev.delivery.provider.test netarch/cicdtoolbox:build-dev-$VERSION
docker push netarch/cicdtoolbox:build-dev-$VERSION
echo " "
docker container commit cicdtoolbox-db.internal.provider.test netarch/cicdtoolbox:cicdtoolbox-db-$VERSION
docker push netarch/cicdtoolbox:cicdtoolbox-db-$VERSION
echo " "
docker container commit cicdtoolbox-db.internal.provider.test netarch/cicdtoolbox:cicdtoolbox-db-$VERSION
docker push netarch/cicdtoolbox:cicdtoolbox-db-$VERSION
echo " "
docker container commit cicdtoolbox-db.internal.provider.test netarch/cicdtoolbox:cicdtoolbox-db-$VERSION
docker push netarch/cicdtoolbox:cicdtoolbox-db-$VERSION
echo " "
echo "NetCICD Toolkit install done "
echo " "
echo "You can read the install test report in install_tests/report.html"
echo " "
echo "You can reach the servers on:"
echo " "
echo " FreeIPA: https://freeipa.iam.provider.test"
echo " Keycloak: https://keycloak.services.provider.test:8443"
echo " Gitea: https://gitea.tooling.provider.test:3000"
echo " Jenkins: https://jenkins.tooling.provider.test:8084"
echo " Nexus: https://nexus.tooling.provider.test:8081"
# echo " Portainer: http://portainer.monitoring.provider.test:9000"
# echo " Loki: http://loki.monitoring.provider.test:9000"
# echo " Grafana: http://grafana.monitoring.provider.test:9000"
# echo " Vault: http://vault.tooling.provider.test:8200"
# echo " Netbox: http://netbox.tooling.provider.test:8000"
echo " "
echo "****************************************************************************************************************"
echo "Cleaning up"
echo "****************************************************************************************************************"