From 8d434b313789235c4a9a484d1caad5d1560e7b66 Mon Sep 17 00:00:00 2001 From: ghsbhatia Date: Sat, 24 Jun 2023 15:24:47 -0600 Subject: [PATCH] fix ubuntu hostname specify token when invoking ec2 instance metadata endpoint --- modules/common/download.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/common/download.sh b/modules/common/download.sh index 75e2e05..1d551f0 100644 --- a/modules/common/download.sh +++ b/modules/common/download.sh @@ -93,7 +93,10 @@ do_download() { # TODO: Determine minimum supported version, for now just carry on assuming ignorance apt update -y apt install -y unzip less iptables resolvconf linux-headers-$(uname -r) telnet - hostnamectl set-hostname "$(curl http://169.254.169.254/latest/meta-data/hostname)" + + TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") + HOSTNAME=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/hostname) + hostnamectl set-hostname $HOSTNAME INSTALL_RKE2_METHOD='tar' INSTALL_RKE2_TYPE="${type}" ./install.sh