-
Notifications
You must be signed in to change notification settings - Fork 49
/
almalinux_9_ami.pkr.hcl
124 lines (112 loc) · 3.79 KB
/
almalinux_9_ami.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
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
# AlmaLinux OS 9 Packer template for building Amazon Machine Images (AMI).
# TODO: Enable when https://github.com/hashicorp/packer/issues/11037 is resolved.
/*
data "amazon-ami" "almalinux_9_x86_64" {
filters = {
name = "AlmaLinux OS 9.*"
architecture = "x86_64"
is-public = true
}
owners = ["764336703387"]
most_recent = true
}
data "amazon-ami" "almalinux_9_aarch64" {
filters = {
name = "AlmaLinux OS 9.*"
architecture = "arm64"
is-public = true
}
owners = ["764336703387"]
most_recent = true
}
*/
source "amazon-ebssurrogate" "almalinux_9_ami_x86_64" {
profile = var.aws_profile
region = var.aws_ami_region
ssh_username = "ec2-user"
instance_type = var.aws_instance_type_x86_64
source_ami = var.aws_source_ami_9_x86_64
ami_name = local.aws_ami_name_x86_64_9
ami_description = local.aws_ami_description_x86_64_9
ami_architecture = "x86_64"
ami_virtualization_type = "hvm"
ami_regions = var.aws_ami_regions
tags = {
Name = "${local.aws_ami_name_x86_64_9}"
Version = "${local.aws_ami_version_9}"
Architecture = "x86_64"
}
boot_mode = "uefi-preferred"
imds_support = "v2.0"
# uefi_data = file("tpl/edk2/OVMF_VARS.secboot.fd_20230524-4.el9_3.2.alma.aws") # Enable Secure Boot support.
# tpm_support = "v2.0" # Enable NitroTPM support. Only supported when "boot_mode" is "uefi"
ena_support = true
sriov_support = true
launch_block_device_mappings {
device_name = "/dev/sdb"
volume_size = var.aws_volume_size
volume_type = var.aws_volume_type
delete_on_termination = true
}
ami_root_device {
source_device_name = "/dev/sdb"
device_name = "/dev/sda1"
volume_size = 10
volume_type = var.aws_volume_type
delete_on_termination = true
}
}
source "amazon-ebssurrogate" "almalinux_9_ami_aarch64" {
profile = var.aws_profile
region = var.aws_ami_region
ssh_username = "ec2-user"
instance_type = var.aws_instance_type_aarch64
source_ami = var.aws_source_ami_9_aarch64
ami_name = local.aws_ami_name_aarch64_9
ami_description = local.aws_ami_description_aarch64_9
ami_architecture = "arm64"
ami_virtualization_type = "hvm"
ami_regions = var.aws_ami_regions
tags = {
Name = "${local.aws_ami_name_aarch64_9}"
Version = "${local.aws_ami_version_9}"
Architecture = "aarch64"
}
imds_support = "v2.0"
ena_support = true
sriov_support = true
launch_block_device_mappings {
device_name = "/dev/sdb"
volume_size = var.aws_volume_size
volume_type = var.aws_volume_type
delete_on_termination = true
}
ami_root_device {
source_device_name = "/dev/sdb"
device_name = "/dev/sda1"
volume_size = 10
volume_type = var.aws_volume_type
delete_on_termination = true
}
}
build {
sources = [
"source.amazon-ebssurrogate.almalinux_9_ami_x86_64",
"source.amazon-ebssurrogate.almalinux_9_ami_aarch64",
]
provisioner "shell" {
inline = ["sudo dnf -y install ansible-core dosfstools"]
}
provisioner "ansible-local" {
playbook_dir = "./ansible"
playbook_file = "./ansible/ami_9_x86_64.yaml"
galaxy_file = "./ansible/requirements.yml"
only = ["amazon-ebssurrogate.almalinux_9_ami_x86_64"]
}
provisioner "ansible-local" {
playbook_dir = "./ansible"
playbook_file = "./ansible/ami_9_aarch64.yaml"
galaxy_file = "./ansible/requirements.yml"
only = ["amazon-ebssurrogate.almalinux_9_ami_aarch64"]
}
}