Skip to content

Commit e01b040

Browse files
OFED workflow
1 parent 2e40537 commit e01b040

File tree

5 files changed

+355
-0
lines changed

5 files changed

+355
-0
lines changed
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
name: Build OFED packages
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
rocky9:
7+
description: Build Rocky Linux 9
8+
type: boolean
9+
default: true
10+
secrets:
11+
KAYOBE_VAULT_PASSWORD:
12+
required: true
13+
CLOUDS_YAML:
14+
required: true
15+
OS_APPLICATION_CREDENTIAL_ID:
16+
required: true
17+
OS_APPLICATION_CREDENTIAL_SECRET:
18+
required: true
19+
20+
env:
21+
ANSIBLE_FORCE_COLOR: True
22+
KAYOBE_ENVIRONMENT: ci-builder
23+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
24+
jobs:
25+
overcloud-ofed-packages:
26+
name: Build OFED packages
27+
if: github.repository == 'stackhpc/stackhpc-kayobe-config'
28+
runs-on: arc-skc-host-image-builder-runner
29+
permissions: {}
30+
steps:
31+
- name: Install Package
32+
uses: ConorMacBride/install-package@main
33+
with:
34+
apt: git unzip nodejs python3-pip python3-venv openssh-server openssh-client jq
35+
36+
- name: Start the SSH service
37+
run: |
38+
sudo /etc/init.d/ssh start
39+
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
with:
43+
path: src/kayobe-config
44+
45+
- name: Determine OpenStack release
46+
id: openstack_release
47+
run: |
48+
BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' src/kayobe-config/.gitreview)
49+
echo "openstack_release=${BRANCH}" | sed -E "s,(stable|unmaintained)/,," >> $GITHUB_OUTPUT
50+
51+
- name: Clone StackHPC Kayobe repository
52+
uses: actions/checkout@v4
53+
with:
54+
repository: stackhpc/kayobe
55+
ref: refs/heads/stackhpc/${{ steps.openstack_release.outputs.openstack_release }}
56+
path: src/kayobe
57+
58+
- name: Install Kayobe
59+
run: |
60+
mkdir -p venvs &&
61+
pushd venvs &&
62+
python3 -m venv kayobe &&
63+
source kayobe/bin/activate &&
64+
pip install -U pip &&
65+
pip install ../src/kayobe
66+
67+
- name: Install terraform
68+
uses: hashicorp/setup-terraform@v2
69+
70+
- name: Initialise terraform
71+
run: terraform init
72+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
73+
74+
- name: Generate SSH keypair
75+
run: ssh-keygen -f id_rsa -N ''
76+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
77+
78+
- name: Generate clouds.yaml
79+
run: |
80+
cat << EOF > clouds.yaml
81+
${{ secrets.CLOUDS_YAML }}
82+
EOF
83+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
84+
85+
- name: Generate terraform.tfvars
86+
run: |
87+
cat << EOF > terraform.tfvars
88+
ssh_public_key = "id_rsa.pub"
89+
ssh_username = "rocky"
90+
aio_vm_name = "skc-host-image-builder"
91+
aio_vm_image = "Rocky-9-GenericCloud-Base-9.3-20231113.0.x86_64.qcow2"
92+
aio_vm_flavor = "en1.medium"
93+
aio_vm_network = "stackhpc-ci"
94+
aio_vm_subnet = "stackhpc-ci"
95+
aio_vm_interface = "eth0"
96+
EOF
97+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
98+
99+
- name: Terraform Plan
100+
run: terraform plan
101+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
102+
env:
103+
OS_CLOUD: "openstack"
104+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
105+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
106+
107+
- name: Terraform Apply
108+
run: |
109+
for attempt in $(seq 5); do
110+
if terraform apply -auto-approve; then
111+
echo "Created infrastructure on attempt $attempt"
112+
exit 0
113+
fi
114+
echo "Failed to create infrastructure on attempt $attempt"
115+
sleep 10
116+
terraform destroy -auto-approve
117+
sleep 60
118+
done
119+
echo "Failed to create infrastructure after $attempt attempts"
120+
exit 1
121+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
122+
env:
123+
OS_CLOUD: "openstack"
124+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
125+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
126+
127+
- name: Get Terraform outputs
128+
id: tf_outputs
129+
run: |
130+
terraform output -json
131+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
132+
133+
- name: Write Terraform outputs
134+
run: |
135+
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-outputs.yml
136+
${{ steps.tf_outputs.outputs.stdout }}
137+
EOF
138+
139+
- name: Write Terraform network config
140+
run: |
141+
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-network-allocation.yml
142+
---
143+
aio_ips:
144+
builder: "{{ access_ip_v4.value }}"
145+
EOF
146+
147+
- name: Write Terraform network interface config
148+
run: |
149+
mkdir -p src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed
150+
rm -f src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
151+
cat << EOF > src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
152+
admin_interface: "{{ access_interface.value }}"
153+
aio_interface: "{{ access_interface.value }}"
154+
EOF
155+
156+
- name: Manage SSH keys
157+
run: |
158+
mkdir -p ~/.ssh
159+
touch ~/.ssh/authorized_keys
160+
cat src/kayobe-config/terraform/aio/id_rsa.pub >> ~/.ssh/authorized_keys
161+
cp src/kayobe-config/terraform/aio/id_rsa* ~/.ssh/
162+
163+
- name: Bootstrap the control host
164+
run: |
165+
source venvs/kayobe/bin/activate &&
166+
source src/kayobe-config/kayobe-env --environment ci-builder &&
167+
kayobe control host bootstrap
168+
169+
- name: Configure the seed host (Builder VM)
170+
run: |
171+
source venvs/kayobe/bin/activate &&
172+
source src/kayobe-config/kayobe-env --environment ci-builder &&
173+
kayobe seed host configure -e seed_bootstrap_user=rocky --skip-tags network
174+
175+
- name: Run growroot playbook
176+
run: |
177+
source venvs/kayobe/bin/activate &&
178+
source src/kayobe-config/kayobe-env --environment ci-builder &&
179+
kayobe playbook run src/kayobe-config/etc/kayobe/ansible/growroot.yml
180+
env:
181+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }
182+
183+
- name: Run OFED builder playbook
184+
run: |
185+
source venvs/kayobe/bin/activate &&
186+
source src/kayobe-config/kayobe-env --environment ci-builder &&
187+
kayobe playbook run src/kayobe-config/etc/kayobe/ansible/build-ofed.yml
188+
env:
189+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }
190+
191+
- name: Run OFED publish playbook
192+
run: |
193+
source venvs/kayobe/bin/activate &&
194+
source src/kayobe-config/kayobe-env --environment ci-builder &&
195+
kayobe playbook run src/kayobe-config/etc/kayobe/ansible/push-ofed.yml
196+
env:
197+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }
198+
199+
- name: Destroy
200+
run: terraform destroy -auto-approve
201+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
202+
env:
203+
OS_CLOUD: openstack
204+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
205+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
206+
if: always()

etc/kayobe/ansible/build-ofed.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
- name: Build OFED packages
3+
become: true
4+
hosts: ofed-builder
5+
gather_facts: false
6+
vars:
7+
stackhpc_mlnx_ofed_file_string: MLNX_OFED_LINUX-{{ stackhpc_pulp_mlnx_ofed_version }}-rhel9.{{ stackhpc_pulp_repo_rocky_9_minor_version }}-x86_64
8+
tasks:
9+
- name: Extend the home logical volume
10+
community.general.lvol:
11+
vg: rootvg
12+
lv: lv_home
13+
size: +5G
14+
15+
- name: Install package dependencies
16+
ansible.builtin.dnf:
17+
name:
18+
- kpartx
19+
- perl
20+
- rpm-build
21+
- automake
22+
- patch
23+
- kernel
24+
- kernel-devel
25+
- autoconf
26+
- pciutils
27+
- kernel-rpm-macros
28+
- lsof
29+
- libtool
30+
- tk
31+
- gcc-gfortran
32+
- tcl
33+
- createrepo
34+
state: latest
35+
update_cache: true
36+
37+
- name: Update the default kernel entry
38+
ansible.builtin.shell:
39+
cmd: |
40+
grubby --set-default /boot/$(rpm -qa kernel-devel | sed 's/kernel-devel/vmlinuz/g')
41+
echo 'GRUB_DEFAULT=2' >> /etc/default/grub
42+
grub2-mkconfig -o /boot/grub2/grub.cfg
43+
44+
- name: Reboot builder to apply kernel update
45+
ansible.builtin.reboot:
46+
reboot_timeout: 600
47+
48+
- name: Create build directory
49+
ansible.builtin.file:
50+
path: /home/cloud-user/ofed
51+
state: directory
52+
mode: 0777
53+
54+
- name: Download MellanoxOFED archive
55+
ansible.builtin.get_url:
56+
url: https://content.mellanox.com/ofed/MLNX_OFED-{{ stackhpc_pulp_mlnx_ofed_version }}/{{ stackhpc_mlnx_ofed_file_string }}.tgz
57+
dest: /home/cloud-user/ofed/ofed-archive
58+
59+
- name: Extract MellanoxOFED archive
60+
ansible.builtin.unarchive:
61+
src: /home/cloud-user/ofed/ofed-archive
62+
dest: /home/cloud-user/ofed
63+
64+
- name: Ensure the current kernel is supported
65+
ansible.builtin.shell:
66+
cmd: |
67+
/home/cloud-user/ofed/{{ stackhpc_mlnx_ofed_file_string }}/mlnx_add_kernel_support.sh \
68+
--mlnx_ofed /home/cloud-user/ofed/{{ stackhpc_mlnx_ofed_file_string }} \
69+
--tmpdir /home/cloud-user/ofed/ofed-build \
70+
--make-tgz -y \
71+
72+
- name: Extract the new archive
73+
ansible.builtin.unarchive:
74+
src: /home/cloud-user/ofed/ofed-build/{{ stackhpc_mlnx_ofed_file_string }}-ext.tgz
75+
dest: /home/cloud-user/ofed/

etc/kayobe/ansible/push-ofed.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
- name: Push OFED packages
3+
hosts: ofed-builder
4+
vars:
5+
stackhpc_mlnx_ofed_file_string: MLNX_OFED_LINUX-{{ stackhpc_pulp_mlnx_ofed_version }}-rhel9.{{ stackhpc_pulp_repo_rocky_9_minor_version }}-x86_64
6+
tasks:
7+
- name: Install python dependencies
8+
ansible.builtin.pip:
9+
name: pulp-cli
10+
11+
- name: Assign timestamp variable
12+
ansible.builtin.set_fact:
13+
stackhpc_pulp_repo_mlnx_ofed_rhel9_version: "{{ ansible_facts.date_time.iso8601_micro }}"
14+
15+
- name: Append timestamp to pulp-repo-versions
16+
ansible.builtin.lineinfile:
17+
path: "{{ lookup('env', 'KAYOBE_CONFIG_PATH') }}/pulp-repo-versions.yml"
18+
line: "stackhpc_pulp_repo_mlnx_ofed_rhel9_version: {{ stackhpc_pulp_repo_mlnx_ofed_rhel9_version }}"
19+
20+
- name: Create Pulp repository for OFED
21+
pulp.squeezer.rpm_repository:
22+
pulp_url: "{{ stackhpc_release_pulp_url }}"
23+
username: "{{ stackhpc_release_pulp_username }}"
24+
password: "{{ stackhpc_release_pulp_password }}"
25+
name: "{{ stackhpc_pulp_repo_mlnx_ofed_rhel9.name }}"
26+
state: present
27+
retries: "{{ pulp_timeout_retries | default(3) }}"
28+
29+
- name: Upload OFED RPMs to Pulp
30+
ansible.builtin.shell:
31+
cmd: |
32+
pulp \
33+
--base-url '{{ stackhpc_release_pulp_url }}' \
34+
--username '{{ stackhpc_release_pulp_username }}' \
35+
--password '{{ stackhpc_release_pulp_password }}' \
36+
rpm content \
37+
--type package upload \
38+
--repository '{{ stackhpc_pulp_repo_mlnx_ofed_rhel9.name }}' \
39+
--file {{ item }} \
40+
with_fileglob: "/home/cloud-user/ofed/{{ stackhpc_mlnx_ofed_file_string }}-ext/RPMS/*.rpm"
41+
no_log: true
42+
43+
- name: Create Pulp publication for OFED
44+
pulp.squeezer.rpm_publication:
45+
pulp_url: "{{ stackhpc_release_pulp_url }}"
46+
username: "{{ stackhpc_release_pulp_username }}"
47+
password: "{{ stackhpc_release_pulp_password }}"
48+
repository: "{{ stackhpc_pulp_repo_mlnx_ofed_rhel9.name }}"
49+
state: present
50+
51+
- name: Create Pulp distribution for OFED
52+
pulp.squeezer.rpm_distribution:
53+
pulp_url: "{{ stackhpc_release_pulp_url }}"
54+
username: "{{ stackhpc_release_pulp_username }}"
55+
password: "{{ stackhpc_release_pulp_password }}"
56+
name: "{{ stackhpc_pulp_repo_mlnx_ofed_rhel9.distribution_name }}"
57+
base_path: "{{ stackhpc_pulp_repo_mlnx_ofed_rhel9.base_path }}"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# A 'seed' host used for building images.
2+
3+
[ofed-builder:children]
4+
seed
5+
26
[seed]
37
builder

etc/kayobe/pulp.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,19 @@ stackhpc_pulp_distribution_rpm_production: >-
412412
{%- endfor -%}
413413
{{ prod_dists }}
414414
415+
###############################################################################
416+
# Mellanox OFED
417+
418+
# Mellanox OFED version
419+
stackhpc_pulp_mlnx_ofed_version: 24.04-0.7.0.0
420+
421+
# Mellanox OFED repositories
422+
stackhpc_pulp_repo_mlnx_ofed_rhel9:
423+
name: Mellanox Technologies mlnx_ofed {{ stackhpc_pulp_mlnx_ofed_version }} Rocky 9.{{ stackhpc_pulp_repo_rocky_9_minor_version }}
424+
url: "{{ stackhpc_release_pulp_content_url }}/mlnx_ofed/{{ stackhpc_pulp_mlnx_ofed_version }}/rhel9.{{ stackhpc_pulp_repo_rocky_9_minor_version }}/x86_64/{{ stackhpc_pulp_repo_mlnx_ofed_rhel9_version }}"
425+
distribution_name: "mlnx-ofed-{{ stackhpc_pulp_mlnx_ofed_version }}-rocky-9-{{ stackhpc_pulp_repo_rocky_9_minor_version }}-"
426+
base_path: "mlnx_ofed/{{ stackhpc_pulp_mlnx_ofed_version }}/rhel9.{{ stackhpc_pulp_repo_rocky_9_minor_version }}/x86_64/"
427+
415428
###############################################################################
416429
# Containers
417430

0 commit comments

Comments
 (0)