forked from cpanel/elevate
-
Notifications
You must be signed in to change notification settings - Fork 2
535 lines (491 loc) · 18.7 KB
/
openstack-cloudlinux-8.yml
File metadata and controls
535 lines (491 loc) · 18.7 KB
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
name: "Test Run: CloudLinux-8"
on:
workflow_call:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-openstack-cloudlinux-8
cancel-in-progress: true
env:
# secrets
TF_VAR_application_credential_id: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
TF_VAR_application_credential_secret: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
TF_VAR_ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
TF_VAR_ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
# vars
TF_VAR_os_auth_url: ${{ vars.OS_AUTH_URL }}
TF_VAR_os_auth_type: ${{ vars.OS_AUTH_TYPE }}
TF_VAR_os_identity_api_version: ${{ vars.OS_IDENTITY_API_VERSION }}
TF_VAR_os_interface: ${{ vars.OS_INTERFACE }}
TF_VAR_os_region_name: ${{ vars.OS_REGION_NAME }}
# github
TF_VAR_github_repository: ${{ github.repository }}
TF_VAR_github_run_id: ${{ github.run_id }}
tf_working_directory: "${{ github.workspace }}/.github/workflows/openstack"
jobs:
terraform_openstack_create:
runs-on:
group: org/cpanel-arc-elevate
container:
image: ghcr.io/webpros-cpanel/misc-ci-containers:ci-elevate-cpanel
defaults:
run:
working-directory: "${{ github.workspace }}/.github/workflows/openstack"
outputs:
VM_IP: ${{ steps.get_vm_ip.outputs.VM_IP }}
REPODIR: ${{ steps.expose_repodir.outputs.REPODIR }}
steps:
- uses: actions/checkout@v6
- name: Install Packages Needed by GitHub Network Check
run: |
apk add --no-cache curl
- name: Terraform Init & Apply
run: |
for i in {1..36}; do curl -I https://objects.githubusercontent.com && break || echo "Attempt $i failed. Retrying in 5s..."; sleep 5; done
MAX_ATTEMPTS=5
SLEEP_SECONDS=5
for attempt in $(seq 1 $MAX_ATTEMPTS); do
echo "Attempt $attempt of $MAX_ATTEMPTS: terraform init"
if terraform init; then
echo "✅ terraform init succeeded on attempt $attempt"
break
else
echo "❌ terraform init failed on attempt $attempt"
if [ "$attempt" -lt "$MAX_ATTEMPTS" ]; then
echo "→ sleeping ${SLEEP_SECONDS}s before retry"
sleep $SLEEP_SECONDS
else
echo "🚨 terraform init failed after $MAX_ATTEMPTS attempts"
exit 1
fi
fi
done
terraform apply -var="image_name=11.134.0.* on CloudLinux 8" -var="cpanel_release_version=134" -no-color -auto-approve
terraform output -json > ${{ github.run_id }}-tf.out.json
mv -v .terraform.lock.hcl terraform.lock.hcl
- name: Upload Terraform Artifacts
uses: actions/upload-artifact@v7
with:
name: ${{ github.run_id }}-cloudlinux8-terraform.tfstate
path: ${{ env.tf_working_directory }}/terraform*
retention-days: 1 # override 90-day default
- name: Get VM IP from Terraform Output
id: get_vm_ip
run: |
echo "VM_IP=$(jq -r '.address.value' ${{ github.run_id }}-tf.out.json)" >> "$GITHUB_OUTPUT"
- name: Expose REPODIR as a Variable
id: expose_repodir
run: |
REPODIR=$(echo ${{ github.repository }} | cut -d / -f2)
echo "REPODIR=$REPODIR" >> "$GITHUB_OUTPUT"
clone_elevate_repo:
runs-on:
group: org/cpanel-arc-elevate
needs: terraform_openstack_create
env:
VM_IP: ${{ needs.terraform_openstack_create.outputs.VM_IP }}
REPODIR: ${{ needs.terraform_openstack_create.outputs.REPODIR }}
outputs:
VM_IP: ${{ env.VM_IP }}
REPODIR: ${{ env.REPODIR }}
steps:
- name: Checkout Repo
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ env.VM_IP }}
username: "root"
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: "22"
script: |
cd /opt
BRANCH_NAME=${{ github.ref_name }}
if [ "${{ github.event_name }}" == "pull_request" ]; then
BRANCH_NAME=${{ github.head_ref }}
fi
echo "## [INFO]: Checking out branch $BRANCH_NAME"
echo "## [INFO]: Repository: ${{ github.repository }}"
ssh-keyscan github.com >> ~/.ssh/known_hosts
mkdir -p ~/.ssh
echo "${{ secrets.ELEVATE_CHECKOUT_KEY }}" > ~/.ssh/elevate_checkout_key
chmod 0600 ~/.ssh/elevate_checkout_key
cat <<EOL > ~/.ssh/config
Host github.com
HostName github.com
User root
IdentityFile ~/.ssh/elevate_checkout_key
IdentitiesOnly yes
HostKeyAlgorithms +ssh-rsa
EOL
echo "## [DEBUG]: git clone --depth=1 --branch $BRANCH_NAME git@github.com:${{ github.repository }}.git"
git clone --depth=1 --branch $BRANCH_NAME git@github.com:${{ github.repository }}.git
cd /opt/$(basename "${{ github.repository }}")
git status
setup_integration_checks:
runs-on:
group: org/cpanel-arc-elevate
needs: clone_elevate_repo
env:
CLOUDLINUX_LICENSE_KEY: ${{ secrets.CLOUDLINUX_LICENSE_KEY }}
VM_IP: ${{ needs.clone_elevate_repo.outputs.VM_IP }}
REPODIR: ${{ needs.clone_elevate_repo.outputs.REPODIR }}
outputs:
VM_IP: ${{ env.VM_IP }}
REPODIR: ${{ env.REPODIR }}
steps:
- name: Install Packages Needed by Scripts.
run: |
sudo apt-get update
sudo apt install -y netcat-openbsd
- name: Setup for Integration Checks Prior to Running Elevate
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ env.VM_IP }}
username: "root"
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: "22"
timeout: 45m
command_timeout: 45m
envs: REPODIR
script: |
chmod -v +x /opt/${{ env.REPODIR}}/t/integration/setup
/opt/${{ env.REPODIR }}/t/integration/setup
- name: Update License And Setup Server For ELevate
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ env.VM_IP }}
username: "root"
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: "22"
timeout: 90m
command_timeout: 90m
envs: REPODIR,CLOUDLINUX_LICENSE_KEY
script: |
echo "## [INFO]: Removing /etc/yum/pluginconf.d/rhnplugin.conf" && rm -fv /etc/yum/pluginconf.d/rhnplugin.conf
echo "## [INFO]: /usr/sbin/rhnreg_ks --activationkey=${CLOUDLINUX_LICENSE_KEY:0:2}****" --force && /usr/sbin/rhnreg_ks --activationkey=$CLOUDLINUX_LICENSE_KEY --force
echo "## [INFO]: Now running /usr/bin/cldetect --update-license" && /usr/bin/cldetect --update-license
echo "## [INFO]: Now running /usr/bin/cldetect --check-license" && /usr/bin/cldetect --check-license
until /usr/local/cpanel/cpkeyclt; do echo "Retrying /usr/local/cpanel/cpkeyct until it passes..."; sleep 5; done
echo "[cloudlinux-base]" > /etc/yum.repos.d/cloudlinux-base.repo
echo "name=CloudLinux-\$releasever - Base" >> /etc/yum.repos.d/cloudlinux-base.repo
echo "baseurl=https://repo.cloudlinux.com/cloudlinux/\$releasever/BaseOS/\$basearch/os/" >> /etc/yum.repos.d/cloudlinux-base.repo
echo "enabled=0" >> /etc/yum.repos.d/cloudlinux-base.repo
echo "gpgcheck=1" >> /etc/yum.repos.d/cloudlinux-base.repo
echo "gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CloudLinux" >> /etc/yum.repos.d/cloudlinux-base.repo
echo "" >> /etc/yum.repos.d/cloudlinux-base.repo
rm -f /etc/yum.repos.d/almalinux*.repo
/usr/bin/yum -y reinstall cloudlinux-release
sed -i 's/\[powertools\]/[cloudlinux-PowerTools]/' /etc/yum.repos.d/almalinux-powertools.repo
/usr/bin/yum erase -y awscli git-lfs kmod-lve-2.0-43
rpm -evh kmod-lve-2.0-43.el8.x86_64 || true
echo "yum remove -y `yum list installed | awk '$3~/cloudlinux-PowerTools/{printf "%s ", $1}'`" | sh
echo "yum reinstall -y `yum list installed | awk '$3~/cloudlinux-BaseOS/{printf "%s ", $1}'` --disablerepo=cloudlinux-BaseOS --enablerepo=cloudlinux-base" | sh
mv -v /etc/yum.repos.d/clmirror.repo /root/
yum-config-manager --enable cloudlinux-base
/usr/bin/yum clean all
/usr/bin/yum makecache
/usr/bin/yum -y update
mv -v /etc/yum.repos.d/cloudlinux-compat.repo /root/
REPODIR=$(echo ${{ github.repository }} | cut -d / -f2)
cp -pv /opt/${REPODIR}/elevate-cpanel /scripts/elevate-cpanel
cp -pv /opt/${REPODIR}/.github/workflows/openstack/status_marker /scripts/status_marker
cp -pv /opt/${REPODIR}/.github/workflows/openstack/reboot_watch /scripts/reboot_watch
chmod -v +x /scripts/elevate-cpanel
shutdown -r +0 -t 15 "Restarting system after updates before we Elevate." &
exit 0
wait_for_stage_1_reboot:
runs-on:
group: org/cpanel-arc-elevate
needs: setup_integration_checks
env:
VM_IP: ${{ needs.setup_integration_checks.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Packages Needed by Scripts.
run: |
sudo apt-get update
sudo apt install -y netcat-openbsd
- name: Wait For VM to Come Back From Initial Reboot
working-directory: ".github/workflows/openstack/"
run: |
./ssh_retry ${{ env.VM_IP }}
start_elevate:
runs-on:
group: org/cpanel-arc-elevate
needs: wait_for_stage_1_reboot
env:
VM_IP: ${{ needs.wait_for_stage_1_reboot.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Start Elevate
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ env.VM_IP }}
username: "root"
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: "22"
timeout: 60m
command_timeout: 35m
debug: true
script: |
/scripts/status_marker 1
nohup /scripts/elevate-cpanel --is-ran-from-ci --non-interactive --skip-cpanel-version-check --start &
exit 0
wait_for_stage_2_reboot:
runs-on:
group: org/cpanel-arc-elevate
needs: start_elevate
env:
VM_IP: ${{ needs.start_elevate.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Packages Needed by Scripts.
run: |
sudo apt-get update
sudo apt install -y netcat-openbsd
- name: Wait For VM to Come Back From Stage 2 Reboot
working-directory: ".github/workflows/openstack/"
run: |
./ssh_retry ${{ env.VM_IP }}
watch_for_stage_3_reboot:
runs-on:
group: org/cpanel-arc-elevate
needs: wait_for_stage_2_reboot
env:
VM_IP: ${{ needs.wait_for_stage_2_reboot.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Monitor Elevate for Stage 3 Reboot
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ env.VM_IP }}
username: "root"
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: "22"
timeout: 60m
command_timeout: 30m
debug: true
script: |
/scripts/status_marker 2
tail -n40 -F /var/log/elevate-cpanel.log &
sleep .5
REBOOT_STRING="Rebooting into stage 3 of 5" RETVAL=1 /scripts/reboot_watch
wait_for_stage_3_reboot:
runs-on:
group: org/cpanel-arc-elevate
needs: watch_for_stage_3_reboot
env:
VM_IP: ${{ needs.watch_for_stage_3_reboot.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Packages Needed by Scripts.
run: |
sudo apt-get update
sudo apt install -y netcat-openbsd
- name: Wait For VM to Come Back From Stage 3 Reboot
working-directory: ".github/workflows/openstack/"
run: |
./ssh_retry ${{ env.VM_IP }}
watch_for_stage_4_reboot:
runs-on:
group: org/cpanel-arc-elevate
needs: wait_for_stage_3_reboot
env:
VM_IP: ${{ needs.wait_for_stage_3_reboot.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Monitor Elevate for Stage 4 Reboot
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ env.VM_IP }}
username: "root"
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: "22"
timeout: 60m
command_timeout: 60m
script: |
/scripts/status_marker 3
tail -n40 -F /var/log/elevate-cpanel.log &
sleep .5
REBOOT_STRING="Rebooting into stage 4 of 5" RETVAL=1 /scripts/reboot_watch
wait_for_stage_4_reboot:
runs-on:
group: org/cpanel-arc-elevate
needs: watch_for_stage_4_reboot
env:
VM_IP: ${{ needs.watch_for_stage_4_reboot.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Packages Needed by Scripts.
run: |
sudo apt-get update
sudo apt install -y netcat-openbsd
- name: Wait For VM to Come Back From Stage 4 Reboot
working-directory: ".github/workflows/openstack/"
run: |
./ssh_retry ${{ env.VM_IP }}
watch_for_stage_5_reboot:
runs-on:
group: org/cpanel-arc-elevate
needs: wait_for_stage_4_reboot
env:
VM_IP: ${{ needs.wait_for_stage_4_reboot.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Monitor Elevate for Stage 5 Reboot
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ env.VM_IP }}
username: "root"
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: "22"
timeout: 45m
command_timeout: 35m
script: |
/scripts/status_marker 4
tail -n40 -F /var/log/elevate-cpanel.log &
sleep .5
REBOOT_STRING="Rebooting into stage 5 of 5" RETVAL=1 /scripts/reboot_watch
wait_for_stage_5_reboot:
runs-on:
group: org/cpanel-arc-elevate
needs: watch_for_stage_5_reboot
env:
VM_IP: ${{ needs.watch_for_stage_5_reboot.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Packages Needed by Scripts.
run: |
sudo apt-get update
sudo apt install -y netcat-openbsd
- name: Wait For VM to Come Back From Stage 5 Reboot
working-directory: ".github/workflows/openstack/"
run: |
./ssh_retry ${{ env.VM_IP }}
watch_for_final_reboot:
runs-on:
group: org/cpanel-arc-elevate
needs: wait_for_stage_5_reboot
env:
VM_IP: ${{ needs.wait_for_stage_5_reboot.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Monitor Elevate for Final Reboot
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ env.VM_IP }}
username: "root"
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: "22"
timeout: 45m
command_timeout: 35m
script: |
/scripts/status_marker 5
tail -n40 -F /var/log/elevate-cpanel.log &
sleep .5
REBOOT_STRING="Doing final reboot" RETVAL=1 /scripts/reboot_watch
wait_for_final_reboot:
runs-on:
group: org/cpanel-arc-elevate
needs: watch_for_final_reboot
env:
VM_IP: ${{ needs.watch_for_final_reboot.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Packages Needed by Scripts.
run: |
sudo apt-get update
sudo apt install -y netcat-openbsd
- name: Wait For VM to Come Back From Final Reboot
working-directory: ".github/workflows/openstack/"
run: |
./ssh_retry ${{ env.VM_IP }}
verify_upgraded_os:
runs-on:
group: org/cpanel-arc-elevate
needs: wait_for_final_reboot
env:
VM_IP: ${{ needs.wait_for_final_reboot.outputs.VM_IP}}
outputs:
VM_IP: ${{ env.VM_IP }}
steps:
- name: Verify End Result Integration Tests
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ env.VM_IP }}
username: "root"
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: "22"
timeout: 10m
command_timeout: 10m
script: |
REPODIR=$(echo ${{ github.repository }} | cut -d / -f2)
/usr/local/cpanel/3rdparty/bin/prove -lvm /opt/${REPODIR}/t/integration/cloudlinux8-to-cloudlinux9/
/usr/local/cpanel/3rdparty/bin/prove -lvm /opt/${REPODIR}/t/integration/
terraform_openstack_destroy:
runs-on:
group: org/cpanel-arc-elevate
container:
image: ghcr.io/webpros-cpanel/misc-ci-containers:ci-elevate-cpanel
needs: verify_upgraded_os
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Download Terraform State
uses: actions/download-artifact@v7
with:
name: ${{ github.run_id }}-cloudlinux8-terraform.tfstate
path: ${{ env.tf_working_directory }}
- name: Stage Files & Show Artifact Paths
run: |
pwd
find -type d
cd ".github/workflows/openstack"
mv -v terraform.lock.hcl .terraform.lock.hcl
- name: Initialize Terraform & Destroy
run: |
cd ".github/workflows/openstack"
rm -Rfv .terraform || true
for i in {1..36}; do curl -I https://objects.githubusercontent.com && break || echo "Attempt $i failed. Retrying in 5s..."; sleep 5; done
MAX_ATTEMPTS=5
SLEEP_SECONDS=5
for attempt in $(seq 1 $MAX_ATTEMPTS); do
echo "Attempt $attempt of $MAX_ATTEMPTS: terraform init"
if terraform init; then
echo "✅ terraform init succeeded on attempt $attempt"
break
else
echo "❌ terraform init failed on attempt $attempt"
if [ "$attempt" -lt "$MAX_ATTEMPTS" ]; then
echo "→ sleeping ${SLEEP_SECONDS}s before retry"
sleep $SLEEP_SECONDS
else
echo "🚨 terraform init failed after $MAX_ATTEMPTS attempts"
exit 1
fi
fi
done
terraform destroy -var="image_name=11.134.0.* on CloudLinux 8" -var="cpanel_release_version=134" -no-color -auto-approve