1
-
2
1
name : Build fat image
3
2
on :
4
3
workflow_dispatch :
5
- inputs :
6
- ci_cloud :
7
- description : ' Select the CI_CLOUD'
8
- required : true
9
- type : choice
10
- options :
11
- - LEAFCLOUD
12
- - SMS
13
- - ARCUS
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
+
14
14
jobs :
15
15
openstack :
16
16
name : openstack-imagebuild
25
25
- RL8
26
26
- RL9
27
27
build :
28
- - openstack.openhpc-ofed
28
+ - openstack.openhpc
29
29
- openstack.openhpc-cuda
30
30
exclude :
31
31
- os_version : RL8
34
34
ANSIBLE_FORCE_COLOR : True
35
35
OS_CLOUD : openstack
36
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
+
37
49
steps :
38
50
- uses : actions/checkout@v2
39
51
@@ -52,10 +64,10 @@ jobs:
52
64
- name : Add bastion's ssh key to known_hosts
53
65
run : cat environments/.stackhpc/bastion_fingerprints >> ~/.ssh/known_hosts
54
66
shell : bash
55
-
67
+
56
68
- name : Install ansible etc
57
69
run : dev/setup-env.sh
58
-
70
+
59
71
- name : Write clouds.yaml
60
72
run : |
61
73
mkdir -p ~/.config/openstack/
@@ -66,17 +78,25 @@ jobs:
66
78
run : |
67
79
. venv/bin/activate
68
80
. environments/.stackhpc/activate
69
-
81
+
70
82
- name : Build fat image with packer
71
83
id : packer_build
72
84
run : |
85
+ set -x
73
86
. venv/bin/activate
74
87
. environments/.stackhpc/activate
75
88
cd packer/
76
89
packer init .
77
- PACKER_LOG=1 packer build -on-error=${{ vars.PACKER_ON_ERROR }} -only=${{ matrix.build }} -var-file=$PKR_VAR_environment_root/${{ env.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
78
97
env :
79
98
PKR_VAR_os_version : ${{ matrix.os_version }}
99
+ SOURCE_IMAGE : ${{ fromJSON(env.SOURCE_IMAGES_MAP)[matrix.os_version][matrix.build] }}
80
100
81
101
- name : Get created image names from manifest
82
102
id : manifest
@@ -87,53 +107,14 @@ jobs:
87
107
sleep 5
88
108
done
89
109
IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID)
90
- echo "image-name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
91
- echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT"
92
-
93
- - name : Download image
94
- run : |
95
- . venv/bin/activate
96
- sudo mkdir /mnt/images
97
- sudo chmod 777 /mnt/images
98
- openstack image save --file /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-name }}
99
-
100
- - name : Set up QEMU
101
- uses : docker/setup-qemu-action@v3
102
-
103
- - name : install libguestfs
104
- run : |
105
- sudo apt -y update
106
- sudo apt -y install libguestfs-tools
107
-
108
- - name : mkdir for mount
109
- run : sudo mkdir -p './${{ steps.manifest.outputs.image-name }}'
110
-
111
- - name : mount qcow2 file
112
- run : sudo guestmount -a /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 -i --ro -o allow_other './${{ steps.manifest.outputs.image-name }}'
113
-
114
- - name : Run Trivy vulnerability scanner
115
- uses :
aquasecurity/[email protected]
116
- with :
117
- scan-type : fs
118
- scan-ref : " ${{ steps.manifest.outputs.image-name }}"
119
- scanners : " vuln"
120
- format : sarif
121
- output : " ${{ steps.manifest.outputs.image-name }}.sarif"
122
- # turn off secret scanning to speed things up
123
-
124
- - name : Upload Trivy scan results to GitHub Security tab
125
- uses : github/codeql-action/upload-sarif@v3
126
- with :
127
- sarif_file : " ${{ steps.manifest.outputs.image-name }}.sarif"
128
- category : " ${{ matrix.os_version }}-${{ matrix.build }}"
110
+ echo $IMAGE_ID > image-id.txt
111
+ echo $IMAGE_NAME > image-name.txt
129
112
130
- - name : Fail if scan has CRITICAL vulnerabilities
131
- uses :
aquasecurity/[email protected]
113
+ - name : Upload manifest artifact
114
+ uses : actions/upload-artifact@v4
132
115
with :
133
- scan-type : fs
134
- scan-ref : " ${{ steps.manifest.outputs.image-name }}"
135
- scanners : " vuln"
136
- format : table
137
- exit-code : ' 1'
138
- severity : ' CRITICAL'
139
- 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