Skip to content

Commit 5cab22b

Browse files
IPA build workflow (#1414)
* Add checksum support * debug * Remove debug * IPA Release Train workflow * Finishing touches * Documentation * Apply suggestions from code review Co-authored-by: Alex-Welsh <112560678+Alex-Welsh@users.noreply.github.com> * Update artifact-type to ipa-images * Update overcloud IPA URLs * Update release note * Disable StackHPC repos --------- Co-authored-by: Alex-Welsh <112560678+Alex-Welsh@users.noreply.github.com>
1 parent 1479d90 commit 5cab22b

File tree

12 files changed

+588
-4
lines changed

12 files changed

+588
-4
lines changed

.github/workflows/ipa-image-build.yml

+343
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,343 @@
1+
---
2+
name: Build IPA images
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
rocky9:
7+
description: Build Rocky Linux 9
8+
type: boolean
9+
default: true
10+
ubuntu-jammy:
11+
description: Build Ubuntu 22.04 Jammy
12+
type: boolean
13+
default: true
14+
secrets:
15+
KAYOBE_VAULT_PASSWORD:
16+
required: true
17+
CLOUDS_YAML:
18+
required: true
19+
OS_APPLICATION_CREDENTIAL_ID:
20+
required: true
21+
OS_APPLICATION_CREDENTIAL_SECRET:
22+
required: true
23+
24+
env:
25+
ANSIBLE_FORCE_COLOR: True
26+
KAYOBE_ENVIRONMENT: ci-builder
27+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
28+
jobs:
29+
ipa-image-build:
30+
name: Build IPA images
31+
if: github.repository == 'stackhpc/stackhpc-kayobe-config'
32+
runs-on: arc-skc-host-image-builder-runner
33+
permissions: {}
34+
steps:
35+
- name: Install Package
36+
uses: ConorMacBride/install-package@main
37+
with:
38+
apt: git unzip nodejs python3-pip python3-venv openssh-server openssh-client jq
39+
40+
- name: Start the SSH service
41+
run: |
42+
sudo /etc/init.d/ssh start
43+
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
with:
47+
path: src/kayobe-config
48+
49+
- name: Output image tag of the builder
50+
id: builder_image_tag
51+
run: |
52+
echo image_tag=$(grep stackhpc_rocky_9_overcloud_host_image_version: etc/kayobe/pulp-host-image-versions.yml | awk '{print $2}') >> $GITHUB_OUTPUT
53+
54+
- name: Determine OpenStack release
55+
id: openstack_release
56+
run: |
57+
BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' src/kayobe-config/.gitreview)
58+
echo "openstack_release=${BRANCH}" | sed -E "s,(stable|unmaintained)/,," >> $GITHUB_OUTPUT
59+
60+
- name: Generate IPA image tag
61+
id: ipa_image_tag
62+
run: |
63+
echo "ipa_image_tag=$(date +${{ steps.openstack_release.outputs.openstack_release }}-%Y%m%dT%H%M%S)" >> $GITHUB_OUTPUT
64+
65+
- name: Display IPA image tag
66+
run: |
67+
echo "${{ steps.ipa_image_tag.outputs.ipa_image_tag }}"
68+
69+
- name: Install Kayobe
70+
run: |
71+
mkdir -p venvs &&
72+
pushd venvs &&
73+
python3 -m venv kayobe &&
74+
source kayobe/bin/activate &&
75+
pip install -U pip &&
76+
pip install -r ../src/kayobe-config/requirements.txt
77+
78+
- name: Install terraform
79+
uses: hashicorp/setup-terraform@v3
80+
81+
- name: Initialise terraform
82+
run: terraform init
83+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
84+
85+
- name: Generate SSH keypair
86+
run: ssh-keygen -f id_rsa -N ''
87+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
88+
89+
- name: Generate clouds.yaml
90+
run: |
91+
cat << EOF > clouds.yaml
92+
${{ secrets.CLOUDS_YAML }}
93+
EOF
94+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
95+
96+
- name: Generate terraform.tfvars
97+
run: |
98+
cat << EOF > terraform.tfvars
99+
ssh_public_key = "id_rsa.pub"
100+
ssh_username = "ubuntu"
101+
aio_vm_name = "skc-ipa-image-builder"
102+
aio_vm_image = "Ubuntu-22.04"
103+
aio_vm_flavor = "en1.large"
104+
aio_vm_network = "stackhpc-ci"
105+
aio_vm_subnet = "stackhpc-ci"
106+
aio_vm_interface = "ens3"
107+
aio_vm_volume_size = 100
108+
EOF
109+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
110+
111+
- name: Terraform Plan
112+
run: terraform plan
113+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
114+
env:
115+
OS_CLOUD: "openstack"
116+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
117+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
118+
119+
- name: Terraform Apply
120+
run: |
121+
for attempt in $(seq 5); do
122+
if terraform apply -auto-approve; then
123+
echo "Created infrastructure on attempt $attempt"
124+
exit 0
125+
fi
126+
echo "Failed to create infrastructure on attempt $attempt"
127+
sleep 10
128+
terraform destroy -auto-approve
129+
sleep 60
130+
done
131+
echo "Failed to create infrastructure after $attempt attempts"
132+
exit 1
133+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
134+
env:
135+
OS_CLOUD: "openstack"
136+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
137+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
138+
139+
- name: Get Terraform outputs
140+
id: tf_outputs
141+
run: |
142+
terraform output -json
143+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
144+
145+
- name: Write Terraform outputs
146+
run: |
147+
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-outputs.yml
148+
${{ steps.tf_outputs.outputs.stdout }}
149+
EOF
150+
151+
- name: Write Terraform network config
152+
run: |
153+
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-network-allocation.yml
154+
---
155+
aio_ips:
156+
builder: "{{ access_ip_v4.value }}"
157+
EOF
158+
159+
- name: Write Terraform network interface config
160+
run: |
161+
mkdir -p src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed
162+
rm -f src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
163+
cat << EOF > src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
164+
admin_interface: "{{ access_interface.value }}"
165+
aio_interface: "{{ access_interface.value }}"
166+
EOF
167+
168+
- name: Manage SSH keys
169+
run: |
170+
mkdir -p ~/.ssh
171+
touch ~/.ssh/authorized_keys
172+
cat src/kayobe-config/terraform/aio/id_rsa.pub >> ~/.ssh/authorized_keys
173+
cp src/kayobe-config/terraform/aio/id_rsa* ~/.ssh/
174+
175+
- name: Bootstrap the control host
176+
run: |
177+
source venvs/kayobe/bin/activate &&
178+
source src/kayobe-config/kayobe-env --environment ci-builder &&
179+
kayobe control host bootstrap
180+
181+
- name: Configure the seed host (Builder VM)
182+
run: |
183+
source venvs/kayobe/bin/activate &&
184+
source src/kayobe-config/kayobe-env --environment ci-builder &&
185+
kayobe seed host configure \
186+
-e seed_bootstrap_user=ubuntu \
187+
--skip-tags network,apt,docker,docker-registry
188+
env:
189+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
190+
191+
- name: Install dependencies
192+
run: |
193+
source venvs/kayobe/bin/activate &&
194+
source src/kayobe-config/kayobe-env --environment ci-builder &&
195+
kayobe seed host command run \
196+
--command "sudo apt update && sudo apt -y install gcc git libffi-dev python3-dev python-is-python3 python3-venv" --show-output
197+
env:
198+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
199+
200+
- name: Build a Ubuntu 22.04 Jammy IPA image
201+
id: build_ubuntu_jammy_ipa
202+
continue-on-error: true
203+
run: |
204+
source venvs/kayobe/bin/activate &&
205+
source src/kayobe-config/kayobe-env --environment ci-builder &&
206+
kayobe overcloud deployment image build --force-rebuild \
207+
-e os_distribution="ubuntu" \
208+
-e os_release="jammy" \
209+
-e ipa_ci_builder_distribution="ubuntu"
210+
env:
211+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
212+
if: inputs.ubuntu-jammy
213+
214+
- name: Show last error logs
215+
continue-on-error: true
216+
run: |
217+
source venvs/kayobe/bin/activate &&
218+
source src/kayobe-config/kayobe-env --environment ci-builder &&
219+
kayobe seed host command run --command "tail -200 /opt/kayobe/images/ipa/ipa.stdout" --show-output
220+
env:
221+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
222+
if: steps.build_ubuntu_jammy_ipa.outcome == 'failure'
223+
224+
- name: Upload Ubuntu 22.04 Jammy IPA kernel image to Ark
225+
run: |
226+
source venvs/kayobe/bin/activate &&
227+
source src/kayobe-config/kayobe-env --environment ci-builder &&
228+
kayobe playbook run \
229+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \
230+
-e artifact_path=/opt/kayobe/images/ipa \
231+
-e artifact_type=ipa-images \
232+
-e artifact_tag=${{ steps.ipa_image_tag.outputs.ipa_image_tag }} \
233+
-e os_distribution="ubuntu" \
234+
-e os_release="jammy" \
235+
-e file_regex='*.kernel' \
236+
-e upload_checksum=true
237+
env:
238+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
239+
if: inputs.ubuntu-jammy && steps.build_ubuntu_jammy_ipa.outcome == 'success'
240+
241+
- name: Upload Ubuntu 22.04 Jammy IPA ramdisk image to Ark
242+
run: |
243+
source venvs/kayobe/bin/activate &&
244+
source src/kayobe-config/kayobe-env --environment ci-builder &&
245+
kayobe playbook run \
246+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \
247+
-e artifact_path=/opt/kayobe/images/ipa \
248+
-e artifact_type=ipa-images \
249+
-e artifact_tag=${{ steps.ipa_image_tag.outputs.ipa_image_tag }} \
250+
-e os_distribution="ubuntu" \
251+
-e os_release="jammy" \
252+
-e file_regex='*.initramfs' \
253+
-e upload_checksum=true
254+
env:
255+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
256+
if: inputs.ubuntu-jammy && steps.build_ubuntu_jammy_ipa.outcome == 'success'
257+
258+
- name: Build a Rocky 9 IPA image
259+
id: build_rocky_9_ipa
260+
continue-on-error: true
261+
run: |
262+
source venvs/kayobe/bin/activate &&
263+
source src/kayobe-config/kayobe-env --environment ci-builder &&
264+
kayobe overcloud deployment image build --force-rebuild \
265+
-e os_distribution="rocky" \
266+
-e os_release="9" \
267+
-e ipa_ci_builder_distribution="rocky"
268+
env:
269+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
270+
if: inputs.rocky9
271+
272+
- name: Show last error logs
273+
continue-on-error: true
274+
run: |
275+
source venvs/kayobe/bin/activate &&
276+
source src/kayobe-config/kayobe-env --environment ci-builder &&
277+
kayobe seed host command run --command "tail -200 /opt/kayobe/images/ipa/ipa.stdout" --show-output
278+
env:
279+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
280+
if: steps.build_rocky_9_ipa.outcome == 'failure'
281+
282+
- name: Upload Rocky 9 IPA kernel image to Ark
283+
run: |
284+
source venvs/kayobe/bin/activate &&
285+
source src/kayobe-config/kayobe-env --environment ci-builder &&
286+
kayobe playbook run \
287+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \
288+
-e artifact_path=/opt/kayobe/images/ipa \
289+
-e artifact_type=ipa-images \
290+
-e artifact_tag=${{ steps.ipa_image_tag.outputs.ipa_image_tag }} \
291+
-e os_distribution="rocky" \
292+
-e os_release="9" \
293+
-e file_regex='*.kernel' \
294+
-e upload_checksum=true
295+
env:
296+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
297+
if: inputs.rocky9 && steps.build_rocky_9_ipa.outcome == 'success'
298+
299+
- name: Upload Rocky 9 IPA ramdisk image to Ark
300+
run: |
301+
source venvs/kayobe/bin/activate &&
302+
source src/kayobe-config/kayobe-env --environment ci-builder &&
303+
kayobe playbook run \
304+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \
305+
-e artifact_path=/opt/kayobe/images/ipa \
306+
-e artifact_type=ipa-images \
307+
-e artifact_tag=${{ steps.ipa_image_tag.outputs.ipa_image_tag }} \
308+
-e os_distribution="rocky" \
309+
-e os_release="9" \
310+
-e file_regex='*.initramfs' \
311+
-e upload_checksum=true
312+
env:
313+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
314+
if: inputs.rocky9 && steps.build_rocky_9_ipa.outcome == 'success'
315+
316+
- name: Copy logs back
317+
continue-on-error: true
318+
run: |
319+
mkdir logs
320+
scp -r ubuntu@$(jq -r .access_ip_v4.value src/kayobe-config/etc/kayobe/environments/ci-builder/tf-outputs.yml):/opt/kayobe/images/*/*.std* ./logs/
321+
if: always()
322+
323+
- name: Upload logs artifact
324+
uses: actions/upload-artifact@v4
325+
with:
326+
name: Build logs
327+
path: ./logs
328+
329+
- name: Fail if the IPA image build failed
330+
run: |
331+
echo "Builds failed. See workflow artifacts for details." &&
332+
exit 1
333+
if: steps.build_rocky_9_ipa.outcome == 'failure' ||
334+
steps.build_ubuntu_jammy_ipa.outcome == 'failure'
335+
336+
- name: Destroy
337+
run: terraform destroy -auto-approve
338+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
339+
env:
340+
OS_CLOUD: openstack
341+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
342+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
343+
if: always()

0 commit comments

Comments
 (0)