@@ -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_version = var. image_name_version == " auto" ? " -${ local . timestamp } -${ substr (local. git_commit , 0 , 8 )} " : var. image_name_version
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,15 +118,6 @@ variable "volume_type" {
123118}
124119
125120variable "volume_size" {
126- type = map (number )
127- default = {
128- # fat image builds, GB:
129- rocky-latest = 15
130- openhpc = 15
131- }
132- }
133-
134- variable "extra_build_volume_size" {
135121 type = number
136122 default = 15
137123}
@@ -147,34 +133,35 @@ variable "metadata" {
147133}
148134
149135variable "groups" {
150- type = map (list (string ))
151- description = " Additional inventory groups (other than 'builder') to add build VM to, keyed by source name"
152- default = {
153- # fat image builds:
154- rocky-latest = [" update" ]
155- openhpc = [" control" , " compute" , " login" ]
156- }
136+ type = string
137+ description = " Comma-separated list of additional inventory groups (other than 'builder') to add build VM to"
138+ default = " " # this is
139+ # rocky-latest = ["update"]
140+ # openhpc = ["control", "compute", "login"]
157141}
158142
159- variable "extra_build_groups" {
160- type = list (string )
161- default = []
143+ variable "image_name" {
144+ type = string
145+ description = " Name of image"
146+ default = " openhpc"
162147}
163148
164- variable "extra_build_image_name " {
149+ variable "image_name_version " {
165150 type = string
166- description = " Infix for 'extra' build image name "
167- default = " extra "
151+ description = " Suffix for image name giving version. Default of 'auto' appends timestamp + short commit "
152+ default = " auto "
168153}
169154
170155source "openstack" "openhpc" {
171156 # Build VM:
172157 flavor = var. flavor
173158 use_blockstorage_volume = var. use_blockstorage_volume
174159 volume_type = var. volume_type
175- volume_size = lookup ( var. volume_size , source . name , var . extra_build_volume_size )
160+ volume_size = var. volume_size
176161 metadata = var. metadata
177- instance_metadata = {ansible_init_disable = " true" }
162+ instance_metadata = {
163+ ansible_init_disable = " true"
164+ }
178165 networks = var. networks
179166 floating_ip_network = var. floating_ip_network
180167 security_groups = var. security_groups
@@ -201,26 +188,25 @@ source "openstack" "openhpc" {
201188build {
202189
203190 # latest nightly image:
204- source "source.openstack.openhpc" {
205- name = " rocky-latest"
206- image_name = " ${ source . name } -${ var . os_version } "
207- }
191+ # source "source.openstack.openhpc" {
192+ # name = "rocky-latest"
193+ # image_name = "${source.name}-${var.os_version}"
194+ # }
208195
209196 # fat image:
210197 source "source.openstack.openhpc" {
211- name = " openhpc"
212- image_name = " ${ source . name } -${ var . os_version } -${ local . timestamp } -${ substr (local. git_commit , 0 , 8 )} "
198+ image_name = " ${ var . image_name } ${ local . image_name_version } "
213199 }
214200
215- # Extended site-specific image, built on fat image:
216- source "source.openstack.openhpc" {
217- name = " openhpc-extra"
218- image_name = " openhpc-${ var . extra_build_image_name } -${ var . os_version } -${ local . timestamp } -${ substr (local. git_commit , 0 , 8 )} "
219- }
201+ # # Extended site-specific image, built on fat image:
202+ # source "source.openstack.openhpc" {
203+ # name = "openhpc-extra"
204+ # image_name = "openhpc-${var.extra_build_image_name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}"
205+ # }
220206
221207 provisioner "ansible" {
222208 playbook_file = " ${ var . repo_root } /ansible/fatimage.yml"
223- groups = concat ([" builder" ], lookup (var . groups , source . name , var. extra_build_groups ))
209+ groups = concat ([" builder" ], split ( " , " , var. groups ))
224210 keep_inventory_file = true # for debugging
225211 use_proxy = false # see https://www.packer.io/docs/provisioners/ansible#troubleshooting
226212 extra_arguments = [
0 commit comments