Skip to content

Commit

Permalink
Add ec2-user to docker group, package fixups (aws#10)
Browse files Browse the repository at this point in the history
ec2-user needs to be added to the docker group to ensure that the
'docker' binary can be run without 'sudo'.

packages were fixed up to be consistent with current AMIs.
  • Loading branch information
sparrc authored Nov 9, 2021
1 parent d6a209e commit 7c2c018
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
9 changes: 8 additions & 1 deletion al1.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ build {
provisioner "shell" {
inline_shebang = "/bin/sh -ex"
inline = [
"sudo yum install -y docker-${var.docker_version_al1} ecs-init-${var.ecs_version_al1} ${local.packages} docker-storage-setup"
"sudo yum install -y docker-${var.docker_version_al1} ecs-init-${var.ecs_version_al1} ${local.packages_al1}"
]
}

Expand Down Expand Up @@ -116,6 +116,13 @@ build {
script = "scripts/append-efs-client-info.sh"
}

provisioner "shell" {
inline_shebang = "/bin/sh -ex"
inline = [
"sudo usermod -a -G docker ec2-user"
]
}

provisioner "shell" {
script = "scripts/cleanup.sh"
}
Expand Down
10 changes: 9 additions & 1 deletion al2.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ build {
provisioner "shell" {
inline_shebang = "/bin/sh -ex"
inline = [
"sudo mv /tmp/90_ecs.cfg /etc/cloud/cloud.cfg.d/90_ecs.cfg"
"sudo mv /tmp/90_ecs.cfg /etc/cloud/cloud.cfg.d/90_ecs.cfg",
"sudo chown root:root /etc/cloud/cloud.cfg.d/90_ecs.cfg"
]
}

Expand Down Expand Up @@ -159,6 +160,13 @@ build {
script = "scripts/enable-ecs-agent-gpu-support.sh"
}

provisioner "shell" {
inline_shebang = "/bin/sh -ex"
inline = [
"sudo usermod -a -G docker ec2-user"
]
}

provisioner "shell" {
script = "scripts/enable-services.sh"
}
Expand Down
1 change: 1 addition & 0 deletions files/90_ecs.cfg.amzn2
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
system_info:
default_user:
groups: [ "wheel", "docker" ]

2 changes: 1 addition & 1 deletion release.auto.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ami_version = "20211106"
ami_version = "20210101"
source_ami_al2 = "amzn2-ami-minimal-hvm-2.0.20211005.0-x86_64-ebs"
source_ami_al2arm = "amzn2-ami-minimal-hvm-2.0.20211005.0-arm64-ebs"
ecs_agent_version = "1.57.0"
Expand Down
3 changes: 2 additions & 1 deletion variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ packer {
}

locals {
packages = "amazon-efs-utils ec2-net-utils acpid amazon-ssm-agent"
packages_al1 = "amazon-efs-utils ec2-net-utils acpid irqbalance numactl rng-tools docker-storage-setup"
packages = "amazon-efs-utils ec2-net-utils acpid amazon-ssm-agent yum-plugin-upgrade-helper"
}

variable "ami_name_prefix_al2" {
Expand Down

0 comments on commit 7c2c018

Please sign in to comment.