-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
1514 lines (1475 loc) · 67.6 KB
/
.gitlab-ci.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
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
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
stages:
- pages
- documentation
- build
- install-kickoff
- install-check
- install-snapshot
- templates-build
- templates-check
- templates-snapshot
- client
- range-admin-deploy
- range-admin-check
- range-admin-snapshot
- post-deploy-admin-testing
- post-deploy-admin-power
- post-deploy-admin-ansible
- post-deploy-admin-user
- post-deploy-admin-templates
- range-user-deploy
- range-user-check
- range-user-snapshot
- post-deploy-user-testing
- post-deploy-user-power
- post-deploy-user-ansible
- post-deploy-user-user
- post-deploy-user-templates
- integration
- manual
- upload
- release
################
# YAML ANCHORS #
################
# This is a Yaml script anchor to do all the standard setup to prepare fo CI tasks - update the server and load the CI user API key
.common-setup: &common-setup
# Sync time in the event this test is being run after a snapshot rollback
- sudo /usr/sbin/chronyd -q 'pool pool.ntp.org iburst' || sudo /usr/bin/chronyc -m 'burst 3/3' 'makestep 0.5 -1'
- date
- cd binaries
# Update the server to make sure we are running the latest version if a packer or ansible build is not running
- pgrep -f 'ansible|packer' || sudo ./ludus-server --update
# Move the latest client to /usr/local/bin for clean commands
- sudo cp -f ludus-client_linux-amd64 /usr/local/bin/ludus
- cd ..
# Set the config to use the "user" API by default
- mkdir -p ~/.config/ludus/
- 'echo "url: https://127.0.0.1:8080" > ~/.config/ludus/config.yml'
# Start as the ROOT user
- export LUDUS_API_KEY=$(sudo cat /opt/ludus/install/root-api-key)
.powered-on-and-not-in-testing: &powered-on-and-not-in-testing
# Start from a known state (in the event this is a retry)
# Power on all VMs if we are not in a "user" test as admin (admin VMs are powered off for user tests to save resources)
- |
if [[ ! ($(ludus range list --json | jq "all(.VMs[].poweredOn; . == true)") == "true") && ("$CI_JOB_NAME" != *"-user"* && "$LUDUS_USER_ID" != "CIU") ]]; then
echo "Not all VMs are powered on, powering on now"
ludus power on -n all
timeout 180 bash -c 'until [[ $(ludus range list --json | jq "all(.VMs[].poweredOn; . == true)") == "true" ]]; do sleep 5; done'
fi
# Exit testing mode if we failed mid-testing mode and this is a retry
- if [[ "$(ludus testing status --json | jq '.testingEnabled')" == "true" ]]; then echo "Tested mode was on, stopping it now"; ludus testing stop; fi
.ci-setup-admin: &ci-setup-admin
- *common-setup
# Add the CIA user if it doesn't already exist, try 5 times since the server just restarted the first might fail
- for i in {1..5}; do (ludus --url https://127.0.0.1:8081 users list all | grep -q 'Continuous Integration Admin' || ludus --url https://127.0.0.1:8081 users add -a -n "Continuous Integration Admin" -i CIA) && break || sleep 5; done
# Switch to CIA user API Key - only request it once, save it to disk
- if [ ! -f /opt/ludus/ci/.apikey-admin ]; then ludus --url https://127.0.0.1:8081 --json --user CIA users apikey --no-prompt | jq -r '.result.apiKey' > /opt/ludus/ci/.apikey-admin; fi
# Set the CIA user key as the key for all future ludus operations
- export LUDUS_API_KEY=$(cat /opt/ludus/ci/.apikey-admin)
- export LUDUS_USER_ID=$(ludus user list --json | jq -r '.[].userID')
- *powered-on-and-not-in-testing
# Set the config to simple-domain.yml if all templates are built
- if [ $(ludus templates list --json | jq '[.[] | select(.built == false)] | length' || echo 1) -eq 0 ]; then ludus range config set -f ludus-server/ci/configs/simple-domain.yml; fi
.ci-setup-user: &ci-setup-user
- *common-setup
# Add the CIU user if it doesn't already exist, try 5 times since the server just restarted the first might fail
- for i in {1..5}; do (ludus --url https://127.0.0.1:8081 users list all | grep -q 'Continuous Integration User' || ludus --url https://127.0.0.1:8081 users add -n "Continuous Integration User" -i CIU) && break || sleep 5; done
# Switch to CIU user API Key - only request it once, save it to disk
- if [ ! -f /opt/ludus/ci/.apikey-user ]; then ludus --url https://127.0.0.1:8081 --json --user CIU users apikey --no-prompt | jq -r '.result.apiKey' > /opt/ludus/ci/.apikey-user; fi
# Set the CIU user key as the key for all future ludus operations
- export LUDUS_API_KEY=$(cat /opt/ludus/ci/.apikey-user)
- export LUDUS_USER_ID=$(ludus user list --json | jq -r '.[].userID')
- *powered-on-and-not-in-testing
# Set the config to simple-domain.yml
- ludus range config set -f ludus-server/ci/configs/simple-domain.yml
.ansible-tests: &ansible-tests
# Add and remove a role
- ludus ansible role list
- ludus ansible role rm geerlingguy.docker || true
- ludus ansible role add geerlingguy.docker
- ludus ansible role list | grep geerlingguy.docker
- ludus ansible role rm geerlingguy.docker
- '! ludus ansible role list | grep geerlingguy.docker'
# Install a specific version
- ludus ansible role add geerlingguy.docker --version 7.0.1
- ludus ansible role list | grep geerlingguy.docker | grep 7.0.1
# Test the force install
- set +o pipefail # We expect the first command in the next line to fail, so allow it so long as the grep succeeds
- ludus ansible role add geerlingguy.docker 2>&1 | grep 'geerlingguy.docker (7.0.1) is already installed'
- set -o pipefail
- ludus ansible role add geerlingguy.docker --force
- ludus ansible role list | grep geerlingguy.docker
- '! ludus ansible role list | grep geerlingguy.docker | grep 7.0.1'
# Test collections
- ludus ansible collection list
- ludus ansible collection add maxhoesel.smallstep || true
- ludus ansible collection list | grep maxhoesel.smallstep
# Force install a collection
- ludus ansible collection add maxhoesel.smallstep --version 0.24.4 --force
- ludus ansible collection list | grep maxhoesel.smallstep | grep 0.24.4
# Depends on tests
- ludus ansible role add -d ludus-server/ci/roles/hello_world --force
- ludus range config set -f ludus-server/ci/configs/depends-on.yml
- ludus range deploy -t user-defined-roles
- while [ "$(ludus range list --json | jq -r '.rangeState')" != "SUCCESS" ]; do ludus range logs --tail 20; sleep 60; done
# Depends on - dependency that doesn't exist test
- set +o pipefail # We expect the first command in the next line to fail, so allow it so long as the grep succeeds
- 'ludus range config set -f ludus-server/ci/configs/depends-on-not-found.yml 2>&1 | egrep "ERROR: Dependency not found \w+-ad-dc-win2022-server-x64-1:geerlingguy.docker"'
# Depends on circular dependency test
- 'ludus range config set -f ludus-server/ci/configs/depends-on-circular.yml 2>&1 | egrep "ERROR: Circular dependency found for \w+-ad-win11-22h2-enterprise-x64-1:geerlingguy.docker"'
.testing-mode-tests: &testing-mode-tests
- export WIN11VMID=$(sudo qm list | grep running | grep win11 | head -1 | awk '{print $1}') # TODO use the API
- ludus testing status
# Validate that WIN10 can reach the internet
- "sudo qm guest exec $WIN11VMID -- ping -n 1 8.8.8.8 | grep 'Reply from 8.8.8.8: bytes=32'"
- sudo qm guest exec $WIN11VMID -- curl https://google.com/ | grep 'HTML'
- ludus testing start
- ludus testing status
- ludus range list
# Validate that WIN10 cannot reach the internet
- sudo qm guest exec $WIN11VMID -- ping -n 1 8.8.8.8 | egrep 'Request timed out.|Destination port unreachable.'
# Sometimes the DNS lookup is cached from the test above, so test for a DNS failure or a connect failure
- sudo qm guest exec $WIN11VMID -- curl https://google.com/ | egrep 'Could not resolve host|Failed to connect to google.com'
- ludus testing allow -i 8.8.8.8
- ludus testing status
# Validate that WIN10 can get to 8.8.8.8 but not 1.1.1.1
- "sudo qm guest exec $WIN11VMID -- ping -n 1 8.8.8.8 | grep 'Reply from 8.8.8.8: bytes=32'"
- sudo qm guest exec $WIN11VMID -- ping -n 1 1.1.1.1 | egrep 'Request timed out.|Destination port unreachable.'
# Allow google.com and check that google is allowed but example isn't
- ludus testing allow -d google.com
- ludus testing status
# This sometimes takes a few seconds - try 3 times 5 seconds apart
- for i in {1..3}; do (sudo qm guest exec $WIN11VMID -- curl https://google.com/ | grep 'HTML') && break || sleep 5; done
- sudo qm guest exec $WIN11VMID -- curl https://example.com/ | egrep 'Could not resolve host|Failed to connect to example.com'
# Deny google.com and 8.8.8.8 and check that they are not reachable
- ludus testing deny -d google.com
- ludus testing deny -i 8.8.8.8
- for i in {1..3}; do (sudo qm guest exec $WIN11VMID -- curl https://google.com/ | egrep 'Could not resolve host|Failed to connect to google.com') && break || sleep 5; done
- for i in {1..3}; do (sudo qm guest exec $WIN11VMID -- ping -n 1 8.8.8.8 | egrep 'Request timed out.|Destination port unreachable.') && break || sleep 5; done
- ludus testing stop
- ludus testing status
# Now that testing has stopped, check the VM can reach the internet
- "sudo qm guest exec $WIN11VMID -- ping -n 1 8.8.8.8 | grep 'Reply from 8.8.8.8: bytes=32'"
- sudo qm guest exec $WIN11VMID -- curl https://google.com/ | grep 'HTML'
.power-tests: &power-tests
# Power on/off tests - single VM
- ludus power off -n ${LUDUS_USER_ID}-kali
- timeout 60 bash -c 'until [[ $(ludus range list --json | jq ".VMs[] | select(.name == \"${LUDUS_USER_ID}-kali\").poweredOn") == "false" ]]; do echo "Waiting for ${LUDUS_USER_ID}-kali to power off"; sleep 5; done'
- ludus range status | grep "${LUDUS_USER_ID}-kali" | grep 'Off'
- ludus range status | grep "${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1" | grep 'On'
- ludus range status | grep "${LUDUS_USER_ID}-ad-dc-win2022-server-x64" | grep 'On'
- ludus power on -n ${LUDUS_USER_ID}-kali
- timeout 60 bash -c 'until [[ $(ludus range list --json | jq ".VMs[] | select(.name == \"${LUDUS_USER_ID}-kali\").poweredOn") == "true" ]]; do echo "Waiting for ${LUDUS_USER_ID}-kali to power on"; sleep 5; done'
- ludus range status | grep "${LUDUS_USER_ID}-kali" | grep 'On'
- ludus range status | grep "${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1" | grep 'On'
- ludus range status | grep "${LUDUS_USER_ID}-ad-dc-win2022-server-x64" | grep 'On'
# Power on/off tests - comma separated
- ludus power off -n ${LUDUS_USER_ID}-kali,${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1
- timeout 120 bash -c 'until [[ $(ludus range list --json | jq "[.VMs[] | select(.name == \"${LUDUS_USER_ID}-kali\" or .name == \"${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1\").poweredOn] | all(.[]; . == false)") == "true" ]]; do echo "Waiting for ${LUDUS_USER_ID}-kali and ${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1 to power off"; sleep 5; done'
- ludus range status | grep "${LUDUS_USER_ID}-kali" | grep 'Off'
- ludus range status | grep "${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1" | grep 'Off'
- ludus range status | grep "${LUDUS_USER_ID}-ad-dc-win2022-server-x64" | grep 'On'
- ludus power on -n ${LUDUS_USER_ID}-kali,${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1
- timeout 120 bash -c 'until [[ $(ludus range list --json | jq "[.VMs[] | select(.name == \"${LUDUS_USER_ID}-kali\" or .name == \"${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1\").poweredOn] | all(.[]; . == true)") == "true" ]]; do echo "Waiting for ${LUDUS_USER_ID}-kali and ${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1 to power on"; sleep 5; done'
- ludus range status | grep "${LUDUS_USER_ID}-kali" | grep 'On'
- ludus range status | grep "${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1" | grep 'On'
- ludus range status | grep "${LUDUS_USER_ID}-ad-dc-win2022-server-x64" | grep 'On'
# Power on/off tests - "all"
- ludus power off -n all
- timeout 180 bash -c 'until [[ $(ludus range list --json | jq "all(.VMs[].poweredOn; . == false)") == "true" ]]; do sleep 5; done'
- ludus range status | grep "${LUDUS_USER_ID}-kali" | grep 'Off'
- ludus range status | grep "${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1" | grep 'Off'
- ludus range status | grep "${LUDUS_USER_ID}-ad-dc-win2022-server-x64" | grep 'Off'
- ludus range status | grep "${LUDUS_USER_ID}-router-debian11-x64" | grep 'Off'
- ludus power on -n all
- timeout 180 bash -c 'until [[ $(ludus range list --json | jq "all(.VMs[].poweredOn; . == true)") == "true" ]]; do sleep 5; done'
- ludus range status | grep "${LUDUS_USER_ID}-kali" | grep 'On'
- ludus range status | grep "${LUDUS_USER_ID}-ad-win11-22h2-enterprise-x64-1" | grep 'On'
- ludus range status | grep "${LUDUS_USER_ID}-ad-dc-win2022-server-x64" | grep 'On'
- ludus range status | grep "${LUDUS_USER_ID}-router-debian11-x64" | grep 'On'
.template-tests: &template-tests
# Remove debian 10 if it exists (retry)
- ludus templates list --json | jq -r '.[] | select(.name == "debian-10-x64-server-template") | .name' | grep -q 'debian-10-x64-server-template' && ludus templates rm -n "debian-10-x64-server-template" || echo "No debian10 on the server"
- cd templates
- ludus templates list
- ludus templates add -d debian10
- ludus templates list
- set +o pipefail
- ludus templates add -d debian10 2>&1 | grep 'Template already exists, use --force to overwrite it'
- mkdir /tmp/test-template || true
- echo "debian-10-x64-server-template" > /tmp/test-template/test.pkr.hcl
- 'ludus templates add -d /tmp/test-template/test.pkr.hcl 2>&1 | grep "Error finding .pkr.hcl or .pkr.json template files: the provided path is not a directory"'
- ludus templates add -d /tmp/test-template 2>&1 | grep "The uploaded template name is already present on the server. Template names must be unique."
- ludus templates add -d ../ludus-server/packer/kali 2>&1 | grep "The uploaded template name is already present on the server. Template names must be unique."
- ludus templates add -d ../ludus-server/packer/kali --force 2>&1 | grep "'kali-x64-desktop-template' is a template that does not belong to you"
- set -o pipefail
- ludus templates add -d debian10 --force
- ludus templates list
- ludus templates build -n debian-10-x64-server-template
- ludus templates status
- ludus templates status | grep debian-10-x64-server-template
- ludus templates status | grep continuous-integration-
# Wait for the template to build
- while [ $(ludus templates list --json | jq '[.[] | select(.built == false)] | length' || echo 1) -ne 0 ]; do date; sleep 60; done
- ludus templates logs
- ludus templates list
- ludus templates rm -n debian-10-x64-server-template
- '! ludus templates list | grep "debian-10-x64-server-template"'
#################
# DOCUMENTATION #
#################
pages:
stage: pages
variables:
LUDUS_BUILD_TYPE: any-built
tags:
- ludus-proxmox-runner
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_MESSAGE =~ /\[build pages\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip build\]/
when: never
- if: $CI_COMMIT_BRANCH == "main" # Only update public docs in the main branch
changes:
- "docs/**/*"
retry:
max: 2
script:
- cd docs
# Change the base URL as we are hosting the site straight off the root of the domain
- "sed -i \"s|baseUrl: '/ludus/'|baseUrl: '/'|\" docusaurus.config.js"
- yarn install
- yarn build
- rm -f ./build/video/*
- mv ./build ../public
artifacts:
paths:
- public
documentation:
stage: documentation
variables:
LUDUS_BUILD_TYPE: any-built
tags:
- ludus-proxmox-runner
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_MESSAGE =~ /\[build docs\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip build\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at / # Any "start-at" will skip the doc build to speed up CI
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- changes:
- "docs/**/*"
retry:
max: 2
script:
- cd docs
- yarn install
- yarn build
- rm -f ./build/video/*
- rm -f ./build/img/hardware/Debian_12_RAID0.mp4
- mv ./build ../built-docs
artifacts:
paths:
- built-docs
#########
# BUILD #
#########
build all:
stage: build
tags:
- ludus-proxmox-runner
dependencies:
- documentation
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_MESSAGE =~ /\[skip build\]/
when: never
- changes:
- "**/*"
artifacts:
paths:
- binaries/*
expire_in: 1 week
variables:
LUDUS_BUILD_TYPE: any-built # we are just building go code, use any CI VM
timeout: 10m
script:
- echo "Compiling the server code..."
- export GIT_COMMIT_SHORT_HASH=$(git rev-parse --short HEAD)
- if [[ -n $CI_COMMIT_TAG ]]; then export VERSION=$CI_COMMIT_TAG; else export VERSION=${CI_COMMIT_BRANCH}; fi
- mkdir binaries
- cd ludus-server
- | # If we have docs from the previous stage, embed them, otherwise build without docs
if [[ -d ../built-docs ]]; then
mv ../built-docs ../ludus-api/docs
CGO_ENABLED=1 go build -trimpath -ldflags "-s -w -X main.GitCommitHash=$GIT_COMMIT_SHORT_HASH -X main.VersionString=$VERSION" -tags=embeddocs -o ../binaries/ludus-server
else
CGO_ENABLED=1 go build -trimpath -ldflags "-s -w -X main.GitCommitHash=$GIT_COMMIT_SHORT_HASH -X main.VersionString=$VERSION" -o ../binaries/ludus-server
fi
- cd ..
- echo "Compiling the client code..."
- cd ludus-client
# Use the fork that doesn't break the terminal on control+c for Linux and macOS
- git clone https://github.com/zimeg/spinner
- cd spinner && git checkout unhide-interrupts && cd .. && go mod edit -replace github.com/briandowns/spinner=./spinner
- CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X ludus/cmd.GitCommitHash=$GIT_COMMIT_SHORT_HASH -X ludus/cmd.VersionString=$VERSION" -o ../binaries/ludus-client_linux-amd64
- CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags "-s -w -X ludus/cmd.GitCommitHash=$GIT_COMMIT_SHORT_HASH -X ludus/cmd.VersionString=$VERSION" -o ../binaries/ludus-client_linux-arm64
- CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -trimpath -ldflags "-s -w -X ludus/cmd.GitCommitHash=$GIT_COMMIT_SHORT_HASH -X ludus/cmd.VersionString=$VERSION" -o ../binaries/ludus-client_linux-arm
- CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags "-s -w -X ludus/cmd.GitCommitHash=$GIT_COMMIT_SHORT_HASH -X ludus/cmd.VersionString=$VERSION" -o ../binaries/ludus-client_macOS-amd64
- CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags "-s -w -X ludus/cmd.GitCommitHash=$GIT_COMMIT_SHORT_HASH -X ludus/cmd.VersionString=$VERSION" -o ../binaries/ludus-client_macOS-arm64
# The forked spinner library doesn't compile for windows, so switch back to the original
- go mod edit -dropreplace=github.com/briandowns/spinner
- CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath -ldflags "-s -w -X ludus/cmd.GitCommitHash=$GIT_COMMIT_SHORT_HASH -X ludus/cmd.VersionString=$VERSION" -o ../binaries/ludus-client_windows-amd64.exe
- CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -trimpath -ldflags "-s -w -X ludus/cmd.GitCommitHash=$GIT_COMMIT_SHORT_HASH -X ludus/cmd.VersionString=$VERSION" -o ../binaries/ludus-client_windows-386.exe
- CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -trimpath -ldflags "-s -w -X ludus/cmd.GitCommitHash=$GIT_COMMIT_SHORT_HASH -X ludus/cmd.VersionString=$VERSION" -o ../binaries/ludus-client_windows-arm64.exe
- cd ..
# If this is a release, build the enterprise plugin at the same time on the same build machine so the binaries are compatible
- |
if [[ ! -z ${CI_COMMIT_TAG+x} ]]; then
git clone https://ludus-enterprise:${LUDUS_ENTERPRISE_GITLAB_TOKEN}@gitlab.com/badsectorlabs/ludus-enterprise-plugin.git
go work use ./ludus-enterprise-plugin
cd ludus-enterprise-plugin
git config --global --add safe.directory $PWD
GIT_COMMIT_SHORT_HASH=$(git rev-parse --short HEAD)
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildmode=plugin -trimpath -ldflags "-s -w -X main.GitCommitHash=${GIT_COMMIT_SHORT_HASH} -X main.VersionString=${CI_COMMIT_TAG}" -tags=embeddocs -o ../binaries/ludus-enterprise.so
fi
- echo "Compile complete."
###########
# INSTALL #
###########
install kickoff:
stage: install-kickoff
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at / # Any "start-at" will skip the install
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes: # Only run if we need to test installer related changes
- ludus-server/*.go
- ludus-server/ansible/proxmox-install/**/*
variables:
LUDUS_BUILD_TYPE: full # We have to test the install process, so do a full build
LUDUS_INSTALL_STEP: kickoff
timeout: 10m
script:
- sudo hostname ludus-$CI_PIPELINE_ID
- sudo hostnamectl set-hostname ludus-$CI_PIPELINE_ID
- cd binaries
- sudo ./ludus-server --no-prompt ludus-$CI_PIPELINE_ID # This causes a reboot, handle it in the run.sh ci script
install check:
stage: install-check
tags:
- ludus-proxmox-runner
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at / # Any "start-at" will skip the install
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes: # Only run if we need to test installer related changes
- ludus-server/*.go
- ludus-server/ansible/proxmox-install/**/*
variables:
LUDUS_BUILD_TYPE: full
LUDUS_INSTALL_STEP: check
timeout: 1h
script:
- sudo cat /opt/ludus/install/install.log
- echo "root:$CI_PIPELINE_ID" | sudo chpasswd # allow root login via the web interface for debugging
install snapshot:
stage: install-snapshot
tags:
- ludus-proxmox-runner
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at / # Any "start-at" will skip the install
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes: # Only run if we need to test installer related changes
- ludus-server/*.go
- ludus-server/ansible/proxmox-install/**/*
variables:
LUDUS_BUILD_TYPE: full
LUDUS_INSTALL_STEP: take-snapshot # The magic happens in prepare.sh
LUDUS_SNAPSHOT_NAME: clean_install
timeout: 5m
script:
- echo "Snapshot complete"
#############
# TEMPLATES #
#############
templates build:
stage: templates-build
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[template tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-server/packer/**/*
variables:
LUDUS_BUILD_TYPE: from-snapshot
LUDUS_SNAPSHOT_NAME: clean_install
timeout: 5m
script:
- *ci-setup-admin
# Build in parallel to speed up CI
- ludus templates build --parallel 6
templates check:
stage: templates-check
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[template tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-server/packer/**/*
variables:
LUDUS_BUILD_TYPE: from-snapshot
LUDUS_SNAPSHOT_NAME: clean_install
timeout: 2h
retry:
max: 2
script:
- *ci-setup-admin
# If there is no template building process, start one
# This may happen on a failed ISO upload
- pgrep -f 'packer' || ludus templates build
# Wait for all templates to build
- while [ $(ludus templates list --json | jq '[.[] | select(.built == false)] | length' || echo 1) -ne 0 ]; do date; sleep 60; done
- ludus templates list
templates snapshot:
stage: templates-snapshot
tags:
- ludus-proxmox-runner
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[template tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-server/packer/**/*
variables:
LUDUS_INSTALL_STEP: take-snapshot
LUDUS_SNAPSHOT_NAME: templates_built
timeout: 5m
script:
- echo "Snapshot complete"
##########
# CLIENT #
##########
client basic-commands:
stage: client
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[client tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-client/**/*.go
- ludus-server/ansible/range-management/**/*
- ludus-server/ansible/user-management/**/*
- ludus-server/ansible/user-files/**/*
variables:
LUDUS_BUILD_TYPE: from-snapshot
LUDUS_SNAPSHOT_NAME: clean_install
timeout: 5m
script:
- *ci-setup-admin
- ludus version
- ludus version --verbose
- ludus users creds get
- ludus users wireguard
- ludus range list all
- ludus range list
- ludus range config get
- ludus templates list
- ludus testing status
- ludus range gettags
#################
# RANGE - ADMIN #
#################
range deploy-admin:
stage: range-admin-deploy
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[range tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-client/cmd/range.go
- ludus-server/ansible/range-management/**/*
- ludus-server/ansible/user-management/**/*
variables:
LUDUS_BUILD_TYPE: from-snapshot
LUDUS_SNAPSHOT_NAME: templates_built
timeout: 5m
retry:
max: 2
when:
- script_failure
- job_execution_timeout
script:
- *ci-setup-admin
- ludus range config get
- ludus range deploy
range check-admin:
stage: range-admin-check
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[range tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-server/ansible/range-management/**/*
variables:
LUDUS_BUILD_TYPE: from-snapshot
LUDUS_SNAPSHOT_NAME: templates_built
timeout: 3h
retry:
max: 2
when: script_failure
script:
- *ci-setup-admin
- while [ "$(ludus range list --json | jq -r '.rangeState')" != "SUCCESS" ]; do ludus range logs --tail 20; sleep 60; done
- ludus range logs
- ludus range list
- "[ \"$(ludus range list --json | jq -r '.rangeState')\" = \"SUCCESS\" ]"
range snapshot-admin:
stage: range-admin-snapshot
tags:
- ludus-proxmox-runner
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[range tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-server/ansible/range-management/**/*
variables:
LUDUS_INSTALL_STEP: take-snapshot
LUDUS_SNAPSHOT_NAME: range_built_admin
timeout: 5m
retry:
max: 2
when: script_failure
script:
- echo "Snapshot complete"
#######################
# POST-DEPLOY - ADMIN #
#######################
post-deploy testing-as-admin:
stage: post-deploy-admin-testing
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[post-deploy tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[testing-mode tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-client/cmd/testing.go
- ludus-server/ansible/range-management/**/*
variables:
LUDUS_BUILD_TYPE: from-snapshot
LUDUS_SNAPSHOT_NAME: range_built_admin
timeout: 15m
retry:
max: 2
when: script_failure
script:
- *ci-setup-admin
- *testing-mode-tests
post-deploy power-as-admin:
stage: post-deploy-admin-power
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[post-deploy tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[power tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-client/cmd/power.go
- ludus-server/ansible/range-management/power.yml
- ludus-server/ansible/range-management/pre-run-checks.yml
- ludus-server/ansible/range-management/tasks/proxmox/set-vm-state.yml
variables:
LUDUS_BUILD_TYPE: from-snapshot
LUDUS_SNAPSHOT_NAME: range_built_admin
timeout: 15m
retry:
max: 2
when: script_failure
script:
- *ci-setup-admin
- *power-tests
post-deploy ansible-as-admin:
stage: post-deploy-admin-ansible
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[post-deploy tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[ansible tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-client/cmd/ansible.go
- ludus-server/src/ansible.go
- ludus-server/src/api_ansible.go
variables:
LUDUS_BUILD_TYPE: from-snapshot
LUDUS_SNAPSHOT_NAME: range_built_admin
timeout: 15m
retry:
max: 2
when: script_failure
script:
- *ci-setup-admin
- *ansible-tests
post-deploy user-cmds-as-admin:
stage: post-deploy-admin-user
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[post-deploy tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[user tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-client/cmd/user.go
- ludus-server/src/api_user_management.go
- ludus-server/ansible/user-management/**/*
variables:
LUDUS_BUILD_TYPE: from-snapshot
LUDUS_SNAPSHOT_NAME: range_built_admin
timeout: 15m
retry:
max: 2
when: script_failure
script:
- *ci-setup-admin
# Add an admin user
- set +o pipefail # We expect the first command in the next line to fail, so allow it so long as the grep succeeds
- ludus user add -a -n "Test Admin" -i TA 2>&1 | grep "You must use the ludus-admin server on 127.0.0.1:8081 to use this endpoint"
- set -o pipefail
- ludus --url https://127.0.0.1:8081 user add -a -n "Test Admin" -i TA
- ludus users list all | grep "Test Admin"
# Try to create a user with the same ID or name
- set +o pipefail # We expect the first command in the next line to fail, so allow it so long as the grep succeeds
- ludus --url https://127.0.0.1:8081 user add -n "Test Admin" -i TA2 2>&1 | grep "User with that name already exists"
- ludus --url https://127.0.0.1:8081 user add -n "Test Admin 2" -i TA 2>&1 | grep "User with that ID already exists"
- set -o pipefail
# Get and set creds
- ludus user creds get --user TA
- ludus user creds set -i TA -p test-password-123
- ludus user creds get --user TA | grep test-password-123
# Get wireguard
- ludus user wireguard --user TA | grep Endpoint
# Remove admin user
- set +o pipefail # We expect the first command in the next line to fail, so allow it so long as the grep succeeds
- ludus user rm -i TA 2>&1 | grep "You must use the ludus-admin server on 127.0.0.1:8081 to use this endpoint"
- set -o pipefail
- ludus --url https://127.0.0.1:8081 user rm -i TA
- '! ludus users list all | grep "Test Admin"'
# Add a normal user
- ludus --url https://127.0.0.1:8081 user add -n "Test User" -i TU
- ludus users list all | grep "Test User"
# Get and set creds
- ludus user creds get --user TU
- ludus user creds set -i TU -p test-password-123
- ludus user creds get --user TU | grep test-password-123
# Get wireguard
- ludus user wireguard --user TU | grep Endpoint
# Remove normal user
- ludus --url https://127.0.0.1:8081 user rm -i TU
- '! ludus users list all | grep "Test User"'
post-deploy templates-as-admin:
stage: post-deploy-admin-templates
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[post-deploy tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[template tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-client/cmd/templates.go
- ludus-server/src/api_template_management.go
variables:
LUDUS_BUILD_TYPE: from-snapshot
LUDUS_SNAPSHOT_NAME: range_built_admin
timeout: 45m
retry:
max: 2
when: script_failure
script:
- *ci-setup-admin
- *template-tests
################
# RANGE - USER #
################
range deploy-user:
stage: range-user-deploy
tags:
- ludus-proxmox-runner
dependencies:
- build all
rules:
- if: $CI_COMMIT_TAG # Tags/Releases are created manually after successful full builds
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[full build\]/
- if: $CI_COMMIT_MESSAGE =~ /\[range tests\]/
- if: $CI_COMMIT_MESSAGE =~ /\[skip ci\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at templates\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-admin\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at range-user\]/
- if: $CI_COMMIT_MESSAGE =~ /\[start-at post-deploy-user\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[start-at integration\]/
when: never
- if: $CI_COMMIT_MESSAGE =~ /\[manual\]/
when: never
- changes:
- ludus-client/cmd/range.go
- ludus-server/ansible/range-management/**/*
- ludus-server/ansible/user-management/**/*
variables:
LUDUS_BUILD_TYPE: from-snapshot
LUDUS_SNAPSHOT_NAME: range_built_admin
timeout: 5m
retry:
max: 2
when: script_failure
script:
- *ci-setup-admin
- ludus power off -n all # Shut down the admin range to save resources
- *ci-setup-user
- ludus range config get