-
Notifications
You must be signed in to change notification settings - Fork 328
/
Copy pathsmb.pkr.hcl
88 lines (78 loc) · 2.32 KB
/
smb.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
packer {
required_plugins {
amazon = {
source = "github.com/hashicorp/amazon"
version = "~> 1"
}
}
}
variable "BRANCH" {
type = string
default = "main"
}
variable "MY_ACCESS_KEY" {
type = string
default = ""
}
variable "MY_SECRET_KEY" {
type = string
default = ""
}
data "amazon-ami" "jammy" {
access_key = "${var.MY_ACCESS_KEY}"
filters = {
name = "ubuntu/images/*ubuntu-jammy-22.04-arm64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
region = "us-east-1"
secret_key = "${var.MY_SECRET_KEY}"
}
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
source "amazon-ebs" "jammy" {
access_key = "${var.MY_ACCESS_KEY}"
ami_name = "ce-smb arm packer 22.04 @ ${local.timestamp}"
associate_public_ip_address = true
iam_instance_profile = "XaniaBlog"
instance_type = "t4g.large"
launch_block_device_mappings {
delete_on_termination = true
device_name = "/dev/sda1"
volume_size = 20
volume_type = "gp2"
}
region = "us-east-1"
run_volume_tags = {
Site = "CompilerExplorer"
}
secret_key = "${var.MY_SECRET_KEY}"
security_group_id = "sg-f53f9f80"
source_ami = "${data.amazon-ami.jammy.id}"
ssh_username = "ubuntu"
subnet_id = "subnet-1df1e135"
tags = {
Site = "CompilerExplorer"
}
vpc_id = "vpc-17209172"
}
build {
sources = ["source.amazon-ebs.jammy"]
provisioner "file" {
destination = "/home/ubuntu/"
source = "packer"
}
provisioner "shell" {
execute_command = "{{ .Vars }} sudo -E bash '{{ .Path }}'"
inline = [
"set -euo pipefail",
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
"export DEBIAN_FRONTEND=noninteractive", "mkdir -p /root/.ssh",
"cp /home/ubuntu/packer/known_hosts /root/.ssh/", "cp /home/ubuntu/packer/known_hosts /home/ubuntu/.ssh/",
"rm -rf /home/ubuntu/packer", "apt-get -y update", "apt-get -y install git",
"git clone -b ${var.BRANCH} https://github.com/compiler-explorer/infra.git /infra", "cd /infra",
"env PACKER_SETUP=yes bash setup-smb.sh 2>&1 | tee /tmp/setup.log"
]
}
}