Skip to content

Commit 6dae3c4

Browse files
OFED workflow
1 parent 2e40537 commit 6dae3c4

File tree

2 files changed

+262
-0
lines changed

2 files changed

+262
-0
lines changed
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
---
2+
name: Build overcloud host 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+
overcloud-host-image-build:
30+
name: Build overcloud host 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+
# Generate a tag to apply to all built overcloud host images.
61+
- name: Generate overcloud host image tag
62+
id: host_image_tag
63+
run: |
64+
echo "host_image_tag=$(date +${{ steps.openstack_release.outputs.openstack_release }}-%Y%m%dT%H%M%S)" >> $GITHUB_OUTPUT
65+
66+
- name: Display overcloud host image tag
67+
run: |
68+
echo "${{ steps.host_image_tag.outputs.host_image_tag }}"
69+
70+
- name: Clone StackHPC Kayobe repository
71+
uses: actions/checkout@v4
72+
with:
73+
repository: stackhpc/kayobe
74+
ref: refs/heads/stackhpc/${{ steps.openstack_release.outputs.openstack_release }}
75+
path: src/kayobe
76+
77+
- name: Install Kayobe
78+
run: |
79+
mkdir -p venvs &&
80+
pushd venvs &&
81+
python3 -m venv kayobe &&
82+
source kayobe/bin/activate &&
83+
pip install -U pip &&
84+
pip install ../src/kayobe
85+
86+
- name: Install terraform
87+
uses: hashicorp/setup-terraform@v2
88+
89+
- name: Initialise terraform
90+
run: terraform init
91+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
92+
93+
- name: Generate SSH keypair
94+
run: ssh-keygen -f id_rsa -N ''
95+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
96+
97+
- name: Generate clouds.yaml
98+
run: |
99+
cat << EOF > clouds.yaml
100+
${{ secrets.CLOUDS_YAML }}
101+
EOF
102+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
103+
104+
- name: Generate terraform.tfvars
105+
run: |
106+
cat << EOF > terraform.tfvars
107+
ssh_public_key = "id_rsa.pub"
108+
ssh_username = "rocky"
109+
aio_vm_name = "skc-host-image-builder"
110+
# Must be a Rocky Linux 9 host to successfully build all images
111+
# This MUST NOT be an LVM image. It can cause confusing conficts with the built image.
112+
aio_vm_image = "Rocky-9-GenericCloud-Base-9.3-20231113.0.x86_64.qcow2"
113+
aio_vm_flavor = "en1.medium"
114+
aio_vm_network = "stackhpc-ci"
115+
aio_vm_subnet = "stackhpc-ci"
116+
aio_vm_interface = "eth0"
117+
EOF
118+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
119+
120+
- name: Terraform Plan
121+
run: terraform plan
122+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
123+
env:
124+
OS_CLOUD: "openstack"
125+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
126+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
127+
128+
- name: Terraform Apply
129+
run: |
130+
for attempt in $(seq 5); do
131+
if terraform apply -auto-approve; then
132+
echo "Created infrastructure on attempt $attempt"
133+
exit 0
134+
fi
135+
echo "Failed to create infrastructure on attempt $attempt"
136+
sleep 10
137+
terraform destroy -auto-approve
138+
sleep 60
139+
done
140+
echo "Failed to create infrastructure after $attempt attempts"
141+
exit 1
142+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
143+
env:
144+
OS_CLOUD: "openstack"
145+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
146+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
147+
148+
- name: Get Terraform outputs
149+
id: tf_outputs
150+
run: |
151+
terraform output -json
152+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
153+
154+
- name: Write Terraform outputs
155+
run: |
156+
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-outputs.yml
157+
${{ steps.tf_outputs.outputs.stdout }}
158+
EOF
159+
160+
- name: Write Terraform network config
161+
run: |
162+
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-network-allocation.yml
163+
---
164+
aio_ips:
165+
builder: "{{ access_ip_v4.value }}"
166+
EOF
167+
168+
- name: Write Terraform network interface config
169+
run: |
170+
mkdir -p src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed
171+
rm -f src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
172+
cat << EOF > src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
173+
admin_interface: "{{ access_interface.value }}"
174+
aio_interface: "{{ access_interface.value }}"
175+
EOF
176+
177+
- name: Manage SSH keys
178+
run: |
179+
mkdir -p ~/.ssh
180+
touch ~/.ssh/authorized_keys
181+
cat src/kayobe-config/terraform/aio/id_rsa.pub >> ~/.ssh/authorized_keys
182+
cp src/kayobe-config/terraform/aio/id_rsa* ~/.ssh/
183+
184+
- name: Bootstrap the control host
185+
run: |
186+
source venvs/kayobe/bin/activate &&
187+
source src/kayobe-config/kayobe-env --environment ci-builder &&
188+
kayobe control host bootstrap
189+
190+
- name: Configure the seed host (Builder VM)
191+
run: |
192+
source venvs/kayobe/bin/activate &&
193+
source src/kayobe-config/kayobe-env --environment ci-builder &&
194+
kayobe seed host configure -e seed_bootstrap_user=rocky --skip-tags network
195+
196+
- name: Install dependencies
197+
run: |
198+
source venvs/kayobe/bin/activate &&
199+
source src/kayobe-config/kayobe-env --environment ci-builder &&
200+
kayobe seed host command run \
201+
--command "sudo dnf config-manager --set-enabled crb \
202+
&& sudo dnf -y install epel-release && sudo dnf -y install zstd \
203+
debootstrap kpartx cloud-init perl rpm-build automake patch kernel-devel \
204+
autoconf pciutils kernel-rpm-macros lsof libtool tk gcc-gfortran tcl" --show-output
205+
env:
206+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
207+
208+
- name: Run OFED builder playbook
209+
run: |
210+
source venvs/kayobe/bin/activate &&
211+
source src/kayobe-config/kayobe-env --environment ci-builder &&
212+
kayobe playbook run src/kayobe-config/etc/kayobe/ansible/build-ofed.yml
213+
env:
214+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }
215+
216+
- name: Destroy
217+
run: terraform destroy -auto-approve
218+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
219+
env:
220+
OS_CLOUD: openstack
221+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
222+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
223+
if: always()

etc/kayobe/ansible/build-ofed.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
- name: Build OFED image
3+
hosts: seed
4+
gather_facts: false
5+
vars:
6+
mlnx_ofed_version: 24.04-0.7.0.0
7+
mlnx_ofed: MLNX_OFED_LINUX-{{ mlnx_ofed_version }}-rhel9.{{ stackhpc_pulp_repo_rocky_9_minor_version }}-x86_64
8+
stackhpc_pulp_repo_rocky_9_minor_version: 4
9+
tasks:
10+
- name: Create build directory
11+
ansible.builtin.file:
12+
path: /opt/ofed
13+
state: directory
14+
mode: 0777
15+
become: true
16+
17+
- name: Download MellanoxOFED archive
18+
ansible.builtin.get_url:
19+
url: https://content.mellanox.com/ofed/MLNX_OFED-{{ mlnx_ofed_version }}/{{ mlnx_ofed }}.tgz
20+
dest: /opt/ofed/ofed-archive
21+
22+
- name: Extract MellanoxOFED archive
23+
ansible.builtin.unarchive:
24+
src: /opt/ofed/ofed-archive
25+
dest: /opt/ofed
26+
27+
- name: Ensure the current kernel is supported
28+
ansible.builtin.shell:
29+
cmd: |
30+
/opt/ofed/{{ mlnx_ofed }}/mlnx_add_kernel_support.sh \
31+
--mlnx_ofed /opt/ofed/{{ mlnx_ofed }} \
32+
--make-tgz -y \
33+
become: true
34+
35+
- name: Extract the new archive
36+
ansible.builtin.unarchive:
37+
src: /tmp/{{ mlnx_ofed }}-ext.tgz
38+
dest: /opt/ofed-build
39+
become: true

0 commit comments

Comments
 (0)