-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebserver.pkr.hcl
More file actions
135 lines (123 loc) · 3.74 KB
/
webserver.pkr.hcl
File metadata and controls
135 lines (123 loc) · 3.74 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
packer {
required_plugins {
amazon = {
source = "github.com/hashicorp/amazon"
version = "~> 1"
}
amazon-ami-management = {
version = ">= 1.6.1"
source = "github.com/wata727/amazon-ami-management"
}
ansible = {
source = "github.com/hashicorp/ansible"
version = "~> 1"
}
}
}
# Instance types to use
variable "amd64_instance_type" {
default = "c7a.large"
}
variable "arm64_instance_type" {
default = "c7g.large"
}
# Provider of the Debian base images
variable "account_id" {
default = "136693071363"
}
data "amazon-ami" "debian-amd64-bookworm" {
filters = {
name = "debian-12-amd64-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["${var.account_id}"]
region = "eu-central-1"
}
data "amazon-ami" "debian-arm64-bookworm" {
filters = {
name = "debian-12-arm64-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["${var.account_id}"]
region = "eu-central-1"
}
# codemonauts-amd64-bookworm-webserver-php83
source "amazon-ebs" "codemonauts-amd64-bookworm-webserver-php83" {
ami_groups = ["all"]
ami_name = "codemonauts-amd64-bookworm-webserver-php83_${formatdate("YYYY-MM-DD-hh-mm", timestamp())}"
ami_regions = ["eu-west-1"]
instance_type = "${var.amd64_instance_type}"
region = "eu-central-1"
source_ami = "${data.amazon-ami.debian-amd64-bookworm.id}"
ssh_username = "admin"
tags = {
Amazon_AMI_Management_Identifier = "codemonauts-amd64-bookworm-webserver-php83"
}
}
build {
name = "codemonauts-amd64-bookworm-webserver-php83"
sources = ["source.amazon-ebs.codemonauts-amd64-bookworm-webserver-php83"]
provisioner "shell" {
pause_before = "10s"
inline = [
"sudo apt-get update",
"sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" dist-upgrade",
"sudo DEBIAN_FRONTEND=noninteractive apt-get -y install ansible"
]
}
provisioner "ansible-local" {
playbook_dir = "./"
playbook_file = "webserver.yaml"
extra_arguments = [
"-e",
"php_version=8.3"
]
}
post-processor "amazon-ami-management" {
identifier = "codemonauts-amd64-bookworm-webserver-php83"
keep_releases = "3"
regions = ["eu-central-1"]
}
}
# codemonauts-arm64-bookworm-webserver-php83
source "amazon-ebs" "codemonauts-arm64-bookworm-webserver-php83" {
ami_groups = ["all"]
ami_name = "codemonauts-arm64-bookworm-webserver-php83_${formatdate("YYYY-MM-DD-hh-mm", timestamp())}"
ami_regions = ["eu-west-1"]
instance_type = "${var.arm64_instance_type}"
region = "eu-central-1"
source_ami = "${data.amazon-ami.debian-arm64-bookworm.id}"
ssh_username = "admin"
tags = {
Amazon_AMI_Management_Identifier = "codemonauts-arm64-bookworm-webserver-php83"
}
}
build {
name = "codemonauts-arm64-bookworm-webserver-php83"
sources = ["source.amazon-ebs.codemonauts-arm64-bookworm-webserver-php83"]
provisioner "shell" {
pause_before = "10s"
inline = [
"sudo apt-get update",
"sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" dist-upgrade",
"sudo DEBIAN_FRONTEND=noninteractive apt-get -y install ansible"
]
}
provisioner "ansible-local" {
playbook_dir = "./"
playbook_file = "webserver.yaml"
extra_arguments = [
"-e",
"php_version=8.3"
]
}
post-processor "amazon-ami-management" {
identifier = "codemonauts-arm64-bookworm-webserver-php83"
keep_releases = "3"
regions = ["eu-central-1"]
}
}