Skip to content

Commit

Permalink
Support arm64 installation of etcd (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiDog authored Sep 12, 2023
1 parent de1bde5 commit afdb726
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
10 changes: 7 additions & 3 deletions service/etcd/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ resource "null_resource" "etcd" {
agent = true
}

provisioner "file" {
source = "${path.module}/scripts/install.sh"
destination = "/tmp/install-etcd.sh"
}

provisioner "remote-exec" {
inline = [
templatefile("${path.module}/scripts/install.sh", {
version = var.etcd_version
})
"chmod +x /tmp/install-etcd.sh",
"/tmp/install-etcd.sh '${var.etcd_version}'"
]
}

Expand Down
24 changes: 19 additions & 5 deletions service/etcd/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
#!/bin/sh
set -e
set -eu

rm -f /opt/etcd-${version}-linux-amd64.tar.gz
[ $# = 1 ] || { >&2 echo "Usage: ${0} ETCD_VERSION"; exit 1; }

version="${1}"
if ! echo "${version}" | grep -qE '^v[0-9]'; then
>&2 printf "ERROR: Must provide valid etcd version, got \`%s\`\n" "${version}"
exit 1
fi

arch="$(arch | sed 's/x86_64/amd64/; s/aarch64/arm64/')"

rm -f "/opt/etcd-${version}-linux-${arch}.tar.gz"
rm -rf /opt/etcd && mkdir -p /opt/etcd

curl -L https://storage.googleapis.com/etcd/${version}/etcd-${version}-linux-amd64.tar.gz \
-o /opt/etcd-${version}-linux-amd64.tar.gz
tar xzvf /opt/etcd-${version}-linux-amd64.tar.gz -C /opt/etcd --strip-components=1
(
set -x
curl --fail-with-body -L "https://storage.googleapis.com/etcd/${version}/etcd-${version}-linux-${arch}.tar.gz" \
-o "/opt/etcd-${version}-linux-${arch}.tar.gz"
tar xzvf "/opt/etcd-${version}-linux-${arch}.tar.gz" -C /opt/etcd --strip-components=1
rm "/opt/etcd-${version}-linux-${arch}.tar.gz"
)

0 comments on commit afdb726

Please sign in to comment.