Skip to content

Commit 8a5f060

Browse files
committed
Add an image-build-deploy workflow
1 parent 08f36d2 commit 8a5f060

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

.github/extra_vars/arcus.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Cluster instance vars
2+
cluster_name: "caas-ci"
3+
cluster_id: "{{ cluster_name }}"
4+
openhpc_slurm_partitions:
5+
- name: "small"
6+
count: 2
7+
flavor_name: "vm.ska.cpu.general.small"
8+
default: "YES"
9+
cluster_run_validation: true
10+
cluster_user_ssh_public_key: ""
11+
home_volume_size: 20
12+
13+
# Cloud vars
14+
cluster_external_network: "CUDN-Internet"
15+
login_flavor_name: "vm.ska.cpu.general.small"
16+
control_flavor_name: "vm.ska.cpu.general.small"
17+
metrics_db_maximum_size: 5
18+
19+
# Image build
20+
image_build_manage_infra: false
21+
image_build_flavor_name: "vm.ska.cpu.general.small"
22+
image_build_network_id: "4b6b2722-ee5b-40ec-8e52-a6610e14cc51"
23+
image_build_attach_floating_ip: true
24+
image_build_floating_ip_network: "CUDN-Internet"
25+
image_build_source_image_id: "519c4a1a-efdd-494e-929b-05dce43e1011"
26+
image_build_security_group_id: "486dfc85-099b-4bbb-9375-60f320a7de18"
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
2+
name: Build, deploy and promote a new OHPC image
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
promote_community:
7+
description: 'Set the community property on a successfully tested image'
8+
required: true
9+
default: false
10+
type: boolean
11+
pull_request:
12+
push:
13+
branches:
14+
- main
15+
tags:
16+
- '*'
17+
jobs:
18+
build-deploy-promote:
19+
name: Build, deploy and promote a new OHPC image
20+
if: github.repository == 'stackhpc/caas-slurm-appliance'
21+
concurrency: ${{ github.ref }}
22+
runs-on: ubuntu-20.04
23+
environment:
24+
name: arcus
25+
env:
26+
ANSIBLE_FORCE_COLOR: True
27+
OS_CLOUD: openstack
28+
OS_CLIENT_CONFIG_FILE: ${{ github.workspace }}/clouds.yaml
29+
steps:
30+
- uses: actions/checkout@v2
31+
32+
- name: Install ansible etc
33+
run: dev/setup-env.sh
34+
35+
- name: Write clouds.yaml
36+
run: |
37+
echo "${CLOUDS_YAML}" > ${OS_CLIENT_CONFIG_FILE}
38+
shell: bash
39+
env:
40+
CLOUDS_YAML: ${{ secrets.CLOUDS_YAML }}
41+
42+
- name: Build OHPC image
43+
id: build
44+
run: |
45+
source venv/bin/activate
46+
ansible-playbook \
47+
-i image-build/hosts \
48+
-e @.github/extra_vars/${{ inputs.environment }}.yml \
49+
-e '{"write_cluster_image_uuid_file": true}' \
50+
image-build.yml
51+
echo "CLUSTER_IMAGE=$(cat cluster_image_uuid.txt)" >> $GITHUB_OUTPUT
52+
env:
53+
PACKER_LOG_PATH: ${{ github.workspace }}/packer-build.log
54+
55+
- name: Remove image build infra
56+
run: |
57+
source venv/bin/activate
58+
ansible-playbook \
59+
-i image-build/hosts \
60+
-e @.github/extra_vars/${{ inputs.environment }}.yml \
61+
-e cluster_state=absent \
62+
image-build.yml
63+
if: always()
64+
65+
- name: Deploy a cluster based on the new OPHC image
66+
id: deploy
67+
run: |
68+
source venv/bin/activate
69+
ansible-playbook \
70+
-i image-build/hosts \
71+
-e @.github/extra_vars/${{ inputs.environment }}.yml \
72+
-e cluster_image=${{ steps.build.outputs.CLUSTER_IMAGE }} \
73+
slurm-infra.yml
74+
if: success()
75+
76+
- name: Remove cluster based on the new OHPC image
77+
run: |
78+
source venv/bin/activate
79+
ansible-playbook \
80+
-i image-build/hosts \
81+
-e @.github/extra_vars/${{ inputs.environment }}.yml \
82+
-e cluster_image=${{ steps.build.outputs.CLUSTER_IMAGE }} \
83+
-e cluster_state=absent \
84+
slurm-infra.yml
85+
if: |
86+
( failure() || cancelled() ) &&
87+
steps.build.outcome == 'success'
88+
89+
- name: Delete built image after testing
90+
run: |
91+
source venv/bin/activate
92+
ansible-playbook \
93+
-i image-build/hosts \
94+
-e cluster_image=${{ steps.build.outputs.CLUSTER_IMAGE }} \
95+
-e '{"cluster_image_delete": true}' \
96+
image-build/image-delete-or-promote.yml
97+
if: |
98+
( success() || failure() || cancelled() ) &&
99+
steps.build.outcome == 'success' &&
100+
github.event_name == 'pull_request'
101+
102+
- name: Promote built image from Private to Community after testing
103+
run: |
104+
source venv/bin/activate
105+
ansible-playbook \
106+
-i image-build/hosts \
107+
-e cluster_image=${{ steps.build.outputs.CLUSTER_IMAGE }} \
108+
-e '{"cluster_image_promote_community": true}' \
109+
image-build/image-delete-or-promote.yml
110+
if: |
111+
success() &&
112+
steps.build.outcome == 'success' &&
113+
steps.deploy.outcome == 'success' &&
114+
(( github.event_name == 'workflow_dispatch' && inputs.promote_community == true )
115+
|| github.event_name == 'push' )
116+
117+
- name: Upload packer build log artifact
118+
uses: actions/upload-artifact@v3
119+
with:
120+
name: packer-build-log
121+
path: ${{ github.workspace }}/packer-build.log
122+
if: failure() || success()
123+

0 commit comments

Comments
 (0)