@@ -23,6 +23,7 @@ data "git-commit" "cwd-head" { }
2323locals {
2424 git_commit = data. git-commit . cwd-head . hash
2525 timestamp = formatdate (" YYMMDD-hhmm" , timestamp ())
26+ image_name_suffix = var. image_name_suffix == " " ? " ${ local . timestamp } -${ substr (local. git_commit , 0 , 8 )} : var.image_name_suffix"
2627}
2728
2829# Path pointing to root of repository - automatically set by environment variable PKR_VAR_repo_root
@@ -39,12 +40,6 @@ variable "networks" {
3940 type = list (string )
4041}
4142
42- variable "os_version" {
43- type = string
44- description = " 'RL8' or 'RL9' with default source_image_* mappings"
45- default = " RL9"
46- }
47-
4843# Must supply either source_image_name or source_image_id
4944variable "source_image_name" {
5045 type = string
@@ -123,19 +118,13 @@ variable "volume_type" {
123118}
124119
125120variable "volume_size" {
126- type = map (number )
127- default = {
128- # fat image builds, GB:
129- rocky-latest = 15
130- rocky-latest-cuda = 30
131- openhpc = 15
132- openhpc-cuda = 30
133- }
121+ type = number
122+ default = 15 # same as default non-CUDA build
134123}
135124
136- variable "extra_build_volume_size " {
125+ variable "volume_size_cuda " {
137126 type = number
138- default = 15 # same as default non-CUDA build
127+ default = 30
139128}
140129
141130variable "image_disk_format" {
@@ -148,32 +137,32 @@ variable "metadata" {
148137 default = {}
149138}
150139
151- variable "groups" {
152- type = map (list (string ))
153- description = " Additional inventory groups (other than 'builder') to add build VM to, keyed by source name"
154- default = {
155- # fat image builds:
156- rocky-latest = [" update" , " ofed" ]
157- rocky-latest-cuda = [" update" , " ofed" , " cuda" ]
158- openhpc = [" control" , " compute" , " login" ]
159- openhpc-cuda = [" control" , " compute" , " login" ]
160- }
161- }
162-
163- variable "extra_build_groups" {
140+ variable "inventory_groups" {
164141 type = list (string )
165142 default = []
166143}
167144
168- variable "extra_build_image_name" {
145+ # variable "groups" {
146+ # type = map(list(string))
147+ # description = "Additional inventory groups (other than 'builder') to add build VM to, keyed by source name"
148+ # default = {
149+ # fat image builds:
150+ # rocky-latest = ["update", "ofed"]
151+ # rocky-latest-cuda = ["update", "ofed", "cuda"]
152+ # openhpc = ["control", "compute", "login"]
153+ # openhpc-cuda = ["control", "compute", "login"]
154+ # }
155+ # }
156+
157+ variable "image_name_prefix" {
169158 type = string
170- description = " Infix for 'extra' build image name "
171- default = " extra "
159+ description = " Prefix for built image names "
160+ default = " openhpc "
172161}
173162
174163variable "image_name_suffix" {
175164 type = string
176- description = " Suffix for all build image names"
165+ description = " Suffix for built image names. If not supplied a timestamp+git commit is used "
177166 default = " "
178167}
179168
@@ -182,7 +171,7 @@ source "openstack" "openhpc" {
182171 flavor = var. flavor
183172 use_blockstorage_volume = var. use_blockstorage_volume
184173 volume_type = var. volume_type
185- volume_size = lookup (var. volume_size , source . name , var. extra_build_volume_size )
174+ volume_size = contains (var. inventory_groups , " cuda " ) ? var . volume_size_cuda : var. volume_size
186175 metadata = var. metadata
187176 instance_metadata = {ansible_init_disable = " true" }
188177 networks = var. networks
@@ -210,39 +199,14 @@ source "openstack" "openhpc" {
210199
211200build {
212201
213- # latest nightly image:
214202 source "source.openstack.openhpc" {
215203 name = " rocky-latest"
216- image_name = " ${ source . name } -${ var . os_version } ${ var . image_name_suffix } "
217- }
218-
219- # latest nightly cuda image:
220- source "source.openstack.openhpc" {
221- name = " rocky-latest-cuda"
222- image_name = " ${ source . name } -${ var . os_version } ${ var . image_name_suffix } "
223- }
224-
225- # OFED fat image:
226- source "source.openstack.openhpc" {
227- name = " openhpc"
228- image_name = " ${ source . name } -${ var . os_version } -${ local . timestamp } -${ substr (local. git_commit , 0 , 8 )} ${ var . image_name_suffix } "
229- }
230-
231- # CUDA fat image:
232- source "source.openstack.openhpc" {
233- name = " openhpc-cuda"
234- image_name = " ${ source . name } -${ var . os_version } -${ local . timestamp } -${ substr (local. git_commit , 0 , 8 )} ${ var . image_name_suffix } "
235- }
236-
237- # Extended site-specific image, built on fat image:
238- source "source.openstack.openhpc" {
239- name = " openhpc-extra"
240- image_name = " openhpc-${ var . extra_build_image_name } -${ var . os_version } -${ local . timestamp } -${ substr (local. git_commit , 0 , 8 )} ${ var . image_name_suffix } "
204+ image_name = " ${ var . image_name_prefix } -${ local . image_name_suffix } "
241205 }
242206
243207 provisioner "ansible" {
244208 playbook_file = " ${ var . repo_root } /ansible/fatimage.yml"
245- groups = concat ([" builder" ], lookup ( var. groups , source . name , var . extra_build_groups ) )
209+ groups = concat ([" builder" ], var. inventory_groups )
246210 keep_inventory_file = true # for debugging
247211 use_proxy = false # see https://www.packer.io/docs/provisioners/ansible#troubleshooting
248212 extra_arguments = [
0 commit comments