Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit 6a1c6de

Browse files
[IT-4417] Also build an arm64 AMI
Install docker compose from a system package (SPAL). Create a duplicate packer builder, changing the platform to arm64. Install gcc and python-devel for building python-psutil from source on arm64.
1 parent 80b3382 commit 6a1c6de

File tree

2 files changed

+63
-21
lines changed

2 files changed

+63
-21
lines changed

src/playbook.yaml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
- hosts: all
55
become: true
66
tasks:
7+
8+
- name: Supplemental Packages for Amazon Linux
9+
ansible.builtin.yum:
10+
name: "spal-release"
11+
state: present
12+
update_cache: true
13+
714
- name: Upgrade all packages
815
ansible.builtin.yum:
916
name: "*"
@@ -17,10 +24,13 @@
1724
with_items:
1825
- "wget"
1926
- "git"
27+
- "gcc"
2028
- "python3-pip"
2129
- "python3-wheel"
30+
- "python3-devel"
2231
- "aws-cfn-bootstrap"
2332
- "chkconfig"
33+
- "docker-compose"
2434

2535
- name: Install python packages
2636
ansible.builtin.pip:
@@ -33,11 +43,6 @@
3343
ansible.builtin.command:
3444
cmd: pip3 freeze
3545

36-
- name: Install docker
37-
ansible.builtin.yum:
38-
name: "docker"
39-
state: present
40-
4146
- name: Start docker service
4247
ansible.builtin.service:
4348
name: docker
@@ -50,18 +55,6 @@
5055
with_items:
5156
- docker
5257

53-
- name: Create docker plugin dir
54-
ansible.builtin.file:
55-
path: /usr/local/lib/docker/cli-plugins
56-
state: directory
57-
mode: '0755'
58-
59-
- name: Download docker-compose
60-
ansible.builtin.get_url:
61-
url: https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64
62-
dest: /usr/local/lib/docker/cli-plugins/docker-compose
63-
mode: +x
64-
6558
- name: Add users to the docker group
6659
ansible.builtin.user:
6760
name: "{{ item }}"

src/template.json

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,60 @@
33
{
44
"access_key": "{{user `aws_access_key`}}",
55
"ami_groups": "{{user `AmiGroups`}}",
6-
"ami_name": "{{user `AmiImageName`}}",
6+
"ami_name": "{{user `AmiImageName`}}-arm64",
77
"assume_role": {
88
"role_arn": "{{user `aws_role_arn`}}"
99
},
1010
"encrypt_boot": "{{user `EncryptBoot`}}",
1111
"force_delete_snapshot": "true",
12-
"instance_type": "{{user `InstanceType`}}",
12+
"instance_type": "{{user `InstanceTypeArm64`}}",
13+
"launch_block_device_mappings": [
14+
{
15+
"delete_on_termination": true,
16+
"device_name": "/dev/xvda",
17+
"volume_size": "{{user `VolumeSize`}}",
18+
"volume_type": "gp3"
19+
}
20+
],
21+
"profile": "{{user `aws_profile`}}",
22+
"region": "{{user `aws_region`}}",
23+
"secret_key": "{{user `aws_secret_key`}}",
24+
"shutdown_behavior": "terminate",
25+
"snapshot_groups": "{{user `SnapshotGroups`}}",
26+
"source_ami_filter": {
27+
"filters": {
28+
"architecture": "arm64",
29+
"name": "al2023-ami-2023*",
30+
"root-device-type": "ebs",
31+
"virtualization-type": "hvm"
32+
},
33+
"most_recent": true,
34+
"owners": [
35+
"amazon"
36+
]
37+
},
38+
"ssh_username": "{{user `SshUsername`}}",
39+
"tags": {
40+
"BuiltBy": "Packer",
41+
"Name": "{{user `AmiImageName`}}",
42+
"OwnerEmail": "{{user `OwnerEmail`}}",
43+
"SourceAmiId": "{{ .SourceAMI }}",
44+
"SourceAmiName": "{{ .SourceAMIName }}"
45+
},
46+
"token": "{{user `aws_session_token`}}",
47+
"type": "amazon-ebs",
48+
"name": "amazon-ebs-arm64"
49+
},
50+
{
51+
"access_key": "{{user `aws_access_key`}}",
52+
"ami_groups": "{{user `AmiGroups`}}",
53+
"ami_name": "{{user `AmiImageName`}}-amd64",
54+
"assume_role": {
55+
"role_arn": "{{user `aws_role_arn`}}"
56+
},
57+
"encrypt_boot": "{{user `EncryptBoot`}}",
58+
"force_delete_snapshot": "true",
59+
"instance_type": "{{user `InstanceTypeAmd64`}}",
1360
"launch_block_device_mappings": [
1461
{
1562
"delete_on_termination": true,
@@ -44,7 +91,8 @@
4491
"SourceAmiName": "{{ .SourceAMIName }}"
4592
},
4693
"token": "{{user `aws_session_token`}}",
47-
"type": "amazon-ebs"
94+
"type": "amazon-ebs",
95+
"name": "amazon-ebs-x86_64"
4896
}
4997
],
5098
"post-processors": [
@@ -70,7 +118,8 @@
70118
"variables": {
71119
"AmiGroups": "all",
72120
"EncryptBoot": "false",
73-
"InstanceType": "t3.small",
121+
"InstanceTypeAmd64": "t3a.small",
122+
"InstanceTypeArm64": "t4g.small",
74123
"OwnerEmail": "it@sagebase.org",
75124
"SnapshotGroups": "all",
76125
"SshUsername": "ec2-user",

0 commit comments

Comments
 (0)