Skip to content

Commit 745c46f

Browse files
OFED workflow
1 parent 2e40537 commit 745c46f

File tree

5 files changed

+348
-0
lines changed

5 files changed

+348
-0
lines changed
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
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+
# Must be a Rocky Linux 9 host to successfully build all images
92+
# This MUST NOT be an LVM image. It can cause confusing conficts with the built image.
93+
aio_vm_image = "Rocky-9-GenericCloud-Base-9.3-20231113.0.x86_64.qcow2"
94+
aio_vm_flavor = "en1.medium"
95+
aio_vm_network = "stackhpc-ci"
96+
aio_vm_subnet = "stackhpc-ci"
97+
aio_vm_interface = "eth0"
98+
EOF
99+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
100+
101+
- name: Terraform Plan
102+
run: terraform plan
103+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
104+
env:
105+
OS_CLOUD: "openstack"
106+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
107+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
108+
109+
- name: Terraform Apply
110+
run: |
111+
for attempt in $(seq 5); do
112+
if terraform apply -auto-approve; then
113+
echo "Created infrastructure on attempt $attempt"
114+
exit 0
115+
fi
116+
echo "Failed to create infrastructure on attempt $attempt"
117+
sleep 10
118+
terraform destroy -auto-approve
119+
sleep 60
120+
done
121+
echo "Failed to create infrastructure after $attempt attempts"
122+
exit 1
123+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
124+
env:
125+
OS_CLOUD: "openstack"
126+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
127+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
128+
129+
- name: Get Terraform outputs
130+
id: tf_outputs
131+
run: |
132+
terraform output -json
133+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
134+
135+
- name: Write Terraform outputs
136+
run: |
137+
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-outputs.yml
138+
${{ steps.tf_outputs.outputs.stdout }}
139+
EOF
140+
141+
- name: Write Terraform network config
142+
run: |
143+
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-network-allocation.yml
144+
---
145+
aio_ips:
146+
builder: "{{ access_ip_v4.value }}"
147+
EOF
148+
149+
- name: Write Terraform network interface config
150+
run: |
151+
mkdir -p src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed
152+
rm -f src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
153+
cat << EOF > src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
154+
admin_interface: "{{ access_interface.value }}"
155+
aio_interface: "{{ access_interface.value }}"
156+
EOF
157+
158+
- name: Manage SSH keys
159+
run: |
160+
mkdir -p ~/.ssh
161+
touch ~/.ssh/authorized_keys
162+
cat src/kayobe-config/terraform/aio/id_rsa.pub >> ~/.ssh/authorized_keys
163+
cp src/kayobe-config/terraform/aio/id_rsa* ~/.ssh/
164+
165+
- name: Bootstrap the control host
166+
run: |
167+
source venvs/kayobe/bin/activate &&
168+
source src/kayobe-config/kayobe-env --environment ci-builder &&
169+
kayobe control host bootstrap
170+
171+
- name: Configure the seed host (Builder VM)
172+
run: |
173+
source venvs/kayobe/bin/activate &&
174+
source src/kayobe-config/kayobe-env --environment ci-builder &&
175+
kayobe seed host configure -e seed_bootstrap_user=rocky --skip-tags network
176+
177+
- name: Run growroot playbook
178+
run: |
179+
source venvs/kayobe/bin/activate &&
180+
source src/kayobe-config/kayobe-env --environment ci-builder &&
181+
kayobe playbook run src/kayobe-config/etc/kayobe/ansible/growroot.yml
182+
env:
183+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }
184+
185+
- name: Run OFED builder playbook
186+
run: |
187+
source venvs/kayobe/bin/activate &&
188+
source src/kayobe-config/kayobe-env --environment ci-builder &&
189+
kayobe playbook run src/kayobe-config/etc/kayobe/ansible/build-ofed.yml
190+
env:
191+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }
192+
193+
- name: Run OFED publish playbook
194+
run: |
195+
source venvs/kayobe/bin/activate &&
196+
source src/kayobe-config/kayobe-env --environment ci-builder &&
197+
kayobe playbook run src/kayobe-config/etc/kayobe/ansible/push-ofed.yml
198+
env:
199+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }
200+
201+
- name: Destroy
202+
run: terraform destroy -auto-approve
203+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
204+
env:
205+
OS_CLOUD: openstack
206+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
207+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
208+
if: always()

etc/kayobe/ansible/build-ofed.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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: Reboot builder to apply kernel update
38+
ansible.builtin.reboot:
39+
reboot_timeout: 600
40+
41+
- name: Create build directory
42+
ansible.builtin.file:
43+
path: /home/cloud-user/ofed
44+
state: directory
45+
mode: 0777
46+
47+
- name: Download MellanoxOFED archive
48+
ansible.builtin.get_url:
49+
url: https://content.mellanox.com/ofed/MLNX_OFED-{{ stackhpc_pulp_mlnx_ofed_version }}/{{ stackhpc_mlnx_ofed_file_string }}.tgz
50+
dest: /home/cloud-user/ofed/ofed-archive
51+
52+
- name: Extract MellanoxOFED archive
53+
ansible.builtin.unarchive:
54+
src: /home/cloud-user/ofed/ofed-archive
55+
dest: /home/cloud-user/ofed
56+
57+
- name: Ensure the current kernel is supported
58+
ansible.builtin.shell:
59+
cmd: |
60+
/home/cloud-user/ofed/{{ stackhpc_mlnx_ofed_file_string }}/mlnx_add_kernel_support.sh \
61+
--mlnx_ofed /home/cloud-user/ofed/{{ stackhpc_mlnx_ofed_file_string }} \
62+
--tmpdir /home/cloud-user/ofed/ofed-build \
63+
--make-tgz -y \
64+
65+
- name: Extract the new archive
66+
ansible.builtin.unarchive:
67+
src: /tmp/{{ stackhpc_mlnx_ofed_file_string }}-ext.tgz
68+
dest: /home/cloud-user/ofed/

etc/kayobe/ansible/push-ofed.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
- name: Push OFED packages
3+
hosts: ofed-builder
4+
gather_facts: false
5+
vars:
6+
stackhpc_mlnx_ofed_file_string: MLNX_OFED_LINUX-{{ stackhpc_pulp_mlnx_ofed_version }}-rhel9.{{ stackhpc_pulp_repo_rocky_9_minor_version }}-x86_64
7+
tasks:
8+
- name: Install python dependencies
9+
ansible.builtin.pip:
10+
name: pulp-cli
11+
12+
- name: Assign timestamp variable
13+
ansible.builtin.set_fact:
14+
stackhpc_pulp_repo_mlnx_ofed_version: "{{ ansible_date_time.iso8601_basic_short }}"
15+
16+
- name: Append timestamp to pulp-repo-versions
17+
ansible.builtin.lineinfile:
18+
path: "{{ lookup('env', KAYOBE_CONFIG_PATH) }}/pulp-repo-versions.yml"
19+
line: "stackhpc_pulp_repo_mlnx_ofed_version: {{ stackhpc_pulp_repo_mlnx_ofed_version }}"
20+
21+
- name: Create Pulp repository for OFED
22+
pulp.squeezer.rpm_repository:
23+
pulp_url: "{{ stackhpc_release_pulp_url }}"
24+
username: "{{ stackhpc_release_pulp_username }}"
25+
password: "{{ stackhpc_release_pulp_password }}"
26+
name: "{{ stackhpc_pulp_repo_mlnx_ofed.name }}"
27+
state: present
28+
retries: "{{ pulp_repository_rpm_repositories_retries }}"
29+
30+
- name: Upload OFED RPMs to Pulp
31+
ansible.builtin.shell:
32+
cmd: |
33+
pulp \
34+
--base-url '{{ stackhpc_release_pulp_url }}' \
35+
--username '{{ stackhpc_release_pulp_username }}' \
36+
--password '{{ stackhpc_release_pulp_password }}' \
37+
rpm content \
38+
--type package upload \
39+
--repository '{{ stackhpc_pulp_repo_mlnx_ofed.name }}' \
40+
--file {{ item }} \
41+
with_fileglob: "/opt/ofed/{{ stackhpc_mlnx_ofed_file_string }}-ext/RPMS/*.rpm"
42+
no_log: true
43+
44+
- name: Create Pulp publication for OFED
45+
pulp.squeezer.rpm_publication:
46+
pulp_url: "{{ stackhpc_release_pulp_url }}"
47+
username: "{{ stackhpc_release_pulp_username }}"
48+
password: "{{ stackhpc_release_pulp_password }}"
49+
repository: "{{ stackhpc_pulp_repo_mlnx_ofed.name }}"
50+
state: present
51+
52+
- name: Create Pulp distribution for OFED
53+
pulp.squeezer.rpm_distribution:
54+
pulp_url: "{{ stackhpc_release_pulp_url }}"
55+
username: "{{ stackhpc_release_pulp_username }}"
56+
password: "{{ stackhpc_release_pulp_password }}"
57+
name: "{{ stackhpc_pulp_repo_mlnx_ofed.distribution_name }}"
58+
base_path: "{{ stackhpc_pulp_repo_mlnx_ofed.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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,16 @@ stackhpc_pulp_repository_rpm_repos: >-
369369
{%- endfor -%}
370370
{{ rpm_repos }}
371371
372+
# Mellanox OFED version
373+
stackhpc_pulp_mlnx_ofed_version: 24.04-0.7.0.0
374+
375+
# Mellanox OFED repositories
376+
stackhpc_pulp_repo_mlnx_ofed:
377+
name: Mellanox Technologies mlnx_ofed {{ stackhpc_pulp_mlnx_ofed_version }}
378+
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_version }}"
379+
distribution_name: "mlnx_ofed_{{ stackhpc_pulp_mlnx_ofed_version }}-"
380+
base_path: "mlnx_ofed/{{ stackhpc_pulp_mlnx_ofed_version }}/rhel9.{{ stackhpc_pulp_repo_rocky_9_minor_version }}/x86_64/"
381+
372382
# Publication format is a subset of distribution.
373383
stackhpc_pulp_publication_rpm_development: "{{ stackhpc_pulp_distribution_rpm_development }}"
374384

0 commit comments

Comments
 (0)