-
Notifications
You must be signed in to change notification settings - Fork 23
IPA build workflow #1414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
IPA build workflow #1414
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f62b7d4
Add checksum support
assumptionsandg b88c529
debug
assumptionsandg 699d615
Remove debug
assumptionsandg 53dc815
IPA Release Train workflow
assumptionsandg 76b22bf
Finishing touches
assumptionsandg 147e2f6
Documentation
assumptionsandg 0198c00
Apply suggestions from code review
assumptionsandg 91da97f
Update artifact-type to ipa-images
assumptionsandg 5a74e2f
Update overcloud IPA URLs
assumptionsandg a507077
Update release note
assumptionsandg b0cf130
Disable StackHPC repos
assumptionsandg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,343 @@ | ||
--- | ||
name: Build IPA images | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
rocky9: | ||
description: Build Rocky Linux 9 | ||
type: boolean | ||
default: true | ||
ubuntu-jammy: | ||
description: Build Ubuntu 22.04 Jammy | ||
type: boolean | ||
default: true | ||
secrets: | ||
KAYOBE_VAULT_PASSWORD: | ||
required: true | ||
CLOUDS_YAML: | ||
required: true | ||
OS_APPLICATION_CREDENTIAL_ID: | ||
required: true | ||
OS_APPLICATION_CREDENTIAL_SECRET: | ||
required: true | ||
|
||
env: | ||
ANSIBLE_FORCE_COLOR: True | ||
KAYOBE_ENVIRONMENT: ci-builder | ||
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }} | ||
jobs: | ||
ipa-image-build: | ||
name: Build IPA images | ||
if: github.repository == 'stackhpc/stackhpc-kayobe-config' | ||
runs-on: arc-skc-host-image-builder-runner | ||
permissions: {} | ||
steps: | ||
- name: Install Package | ||
uses: ConorMacBride/install-package@main | ||
with: | ||
apt: git unzip nodejs python3-pip python3-venv openssh-server openssh-client jq | ||
|
||
- name: Start the SSH service | ||
run: | | ||
sudo /etc/init.d/ssh start | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
path: src/kayobe-config | ||
|
||
- name: Output image tag of the builder | ||
id: builder_image_tag | ||
run: | | ||
echo image_tag=$(grep stackhpc_rocky_9_overcloud_host_image_version: etc/kayobe/pulp-host-image-versions.yml | awk '{print $2}') >> $GITHUB_OUTPUT | ||
|
||
- name: Determine OpenStack release | ||
id: openstack_release | ||
run: | | ||
BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' src/kayobe-config/.gitreview) | ||
echo "openstack_release=${BRANCH}" | sed -E "s,(stable|unmaintained)/,," >> $GITHUB_OUTPUT | ||
|
||
- name: Generate IPA image tag | ||
id: ipa_image_tag | ||
run: | | ||
echo "ipa_image_tag=$(date +${{ steps.openstack_release.outputs.openstack_release }}-%Y%m%dT%H%M%S)" >> $GITHUB_OUTPUT | ||
|
||
- name: Display IPA image tag | ||
run: | | ||
echo "${{ steps.ipa_image_tag.outputs.ipa_image_tag }}" | ||
|
||
- name: Install Kayobe | ||
run: | | ||
mkdir -p venvs && | ||
pushd venvs && | ||
python3 -m venv kayobe && | ||
source kayobe/bin/activate && | ||
pip install -U pip && | ||
pip install -r ../src/kayobe-config/requirements.txt | ||
|
||
- name: Install terraform | ||
uses: hashicorp/setup-terraform@v2 | ||
|
||
- name: Initialise terraform | ||
run: terraform init | ||
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio | ||
|
||
- name: Generate SSH keypair | ||
run: ssh-keygen -f id_rsa -N '' | ||
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio | ||
|
||
- name: Generate clouds.yaml | ||
run: | | ||
cat << EOF > clouds.yaml | ||
${{ secrets.CLOUDS_YAML }} | ||
EOF | ||
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio | ||
|
||
- name: Generate terraform.tfvars | ||
run: | | ||
cat << EOF > terraform.tfvars | ||
ssh_public_key = "id_rsa.pub" | ||
ssh_username = "ubuntu" | ||
aio_vm_name = "skc-ipa-image-builder" | ||
aio_vm_image = "Ubuntu-22.04" | ||
aio_vm_flavor = "en1.large" | ||
aio_vm_network = "stackhpc-ci" | ||
aio_vm_subnet = "stackhpc-ci" | ||
aio_vm_interface = "ens3" | ||
aio_vm_volume_size = 100 | ||
EOF | ||
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio | ||
|
||
- name: Terraform Plan | ||
run: terraform plan | ||
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio | ||
env: | ||
OS_CLOUD: "openstack" | ||
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }} | ||
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }} | ||
|
||
- name: Terraform Apply | ||
run: | | ||
for attempt in $(seq 5); do | ||
if terraform apply -auto-approve; then | ||
echo "Created infrastructure on attempt $attempt" | ||
exit 0 | ||
fi | ||
echo "Failed to create infrastructure on attempt $attempt" | ||
sleep 10 | ||
terraform destroy -auto-approve | ||
sleep 60 | ||
done | ||
echo "Failed to create infrastructure after $attempt attempts" | ||
exit 1 | ||
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio | ||
env: | ||
OS_CLOUD: "openstack" | ||
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }} | ||
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }} | ||
|
||
- name: Get Terraform outputs | ||
id: tf_outputs | ||
run: | | ||
terraform output -json | ||
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio | ||
|
||
- name: Write Terraform outputs | ||
run: | | ||
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-outputs.yml | ||
${{ steps.tf_outputs.outputs.stdout }} | ||
EOF | ||
|
||
- name: Write Terraform network config | ||
run: | | ||
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-network-allocation.yml | ||
--- | ||
aio_ips: | ||
builder: "{{ access_ip_v4.value }}" | ||
EOF | ||
|
||
- name: Write Terraform network interface config | ||
run: | | ||
mkdir -p src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed | ||
rm -f src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces | ||
cat << EOF > src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces | ||
admin_interface: "{{ access_interface.value }}" | ||
aio_interface: "{{ access_interface.value }}" | ||
EOF | ||
|
||
- name: Manage SSH keys | ||
run: | | ||
mkdir -p ~/.ssh | ||
touch ~/.ssh/authorized_keys | ||
cat src/kayobe-config/terraform/aio/id_rsa.pub >> ~/.ssh/authorized_keys | ||
cp src/kayobe-config/terraform/aio/id_rsa* ~/.ssh/ | ||
|
||
- name: Bootstrap the control host | ||
run: | | ||
source venvs/kayobe/bin/activate && | ||
source src/kayobe-config/kayobe-env --environment ci-builder && | ||
kayobe control host bootstrap | ||
|
||
- name: Configure the seed host (Builder VM) | ||
run: | | ||
source venvs/kayobe/bin/activate && | ||
source src/kayobe-config/kayobe-env --environment ci-builder && | ||
kayobe seed host configure \ | ||
-e seed_bootstrap_user=ubuntu \ | ||
--skip-tags network,apt,docker,docker-registry | ||
env: | ||
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
source venvs/kayobe/bin/activate && | ||
source src/kayobe-config/kayobe-env --environment ci-builder && | ||
kayobe seed host command run \ | ||
--command "sudo apt update && sudo apt -y install gcc git libffi-dev python3-dev python-is-python3 python3-venv" --show-output | ||
env: | ||
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }} | ||
|
||
- name: Build a Ubuntu 22.04 Jammy IPA image | ||
id: build_ubuntu_jammy_ipa | ||
continue-on-error: true | ||
run: | | ||
source venvs/kayobe/bin/activate && | ||
source src/kayobe-config/kayobe-env --environment ci-builder && | ||
kayobe overcloud deployment image build --force-rebuild \ | ||
-e os_distribution="ubuntu" \ | ||
-e os_release="jammy" \ | ||
-e ipa_ci_builder_distribution="ubuntu" | ||
env: | ||
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }} | ||
if: inputs.ubuntu-jammy | ||
|
||
- name: Show last error logs | ||
continue-on-error: true | ||
run: | | ||
source venvs/kayobe/bin/activate && | ||
source src/kayobe-config/kayobe-env --environment ci-builder && | ||
kayobe seed host command run --command "tail -200 /opt/kayobe/images/ipa/ipa.stdout" --show-output | ||
env: | ||
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }} | ||
if: steps.build_ubuntu_jammy_ipa.outcome == 'failure' | ||
|
||
- name: Upload Ubuntu 22.04 Jammy IPA kernel image to Ark | ||
run: | | ||
source venvs/kayobe/bin/activate && | ||
source src/kayobe-config/kayobe-env --environment ci-builder && | ||
kayobe playbook run \ | ||
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \ | ||
-e artifact_path=/opt/kayobe/images/ipa \ | ||
-e artifact_type=ipa \ | ||
assumptionsandg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
-e artifact_tag=${{ steps.ipa_image_tag.outputs.ipa_image_tag }} \ | ||
-e os_distribution="ubuntu" \ | ||
-e os_release="jammy" \ | ||
-e file_regex='*.kernel' \ | ||
-e upload_checksum=true | ||
env: | ||
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }} | ||
if: inputs.ubuntu-jammy && steps.build_ubuntu_jammy_ipa.outcome == 'success' | ||
|
||
- name: Upload Ubuntu 22.04 Jammy IPA ramdisk image to Ark | ||
run: | | ||
source venvs/kayobe/bin/activate && | ||
source src/kayobe-config/kayobe-env --environment ci-builder && | ||
kayobe playbook run \ | ||
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \ | ||
-e artifact_path=/opt/kayobe/images/ipa \ | ||
-e artifact_type=ipa \ | ||
assumptionsandg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
-e artifact_tag=${{ steps.ipa_image_tag.outputs.ipa_image_tag }} \ | ||
-e os_distribution="ubuntu" \ | ||
-e os_release="jammy" \ | ||
-e file_regex='*.initramfs' \ | ||
-e upload_checksum=true | ||
env: | ||
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }} | ||
if: inputs.ubuntu-jammy && steps.build_ubuntu_jammy_ipa.outcome == 'success' | ||
|
||
- name: Build a Rocky 9 IPA image | ||
id: build_rocky_9_ipa | ||
continue-on-error: true | ||
run: | | ||
source venvs/kayobe/bin/activate && | ||
source src/kayobe-config/kayobe-env --environment ci-builder && | ||
kayobe overcloud deployment image build --force-rebuild \ | ||
-e os_distribution="rocky" \ | ||
-e os_release="9" \ | ||
-e ipa_ci_builder_distribution="rocky" | ||
env: | ||
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }} | ||
if: inputs.rocky9 | ||
|
||
- name: Show last error logs | ||
continue-on-error: true | ||
run: | | ||
source venvs/kayobe/bin/activate && | ||
source src/kayobe-config/kayobe-env --environment ci-builder && | ||
kayobe seed host command run --command "tail -200 /opt/kayobe/images/ipa/ipa.stdout" --show-output | ||
env: | ||
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }} | ||
if: steps.build_rocky_9_ipa.outcome == 'failure' | ||
|
||
- name: Upload Rocky 9 IPA kernel image to Ark | ||
run: | | ||
source venvs/kayobe/bin/activate && | ||
source src/kayobe-config/kayobe-env --environment ci-builder && | ||
kayobe playbook run \ | ||
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \ | ||
-e artifact_path=/opt/kayobe/images/ipa \ | ||
-e artifact_type=ipa \ | ||
-e artifact_tag=${{ steps.ipa_image_tag.outputs.ipa_image_tag }} \ | ||
-e os_distribution="rocky" \ | ||
-e os_release="9" \ | ||
-e file_regex='*.kernel' \ | ||
-e upload_checksum=true | ||
env: | ||
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }} | ||
if: inputs.rocky9 && steps.build_rocky_9_ipa.outcome == 'success' | ||
|
||
- name: Upload Rocky 9 IPA ramdisk image to Ark | ||
run: | | ||
source venvs/kayobe/bin/activate && | ||
source src/kayobe-config/kayobe-env --environment ci-builder && | ||
kayobe playbook run \ | ||
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \ | ||
-e artifact_path=/opt/kayobe/images/ipa \ | ||
-e artifact_type=ipa \ | ||
-e artifact_tag=${{ steps.ipa_image_tag.outputs.ipa_image_tag }} \ | ||
-e os_distribution="rocky" \ | ||
-e os_release="9" \ | ||
-e file_regex='*.initramfs' \ | ||
-e upload_checksum=true | ||
env: | ||
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }} | ||
if: inputs.rocky9 && steps.build_rocky_9_ipa.outcome == 'success' | ||
|
||
- name: Copy logs back | ||
continue-on-error: true | ||
run: | | ||
mkdir logs | ||
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/ | ||
if: always() | ||
|
||
- name: Upload logs artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Build logs | ||
path: ./logs | ||
|
||
- name: Fail if the IPA image build failed | ||
run: | | ||
echo "Builds failed. See workflow artifacts for details." && | ||
exit 1 | ||
if: steps.build_rocky_9_ipa.outcome == 'failure' || | ||
steps.build_ubuntu_jammy_ipa.outcome == 'failure' | ||
|
||
- name: Destroy | ||
run: terraform destroy -auto-approve | ||
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio | ||
env: | ||
OS_CLOUD: openstack | ||
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }} | ||
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }} | ||
if: always() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.