From 36b5f2ca4930fd08b980f44db245d593f26f32b6 Mon Sep 17 00:00:00 2001 From: Jean Schmidt <4520845+jeanschmidt@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:55:48 +0200 Subject: [PATCH] fix user_data.sh for linux instances - retry command not found (#5373) --- .../runners-instances/templates/user-data.sh | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/terraform-aws-github-runner/modules/runners-instances/templates/user-data.sh b/terraform-aws-github-runner/modules/runners-instances/templates/user-data.sh index 5fe998612a..dfe700ba29 100644 --- a/terraform-aws-github-runner/modules/runners-instances/templates/user-data.sh +++ b/terraform-aws-github-runner/modules/runners-instances/templates/user-data.sh @@ -20,36 +20,38 @@ fi sudo sh -c "curl https://raw.githubusercontent.com/kadwanev/retry/master/retry -o /usr/local/bin/retry && chmod +x /usr/local/bin/retry" -sudo retry "$PKG_MANAGER update -y" +sleep 3 + +sudo /usr/local/bin/retry "$PKG_MANAGER update -y" if ! command -v jq 2>/dev/null; then echo "Installing jq" - sudo retry "$PKG_MANAGER install -y jq" + sudo /usr/local/bin/retry "$PKG_MANAGER install -y jq" fi if ! command -v git 2>/dev/null; then echo "Installing git" - sudo retry "$PKG_MANAGER install -y git" + sudo /usr/local/bin/retry "$PKG_MANAGER install -y git" fi if ! command -v pip3 2>/dev/null; then echo "Installing git" - sudo retry "$PKG_MANAGER install -y pip" + sudo /usr/local/bin/retry "$PKG_MANAGER install -y pip" fi %{ if enable_cloudwatch_agent ~} -sudo retry "$PKG_MANAGER install amazon-cloudwatch-agent -y" +sudo /usr/local/bin/retry "$PKG_MANAGER install amazon-cloudwatch-agent -y" amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c ssm:${ssm_key_cloudwatch_agent_config} %{ endif ~} # Install docker if [ "$(uname -m)" == "aarch64" ]; then - sudo retry "$PKG_MANAGER install -y docker" + sudo /usr/local/bin/retry "$PKG_MANAGER install -y docker" else if command -v amazon-linux-extras 2>/dev/null; then echo "Installing docker using amazon-linux-extras" - sudo retry "amazon-linux-extras install docker" + sudo /usr/local/bin/retry "amazon-linux-extras install docker" else echo "Installing docker using dnf" - sudo retry "dnf install docker -y" + sudo /usr/local/bin/retry "dnf install docker -y" fi fi @@ -59,8 +61,8 @@ usermod -a -G docker ec2-user USER_NAME=ec2-user ${install_config_runner} -sudo retry "$PKG_MANAGER groupinstall -y 'Development Tools'" -sudo retry "$PKG_MANAGER install -y 'kernel-devel-uname-r == $(uname -r)'" +sudo /usr/local/bin/retry "$PKG_MANAGER groupinstall -y 'Development Tools'" +sudo /usr/local/bin/retry "$PKG_MANAGER install -y 'kernel-devel-uname-r == $(uname -r)'" echo Checking if nvidia install required ${nvidia_driver_install} %{ if nvidia_driver_install ~} @@ -68,24 +70,24 @@ echo "NVIDIA driver install required" if [[ "$OS_ID" =~ ^amzn.* ]]; then if [[ "$OS_ID" =~ "amzn2023" ]] ; then echo "On Amazon Linux 2023, installing kernel-modules-extra" - sudo retry "dnf install kernel-modules-extra -y" + sudo /usr/local/bin/retry "dnf install kernel-modules-extra -y" fi echo Installing Development Tools sudo modprobe backlight fi -sudo retry "curl -fsL -o /tmp/nvidia_driver 'https://s3.amazonaws.com/ossci-linux/nvidia_driver/NVIDIA-Linux-x86_64-550.54.15.run'" -sudo retry "/bin/bash /tmp/nvidia_driver -s --no-drm" +sudo /usr/local/bin/retry "curl -fsL -o /tmp/nvidia_driver 'https://s3.amazonaws.com/ossci-linux/nvidia_driver/NVIDIA-Linux-x86_64-550.54.15.run'" +sudo /usr/local/bin/retry "/bin/bash /tmp/nvidia_driver -s --no-drm" sudo rm -fv /tmp/nvidia_driver if [[ "$OS_ID" =~ ^amzn.* ]]; then if [[ "$OS_ID" == ^amzn2023* ]]; then - sudo retry "dnf install -y dnf-plugins-core" - sudo retry "dnf config-manager --add-repo 'https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo'" + sudo /usr/local/bin/retry "dnf install -y dnf-plugins-core" + sudo /usr/local/bin/retry "dnf config-manager --add-repo 'https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo'" else - sudo retry "yum install -y yum-utils" - sudo retry "yum-config-manager --add-repo 'https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo'" + sudo /usr/local/bin/retry "yum install -y yum-utils" + sudo /usr/local/bin/retry "yum-config-manager --add-repo 'https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo'" fi echo Installing nvidia-docker tools - sudo retry "$PKG_MANAGER install -y nvidia-docker2" + sudo /usr/local/bin/retry "$PKG_MANAGER install -y nvidia-docker2" sudo systemctl restart docker fi %{ endif ~}