Skip to content

Commit f8f075a

Browse files
OFED workflow
1 parent 2e40537 commit f8f075a

File tree

4 files changed

+313
-0
lines changed

4 files changed

+313
-0
lines changed
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
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: Output image tag of the builder
46+
id: builder_image_tag
47+
run: |
48+
echo image_tag=$(grep stackhpc_rocky_9_overcloud_host_image_version: etc/kayobe/pulp-host-image-versions.yml | awk '{print $2}') >> $GITHUB_OUTPUT
49+
50+
- name: Determine OpenStack release
51+
id: openstack_release
52+
run: |
53+
BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' src/kayobe-config/.gitreview)
54+
echo "openstack_release=${BRANCH}" | sed -E "s,(stable|unmaintained)/,," >> $GITHUB_OUTPUT
55+
56+
- name: Clone StackHPC Kayobe repository
57+
uses: actions/checkout@v4
58+
with:
59+
repository: stackhpc/kayobe
60+
ref: refs/heads/stackhpc/${{ steps.openstack_release.outputs.openstack_release }}
61+
path: src/kayobe
62+
63+
- name: Install Kayobe
64+
run: |
65+
mkdir -p venvs &&
66+
pushd venvs &&
67+
python3 -m venv kayobe &&
68+
source kayobe/bin/activate &&
69+
pip install -U pip &&
70+
pip install ../src/kayobe
71+
72+
- name: Install terraform
73+
uses: hashicorp/setup-terraform@v2
74+
75+
- name: Initialise terraform
76+
run: terraform init
77+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
78+
79+
- name: Generate SSH keypair
80+
run: ssh-keygen -f id_rsa -N ''
81+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
82+
83+
- name: Generate clouds.yaml
84+
run: |
85+
cat << EOF > clouds.yaml
86+
${{ secrets.CLOUDS_YAML }}
87+
EOF
88+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
89+
90+
- name: Generate terraform.tfvars
91+
run: |
92+
cat << EOF > terraform.tfvars
93+
ssh_public_key = "id_rsa.pub"
94+
ssh_username = "rocky"
95+
aio_vm_name = "skc-host-image-builder"
96+
# Must be a Rocky Linux 9 host to successfully build all images
97+
# This MUST NOT be an LVM image. It can cause confusing conficts with the built image.
98+
aio_vm_image = "Rocky-9-GenericCloud-Base-9.3-20231113.0.x86_64.qcow2"
99+
aio_vm_flavor = "en1.medium"
100+
aio_vm_network = "stackhpc-ci"
101+
aio_vm_subnet = "stackhpc-ci"
102+
aio_vm_interface = "eth0"
103+
EOF
104+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
105+
106+
- name: Terraform Plan
107+
run: terraform plan
108+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
109+
env:
110+
OS_CLOUD: "openstack"
111+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
112+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
113+
114+
- name: Terraform Apply
115+
run: |
116+
for attempt in $(seq 5); do
117+
if terraform apply -auto-approve; then
118+
echo "Created infrastructure on attempt $attempt"
119+
exit 0
120+
fi
121+
echo "Failed to create infrastructure on attempt $attempt"
122+
sleep 10
123+
terraform destroy -auto-approve
124+
sleep 60
125+
done
126+
echo "Failed to create infrastructure after $attempt attempts"
127+
exit 1
128+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
129+
env:
130+
OS_CLOUD: "openstack"
131+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
132+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
133+
134+
- name: Get Terraform outputs
135+
id: tf_outputs
136+
run: |
137+
terraform output -json
138+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
139+
140+
- name: Write Terraform outputs
141+
run: |
142+
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-outputs.yml
143+
${{ steps.tf_outputs.outputs.stdout }}
144+
EOF
145+
146+
- name: Write Terraform network config
147+
run: |
148+
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-network-allocation.yml
149+
---
150+
aio_ips:
151+
builder: "{{ access_ip_v4.value }}"
152+
EOF
153+
154+
- name: Write Terraform network interface config
155+
run: |
156+
mkdir -p src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed
157+
rm -f src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
158+
cat << EOF > src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
159+
admin_interface: "{{ access_interface.value }}"
160+
aio_interface: "{{ access_interface.value }}"
161+
EOF
162+
163+
- name: Manage SSH keys
164+
run: |
165+
mkdir -p ~/.ssh
166+
touch ~/.ssh/authorized_keys
167+
cat src/kayobe-config/terraform/aio/id_rsa.pub >> ~/.ssh/authorized_keys
168+
cp src/kayobe-config/terraform/aio/id_rsa* ~/.ssh/
169+
170+
- name: Bootstrap the control host
171+
run: |
172+
source venvs/kayobe/bin/activate &&
173+
source src/kayobe-config/kayobe-env --environment ci-builder &&
174+
kayobe control host bootstrap
175+
176+
- name: Configure the seed host (Builder VM)
177+
run: |
178+
source venvs/kayobe/bin/activate &&
179+
source src/kayobe-config/kayobe-env --environment ci-builder &&
180+
kayobe seed host configure -e seed_bootstrap_user=rocky --skip-tags network
181+
182+
- name: Run OFED builder playbook
183+
run: |
184+
source venvs/kayobe/bin/activate &&
185+
source src/kayobe-config/kayobe-env --environment ci-builder &&
186+
kayobe playbook run src/kayobe-config/etc/kayobe/ansible/build-ofed.yml
187+
env:
188+
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }
189+
190+
- name: Destroy
191+
run: terraform destroy -auto-approve
192+
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
193+
env:
194+
OS_CLOUD: openstack
195+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
196+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
197+
if: always()

etc/kayobe/ansible/build-ofed.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
- name: Build 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 package dependencies
9+
ansible.builtin.dnf:
10+
name:
11+
- std
12+
- debootstrap
13+
- kpartx
14+
- cloud-init
15+
- perl
16+
- rpm-build
17+
- automake
18+
- patch
19+
- kernel-devel
20+
- autoconf
21+
- pciutils
22+
- kernel-rpm-macros
23+
- lsof
24+
- libtool
25+
- tk
26+
- gcc-gfortran
27+
- tcl
28+
state: present
29+
30+
- name: Install python dependencies
31+
ansible.builtin.pip:
32+
name: pulp-cli
33+
34+
- name: Create build directory
35+
ansible.builtin.file:
36+
path: /opt/ofed
37+
state: directory
38+
mode: 0777
39+
become: true
40+
41+
- name: Download MellanoxOFED archive
42+
ansible.builtin.get_url:
43+
url: https://content.mellanox.com/ofed/MLNX_OFED-{{ stackhpc_pulp_mlnx_ofed_version }}/{{ stackhpc_mlnx_ofed_file_string }}.tgz
44+
dest: /opt/ofed/ofed-archive
45+
46+
- name: Extract MellanoxOFED archive
47+
ansible.builtin.unarchive:
48+
src: /opt/ofed/ofed-archive
49+
dest: /opt/ofed
50+
51+
- name: Ensure the current kernel is supported
52+
ansible.builtin.shell:
53+
cmd: |
54+
/opt/ofed/{{ stackhpc_mlnx_ofed_file_string }}/mlnx_add_kernel_support.sh \
55+
--mlnx_ofed /opt/ofed/{{ stackhpc_mlnx_ofed_file_string }} \
56+
--make-tgz -y \
57+
become: true
58+
59+
- name: Extract the new archive
60+
ansible.builtin.unarchive:
61+
src: /tmp/{{ stackhpc_mlnx_ofed_file_string }}-ext.tgz
62+
dest: /opt/ofed
63+
become: true
64+
65+
- name: Create Pulp repository for OFED
66+
pulp.squeezer.rpm_repository:
67+
pulp_url: "{{ stackhpc_release_pulp_url }}"
68+
username: "{{ stackhpc_release_pulp_username }}"
69+
password: "{{ stackhpc_release_pulp_password }}"
70+
name: "{{ stackhpc_pulp_repo_mlnx_ofed.name }}"
71+
state: present
72+
retries: "{{ pulp_repository_rpm_repositories_retries }}"
73+
74+
- name: Upload OFED RPMs to Pulp
75+
ansible.builtin.shell:
76+
cmd: |
77+
pulp \
78+
--base-url '{{ stackhpc_release_pulp_url }}' \
79+
--username '{{ stackhpc_release_pulp_username }}' \
80+
--password '{{ stackhpc_release_pulp_password }}' \
81+
rpm content \
82+
--type package upload \
83+
--repository '{{ stackhpc_pulp_repo_mlnx_ofed.name }}' \
84+
--file {{ item }} \
85+
with_fileglob: "/opt/ofed/{{ stackhpc_mlnx_ofed_file_string }}-ext/RPMS/*.rpm"
86+
no_log: true
87+
88+
- name: Create Pulp publication for OFED
89+
pulp.squeezer.rpm_publication:
90+
pulp_url: "{{ stackhpc_release_pulp_url }}"
91+
username: "{{ stackhpc_release_pulp_username }}"
92+
password: "{{ stackhpc_release_pulp_password }}"
93+
repository: "{{ stackhpc_pulp_repo_mlnx_ofed.name }}"
94+
state: present
95+
96+
- name: Create Pulp distribution for OFED
97+
pulp.squeezer.rpm_distribution:
98+
pulp_url: "{{ stackhpc_release_pulp_url }}"
99+
username: "{{ stackhpc_release_pulp_username }}"
100+
password: "{{ stackhpc_release_pulp_password }}"
101+
name: "{{ stackhpc_pulp_repo_mlnx_ofed.distribution_name }}"
102+
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)