From 53b84a0a89f8fd9324c54508c718b0108a64e187 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Thu, 19 Oct 2023 08:31:27 -0700 Subject: [PATCH] Add install-managed-daemons.sh script to al2 and al2023 Currently this only installs the ebs-csi-driver managed daemon, but it will likely be expanded to add more in future. --- al2.pkr.hcl | 10 ++ al2023.pkr.hcl | 10 ++ scripts/install-managed-daemons.sh | 179 +++++++++++++++++++++++++++++ variables.pkr.hcl | 6 + 4 files changed, 205 insertions(+) create mode 100644 scripts/install-managed-daemons.sh diff --git a/al2.pkr.hcl b/al2.pkr.hcl index 225661d..a8438e9 100644 --- a/al2.pkr.hcl +++ b/al2.pkr.hcl @@ -137,6 +137,16 @@ build { ] } + provisioner "shell" { + script = "scripts/install-managed-daemons.sh" + environment_vars = [ + "REGION=${var.region}", + "AGENT_VERSION=${var.ecs_agent_version}", + "AIR_GAPPED=${var.air_gapped}", + "MANAGED_DAEMON_BASE_URL=${var.managed_daemon_base_url}" + ] + } + provisioner "shell" { script = "scripts/install-additional-packages.sh" } diff --git a/al2023.pkr.hcl b/al2023.pkr.hcl index 3dfb6cc..9e48262 100644 --- a/al2023.pkr.hcl +++ b/al2023.pkr.hcl @@ -105,6 +105,16 @@ build { ] } + provisioner "shell" { + script = "scripts/install-managed-daemons.sh" + environment_vars = [ + "REGION=${var.region}", + "AGENT_VERSION=${var.ecs_agent_version}", + "AIR_GAPPED=${var.air_gapped}", + "MANAGED_DAEMON_BASE_URL=${var.managed_daemon_base_url}" + ] + } + provisioner "shell" { script = "scripts/append-efs-client-info.sh" } diff --git a/scripts/install-managed-daemons.sh b/scripts/install-managed-daemons.sh new file mode 100644 index 0000000..d4f77d2 --- /dev/null +++ b/scripts/install-managed-daemons.sh @@ -0,0 +1,179 @@ +#!/usr/bin/env bash +set -ex + +if [ -n "$AIR_GAPPED" ]; then + echo "Air-gapped region, assuming ecs-init and dependencies will be in additional-packages/ directory" + exit 0 +fi + +WORK_DIR="$(mktemp -d)" +trap "rm -rf ${WORK_DIR}" EXIT + +# gpg key is taken from https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-install.html +cat >"$WORK_DIR/amazon-ecs-agent.gpg" <