1
-
2
1
name : Build fat image
3
- ' on ' :
2
+ on :
4
3
workflow_dispatch :
5
- concurrency :
6
- group : ${{ github.ref }}-{{ matrix.os_version }}-{{ matrix.build }} # to branch/PR + OS + build
7
- cancel-in-progress : true
4
+ inputs :
5
+ ci_cloud :
6
+ description : ' Select the CI_CLOUD'
7
+ required : true
8
+ type : choice
9
+ options :
10
+ - LEAFCLOUD
11
+ - SMS
12
+ - ARCUS
13
+
8
14
jobs :
9
15
openstack :
10
16
name : openstack-imagebuild
17
+ concurrency :
18
+ group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os_version }}-${{ matrix.build }} # to branch/PR + OS + build
19
+ cancel-in-progress : true
11
20
runs-on : ubuntu-22.04
12
21
strategy :
13
- matrix :
22
+ fail-fast : false # allow other matrix jobs to continue even if one fails
23
+ matrix : # build RL8+OFED, RL9+OFED, RL9+OFED+CUDA versions
14
24
os_version :
15
25
- RL8
16
26
- RL9
17
27
build :
18
28
- openstack.openhpc
19
- - openstack.openhpc-ofed
29
+ - openstack.openhpc-cuda
20
30
exclude :
21
31
- os_version : RL8
22
- build : openstack.openhpc-ofed
23
- - os_version : RL9
24
- build : openstack.openhpc
32
+ build : openstack.openhpc-cuda
25
33
env :
26
34
ANSIBLE_FORCE_COLOR : True
27
35
OS_CLOUD : openstack
28
- CI_CLOUD : ${{ vars.CI_CLOUD }}
36
+ CI_CLOUD : ${{ github.event.inputs.ci_cloud }}
37
+ SOURCE_IMAGES_MAP : |
38
+ {
39
+ "RL8": {
40
+ "openstack.openhpc": "rocky-latest-RL8",
41
+ "openstack.openhpc-cuda": "rocky-latest-cuda-RL8"
42
+ },
43
+ "RL9": {
44
+ "openstack.openhpc": "rocky-latest-RL9",
45
+ "openstack.openhpc-cuda": "rocky-latest-cuda-RL9"
46
+ }
47
+ }
48
+
29
49
steps :
30
50
- uses : actions/checkout@v2
31
51
52
+ - name : Record settings for CI cloud
53
+ run : |
54
+ echo CI_CLOUD: ${{ env.CI_CLOUD }}
55
+
32
56
- name : Setup ssh
33
57
run : |
34
58
set -x
35
59
mkdir ~/.ssh
36
- echo "${{ secrets[format('{0}_SSH_KEY', vars .CI_CLOUD)] }}" > ~/.ssh/id_rsa
60
+ echo "${{ secrets[format('{0}_SSH_KEY', env .CI_CLOUD)] }}" > ~/.ssh/id_rsa
37
61
chmod 0600 ~/.ssh/id_rsa
38
62
shell : bash
39
63
40
64
- name : Add bastion's ssh key to known_hosts
41
65
run : cat environments/.stackhpc/bastion_fingerprints >> ~/.ssh/known_hosts
42
66
shell : bash
43
-
67
+
44
68
- name : Install ansible etc
45
69
run : dev/setup-env.sh
46
-
70
+
47
71
- name : Write clouds.yaml
48
72
run : |
49
73
mkdir -p ~/.config/openstack/
50
- echo "${{ secrets[format('{0}_CLOUDS_YAML', vars .CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
74
+ echo "${{ secrets[format('{0}_CLOUDS_YAML', env .CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
51
75
shell : bash
52
76
53
77
- name : Setup environment
54
78
run : |
55
79
. venv/bin/activate
56
80
. environments/.stackhpc/activate
57
-
81
+
58
82
- name : Build fat image with packer
59
83
id : packer_build
60
84
run : |
85
+ set -x
61
86
. venv/bin/activate
62
87
. environments/.stackhpc/activate
63
88
cd packer/
64
89
packer init .
65
- PACKER_LOG=1 packer build -on-error=${{ vars.PACKER_ON_ERROR }} -only=${{ matrix.build }} -var-file=$PKR_VAR_environment_root/${{ vars.CI_CLOUD }}.pkrvars.hcl openstack.pkr.hcl
90
+
91
+ PACKER_LOG=1 packer build \
92
+ -on-error=${{ vars.PACKER_ON_ERROR }} \
93
+ -only=${{ matrix.build }} \
94
+ -var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \
95
+ -var "source_image_name=${{ env.SOURCE_IMAGE }}" \
96
+ openstack.pkr.hcl
66
97
env :
67
98
PKR_VAR_os_version : ${{ matrix.os_version }}
99
+ SOURCE_IMAGE : ${{ fromJSON(env.SOURCE_IMAGES_MAP)[matrix.os_version][matrix.build] }}
68
100
69
101
- name : Get created image names from manifest
70
102
id : manifest
@@ -75,51 +107,14 @@ jobs:
75
107
sleep 5
76
108
done
77
109
IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID)
78
- echo "image-name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
79
- echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT"
80
-
81
- - name : Download image
82
- run : |
83
- . venv/bin/activate
84
- openstack image save --file ${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-name }}
85
-
86
- - name : Set up QEMU
87
- uses : docker/setup-qemu-action@v3
88
-
89
- - name : install libguestfs
90
- run : |
91
- sudo apt -y update
92
- sudo apt -y install libguestfs-tools
93
-
94
- - name : mkdir for mount
95
- run : sudo mkdir -p './${{ steps.manifest.outputs.image-name }}'
96
-
97
- - name : mount qcow2 file
98
- run : sudo guestmount -a ${{ steps.manifest.outputs.image-name }}.qcow2 -i --ro -o allow_other './${{ steps.manifest.outputs.image-name }}'
99
-
100
- - name : Run Trivy vulnerability scanner
101
- uses :
aquasecurity/[email protected]
102
- with :
103
- scan-type : fs
104
- scan-ref : " ./${{ steps.manifest.outputs.image-name }}"
105
- scanners : " vuln"
106
- format : sarif
107
- output : " ${{ steps.manifest.outputs.image-name }}.sarif"
108
- # turn off secret scanning to speed things up
109
-
110
- - name : Upload Trivy scan results to GitHub Security tab
111
- uses : github/codeql-action/upload-sarif@v3
112
- with :
113
- sarif_file : " ${{ steps.manifest.outputs.image-name }}.sarif"
114
- category : " ${{ matrix.os_version }}-${{ matrix.build }}"
110
+ echo $IMAGE_ID > image-id.txt
111
+ echo $IMAGE_NAME > image-name.txt
115
112
116
- - name : Fail if scan has CRITICAL vulnerabilities
117
- uses :
aquasecurity/[email protected]
113
+ - name : Upload manifest artifact
114
+ uses : actions/upload-artifact@v4
118
115
with :
119
- scan-type : fs
120
- scan-ref : " ./${{ steps.manifest.outputs.image-name }}"
121
- scanners : " vuln"
122
- format : table
123
- exit-code : ' 1'
124
- severity : ' CRITICAL'
125
- ignore-unfixed : true
116
+ name : image-details-${{ matrix.build }}-${{ matrix.os_version }}
117
+ path : |
118
+ ./image-id.txt
119
+ ./image-name.txt
120
+ overwrite : true
0 commit comments