forked from hashicorp-education/learn-nomad-cluster-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.pkr.hcl
67 lines (56 loc) · 1.51 KB
/
image.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
locals {
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
}
variable "aws_region" {
type = string
default = "us-east-1"
}
data "amazon-ami" "hashistack" {
filters = {
architecture = "x86_64"
"block-device-mapping.volume-type" = "gp2"
name = "ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
region = var.aws_region
}
source "amazon-ebs" "hashistack" {
ami_name = "hashistack ${local.timestamp}"
instance_type = "t2.medium"
region = var.aws_region
source_ami = "${data.amazon-ami.hashistack.id}"
ssh_username = "ubuntu"
force_deregister = true
force_delete_snapshot = true
tags = {
Name = "nomad-alb"
source = "hashicorp/learn"
purpose = "demo"
OS_Version = "Ubuntu"
Release = "Latest"
Base_AMI_ID = "{{ .SourceAMI }}"
Base_AMI_Name = "{{ .SourceAMIName }}"
}
snapshot_tags = {
Name = "nomad-alb"
source = "hashicorp/learn"
purpose = "demo"
}
}
build {
sources = ["source.amazon-ebs.hashistack"]
provisioner "shell" {
inline = ["sudo mkdir /ops", "sudo chmod 777 /ops"]
}
provisioner "file" {
destination = "/ops"
source = "shared"
}
provisioner "shell" {
environment_vars = ["INSTALL_NVIDIA_DOCKER=false"]
script = "shared/scripts/setup.sh"
}
}