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

Commit ecc77f8

Browse files
authored
Merge pull request #97 from nepeat/arm64-plus-version-bumps
ARM64 support + Version bumps
2 parents 2b3cea9 + 84fabb2 commit ecc77f8

File tree

9 files changed

+99
-24
lines changed

9 files changed

+99
-24
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ jobs:
3939
# AMI already in the AWS Account.
4040
- run: _ci/publish-amis.sh "ubuntu16-ami"
4141
- run: _ci/publish-amis.sh "ubuntu18-ami"
42-
- run: _ci/publish-amis.sh "amazon-linux-2-ami"
42+
- run: _ci/publish-amis.sh "amazon-linux-2-amd64-ami"
43+
- run: _ci/publish-amis.sh "amazon-linux-2-arm64-ami"
4344
workflows:
4445
version: 2
4546
build-and-test:

examples/nomad-consul-ami/nomad-consul-docker.json

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"min_packer_version": "0.12.0",
33
"variables": {
44
"aws_region": "us-east-1",
5-
"nomad_version": "0.9.1",
6-
"consul_module_version": "v0.8.0",
7-
"consul_version": "1.5.1",
5+
"nomad_version": "1.1.1",
6+
"consul_module_version": "v0.10.1",
7+
"consul_version": "1.9.6",
88
"ami_name_prefix": "nomad-consul"
99
},
1010
"builders": [
1111
{
1212
"name": "ubuntu18-ami",
13-
"ami_name": "{{user `ami_name_prefix`}}-docker-ubuntu18-{{isotime | clean_ami_name}}",
13+
"ami_name": "{{user `ami_name_prefix`}}-docker-ubuntu18-{{isotime | clean_resource_name}}",
1414
"ami_description": "An example of how to build an Ubuntu 18.04 AMI that has Nomad, Consul and Docker",
1515
"instance_type": "t2.micro",
1616
"region": "{{user `aws_region`}}",
@@ -32,7 +32,7 @@
3232
},
3333
{
3434
"name": "ubuntu16-ami",
35-
"ami_name": "{{user `ami_name_prefix`}}-docker-ubuntu16-{{isotime | clean_ami_name}}",
35+
"ami_name": "{{user `ami_name_prefix`}}-docker-ubuntu16-{{isotime | clean_resource_name}}",
3636
"ami_description": "An Ubuntu 16.04 AMI that has Nomad, Consul and Docker installed.",
3737
"instance_type": "t2.micro",
3838
"region": "{{user `aws_region`}}",
@@ -53,10 +53,10 @@
5353
"ssh_username": "ubuntu"
5454
},
5555
{
56-
"ami_name": "{{user `ami_name_prefix`}}-docker-amazon-linux-2-{{isotime | clean_ami_name}}",
57-
"ami_description": "An Amazon Linux 2 AMI that has Nomad, Consul and Docker installed.",
56+
"ami_name": "{{user `ami_name_prefix`}}-docker-amazon-linux-2-amd64-{{isotime | clean_resource_name}}",
57+
"ami_description": "An Amazon Linux 2 x86_64 AMI that has Nomad, Consul and Docker installed.",
5858
"instance_type": "t2.micro",
59-
"name": "amazon-linux-2-ami",
59+
"name": "amazon-linux-2-amd64-ami",
6060
"region": "{{user `aws_region`}}",
6161
"type": "amazon-ebs",
6262
"source_ami_filter": {
@@ -73,6 +73,28 @@
7373
"most_recent": true
7474
},
7575
"ssh_username": "ec2-user"
76+
},
77+
{
78+
"ami_name": "{{user `ami_name_prefix`}}-docker-amazon-linux-2-arm64-{{isotime | clean_resource_name}}",
79+
"ami_description": "An Amazon Linux 2 ARM64 AMI that has Nomad, Consul and Docker installed.",
80+
"instance_type": "t4g.micro",
81+
"name": "amazon-linux-2-arm64-ami",
82+
"region": "{{user `aws_region`}}",
83+
"type": "amazon-ebs",
84+
"source_ami_filter": {
85+
"filters": {
86+
"virtualization-type": "hvm",
87+
"architecture": "arm64",
88+
"name": "*amzn2-ami-hvm-*",
89+
"block-device-mapping.volume-type": "gp2",
90+
"root-device-type": "ebs"
91+
},
92+
"owners": [
93+
"amazon"
94+
],
95+
"most_recent": true
96+
},
97+
"ssh_username": "ec2-user"
7698
}
7799
],
78100
"provisioners": [
@@ -92,7 +114,8 @@
92114
"type": "shell",
93115
"script": "{{template_dir}}/setup_amazon-linux-2.sh",
94116
"only": [
95-
"amazon-linux-2-ami"
117+
"amazon-linux-2-amd64-ami",
118+
"amazon-linux-2-arm64-ami"
96119
]
97120
},
98121
{

examples/nomad-consul-ami/nomad-consul.json

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"min_packer_version": "0.12.0",
33
"variables": {
44
"aws_region": "us-east-1",
5-
"nomad_version": "0.9.1",
6-
"consul_module_version": "v0.8.0",
7-
"consul_version": "1.5.1",
5+
"nomad_version": "1.1.1",
6+
"consul_module_version": "v0.10.1",
7+
"consul_version": "1.9.6",
88
"ami_name_prefix": "nomad-consul"
99
},
1010
"builders": [
@@ -53,10 +53,10 @@
5353
"ssh_username": "ubuntu"
5454
},
5555
{
56-
"ami_name": "{{user `ami_name_prefix`}}-amazon-linux-2-{{isotime | clean_resource_name}}",
57-
"ami_description": "An Amazon Linux 2 AMI that has Nomad and Consul installed.",
56+
"ami_name": "{{user `ami_name_prefix`}}-amazon-linux-2-amd64-{{isotime | clean_resource_name}}",
57+
"ami_description": "An Amazon Linux 2 x86_64 AMI that has Nomad and Consul installed.",
5858
"instance_type": "t2.micro",
59-
"name": "amazon-linux-2-ami",
59+
"name": "amazon-linux-2-amd64-ami",
6060
"region": "{{user `aws_region`}}",
6161
"type": "amazon-ebs",
6262
"source_ami_filter": {
@@ -73,6 +73,28 @@
7373
"most_recent": true
7474
},
7575
"ssh_username": "ec2-user"
76+
},
77+
{
78+
"ami_name": "{{user `ami_name_prefix`}}-amazon-linux-2-arm64-{{isotime | clean_resource_name}}",
79+
"ami_description": "An Amazon Linux 2 ARM64 AMI that has Nomad and Consul installed.",
80+
"instance_type": "t4g.micro",
81+
"name": "amazon-linux-2-arm64-ami",
82+
"region": "{{user `aws_region`}}",
83+
"type": "amazon-ebs",
84+
"source_ami_filter": {
85+
"filters": {
86+
"virtualization-type": "hvm",
87+
"architecture": "arm64",
88+
"name": "*amzn2-ami-hvm-*",
89+
"block-device-mapping.volume-type": "gp2",
90+
"root-device-type": "ebs"
91+
},
92+
"owners": [
93+
"amazon"
94+
],
95+
"most_recent": true
96+
},
97+
"ssh_username": "ec2-user"
7698
}
7799
],
78100
"provisioners": [
@@ -92,7 +114,8 @@
92114
"sudo yum install -y git"
93115
],
94116
"only": [
95-
"amazon-linux-2-ami"
117+
"amazon-linux-2-amd64-ami",
118+
"amazon-linux-2-arm64-ami"
96119
]
97120
},
98121
{

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module "servers" {
6464

6565
cluster_name = "${var.cluster_name}-server"
6666
cluster_size = var.num_servers
67-
instance_type = "t2.micro"
67+
instance_type = var.server_instance_type
6868

6969
# The EC2 Instances will use these tags to automatically discover each other and form a cluster
7070
cluster_tag_key = var.cluster_tag_key

modules/install-nomad/install-nomad

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,30 @@ function install_binaries {
127127
local readonly path="$2"
128128
local readonly username="$3"
129129

130-
local readonly url="https://releases.hashicorp.com/nomad/${version}/nomad_${version}_linux_amd64.zip"
131-
local readonly download_path="/tmp/nomad_${version}_linux_amd64.zip"
130+
local cpu_arch
131+
cpu_arch="$(uname -m)"
132+
local binary_arch=""
133+
case "$cpu_arch" in
134+
x86_64)
135+
binary_arch="amd64"
136+
;;
137+
x86)
138+
binary_arch="386"
139+
;;
140+
arm64|aarch64)
141+
binary_arch="arm64"
142+
;;
143+
arm*)
144+
binary_arch="arm"
145+
;;
146+
*)
147+
log_error "CPU architecture $cpu_arch is not a supported by Consul."
148+
exit 1
149+
;;
150+
esac
151+
152+
local readonly url="https://releases.hashicorp.com/nomad/${version}/nomad_${version}_linux_${binary_arch}.zip"
153+
local readonly download_path="/tmp/nomad_${version}_linux_${binary_arch}.zip"
132154
local readonly bin_dir="$path/bin"
133155
local readonly nomad_dest_path="$bin_dir/nomad"
134156
local readonly run_nomad_dest_path="$bin_dir/run-nomad"

test/nomad_cluster_ssh_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import "testing"
44

55
func TestNomadClusterSSHAccess(t *testing.T) {
66
t.Parallel()
7-
runNomadClusterSSHTest(t, "amazon-linux-2-ami", "ec2-user")
7+
runNomadClusterSSHTest(t, "amazon-linux-2-amd64-ami", "ec2-user")
88
}

test/nomad_consul_cluster_colocated_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func TestNomadConsulClusterColocatedWithUbuntu16Ami(t *testing.T) {
1414
runNomadClusterColocatedTest(t, "ubuntu16-ami")
1515
}
1616

17-
func TestNomadConsulClusterColocatedAmazonLinux2Ami(t *testing.T) {
17+
func TestNomadConsulClusterColocatedAmazonLinux2Amd64Ami(t *testing.T) {
1818
t.Parallel()
19-
runNomadClusterColocatedTest(t, "amazon-linux-2-ami")
19+
runNomadClusterColocatedTest(t, "amazon-linux-2-amd64-ami")
2020
}

test/nomad_consul_cluster_separate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ func TestNomadConsulClusterSeparateWithUbuntu16Ami(t *testing.T) {
1414

1515
func TestNomadConsulClusterSeparateAmazonLinux2Ami(t *testing.T) {
1616
t.Parallel()
17-
runNomadClusterSeparateTest(t, "amazon-linux-2-ami")
17+
runNomadClusterSeparateTest(t, "amazon-linux-2-amd64-ami")
1818
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ variable "cluster_name" {
3131
default = "nomad-example"
3232
}
3333

34+
variable "server_instance_type" {
35+
description = "What kind of instance type to use for the nomad servers"
36+
type = string
37+
default = "t2.micro"
38+
}
39+
3440
variable "instance_type" {
3541
description = "What kind of instance type to use for the nomad clients"
3642
type = string

0 commit comments

Comments
 (0)