2
2
# $ PACKER_LOG=1 packer build --on-error=ask -var-file=<something>.pkrvars.hcl openstack.pkr.hcl
3
3
4
4
# "timestamp" template function replacement:s
5
- locals { timestamp = formatdate (" YYMMDD-hhmm" , timestamp ())}
5
+ locals {
6
+ timestamp = formatdate (" YYMMDD-hhmm" , timestamp ())
7
+ # a lookup table to change image name with var.ofed_install:
8
+ image_name_suffix = {
9
+ true = " -ofed"
10
+ false = " "
11
+ }
12
+ }
6
13
7
14
variable "source_image_name" {
8
15
type = string
@@ -20,7 +27,12 @@ variable "ssh_bastion_username" {
20
27
}
21
28
22
29
variable "port_id" {
23
- type = string
30
+ type = string # set by Terraform templating arcus.builder.pkrvars.hcl
31
+ }
32
+
33
+ variable "ofed_install" {
34
+ type = string # set by github CI via environment variables
35
+ default = " false"
24
36
}
25
37
26
38
source "openstack" "openhpc" {
@@ -33,31 +45,18 @@ source "openstack" "openhpc" {
33
45
ssh_bastion_host = " 128.232.222.183"
34
46
ssh_bastion_username = " ${ var . ssh_bastion_username } "
35
47
ssh_bastion_private_key_file = " ~/.ssh/id_rsa"
48
+ image_name = " ${ source . name } -${ local . timestamp } ${ local . image_name_suffix [var . ofed_install ]} .qcow2"
36
49
ports = [var . port_id ]
37
50
}
38
51
39
52
build {
40
53
source "source.openstack.openhpc" {
41
- name = " inbox"
42
- image_name = " openhpc-${ local . timestamp } .qcow2"
43
- }
44
-
45
- source "source.openstack.openhpc" {
46
- name = " ofed"
47
- image_name = " openhpc-${ local . timestamp } -ofed.qcow2"
48
54
}
49
55
50
56
provisioner "ansible" {
51
57
playbook_file = " playbooks/build.yml" # can't use ansible FQCN here
52
58
use_proxy = false # see https://www.packer.io/docs/provisioners/ansible#troubleshooting
53
- override = {
54
- inbox = {
55
- extra_arguments = [" -v" ]
56
- }
57
- ofed = {
58
- extra_arguments = concat ([" -v" ], [" -e" , " ofed_install=yes" ])
59
- }
60
- }
59
+ extra_arguments = [" -v" , " -e" , " ofed_install=${ var . ofed_install } " ]
61
60
ansible_ssh_extra_args = [" -o ProxyCommand='ssh ${ var . ssh_bastion_username } @${ var . ssh_bastion_host } -W %h:%p'" ]
62
61
}
63
62
0 commit comments