diff --git a/packer/jenkins-agent-ubuntu2404-x64.json b/packer/jenkins-agent-ubuntu2404-x64.json new file mode 100644 index 00000000..1e6e1cca --- /dev/null +++ b/packer/jenkins-agent-ubuntu2404-x64.json @@ -0,0 +1,97 @@ +{ + "variables": { + "name-base":"Jenkins-Agent-Ubuntu2404-X64", + "os-version": "Ubuntu2404", + "build-region":"us-east-1", + "build-vpc":"vpc-<>", + "build-subnet":"subnet-<>", + "build-secgrp":"sg-<>", + "build-time":"{{isotime \"2006-01-02T03-04-05Z\"}}", + "aws_ami_region":"us-east-1" + }, + "builders": [ + { + "name":"{{user `name-base`}}-{{user `build-time`}}" , + "ami_description":"{{user `name-base`}}", + "type":"amazon-ebs", + "encrypt_boot":"false", + "region":"{{user `build-region`}}", + "ami_regions":"{{user `aws_ami_region`}}", + "instance_type":"c5.4xlarge", + "ami_name":"{{user `name-base`}}-{{user `build-time`}}", + "vpc_id":"{{user `build-vpc`}}", + "subnet_id":"{{user `build-subnet`}}", + "security_group_ids":"{{user `build-secgrp`}}", + "source_ami_filter": { + "filters": { + "virtualization-type":"hvm", + "architecture":"x86_64", + "name": "ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-20*", + "block-device-mapping.volume-type":"gp3", + "root-device-type":"ebs" + }, + "owners": [ + "amazon" + ], + "most_recent":true + }, + "associate_public_ip_address":false, + "metadata_options": { + "http_endpoint": "enabled", + "http_tokens": "required", + "http_put_response_hop_limit": 1 + }, + "ssh_username": "ubuntu", + "ssh_timeout": "3h", + "tags": { + "Name": "{{user `name-base`}}-{{user `build-time`}}", + "OS_Version":"{{user `os-version`}}", + "User":"Packer", + "Encrypted_AMI":"False", + "Created":"{{user `build-time`}}" + }, + "launch_block_device_mappings": [ + { + "device_name":"/dev/sda1", + "volume_size":100, + "delete_on_termination":true, + "volume_type":"gp3" + } + ] + } + ], + "provisioners": [ + { + "type": "file", + "source": "files/common/vm-max-map.sh", + "destination": + "/tmp/vm_max_map.sh" + }, + { + "type": "file", + "source": "files/common/docker-daemon.json", + "destination": + "/tmp/daemon.json" + }, + { + "type":"shell", + "scripts": [ + "scripts/ubuntu/ubuntu2404-agent-setups.sh" + ] + }, + { + "type": "shell", + "inline": [ + "sudo mv -v /tmp/vm_max_map.sh /etc/profile.d/vm_max_map.sh", + "sudo mv -v /tmp/daemon.json /etc/docker/daemon.json" + ] + }, + { + "type": "shell", + "inline": [ + "sudo reboot" + ], + "expect_disconnect": true + } + ] +} diff --git a/packer/jenkins-agent-ubuntu2004-x64.json b/packer/legacy/jenkins-agent-ubuntu2004-x64.json similarity index 96% rename from packer/jenkins-agent-ubuntu2004-x64.json rename to packer/legacy/jenkins-agent-ubuntu2004-x64.json index 65fa5873..3d5862ce 100644 --- a/packer/jenkins-agent-ubuntu2004-x64.json +++ b/packer/legacy/jenkins-agent-ubuntu2004-x64.json @@ -31,7 +31,7 @@ "root-device-type":"ebs" }, "owners": [ - "099720109477" + "amazon" ], "most_recent":true }, @@ -76,7 +76,7 @@ { "type":"shell", "scripts": [ - "scripts/ubuntu2004/ubuntu2004-agent-setups.sh" + "scripts/ubuntu/ubuntu2004-agent-setups.sh" ] }, { diff --git a/packer/scripts/ubuntu2004/ubuntu2004-agent-setups.sh b/packer/scripts/ubuntu/ubuntu2004-agent-setups.sh similarity index 100% rename from packer/scripts/ubuntu2004/ubuntu2004-agent-setups.sh rename to packer/scripts/ubuntu/ubuntu2004-agent-setups.sh diff --git a/packer/scripts/ubuntu/ubuntu2404-agent-setups.sh b/packer/scripts/ubuntu/ubuntu2404-agent-setups.sh new file mode 100755 index 00000000..9fe8e3d9 --- /dev/null +++ b/packer/scripts/ubuntu/ubuntu2404-agent-setups.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +set -ex + +whoami +export DEBIAN_FRONTEND=noninteractive + +sudo apt-get update -y && (sudo killall -9 apt-get apt 2>&1 || echo) +sudo apt-get upgrade -y && sudo apt-get install -y software-properties-common && sudo add-apt-repository ppa:deadsnakes/ppa -y +sudo apt-get update -y && sudo apt-get install -y binfmt-support qemu-system qemu-system-common qemu-user qemu-user-static +sudo apt-get install -y docker.io=24.0.7* docker-compose ntp curl git gnupg2 tar zip unzip jq pigz +sudo apt-get install -y build-essential + +sudo systemctl restart ntp && sudo systemctl enable ntp && sudo systemctl status ntp +sudo systemctl restart docker && sudo systemctl enable docker && sudo systemctl status docker +sudo usermod -a -G docker `whoami` + +sudo apt-get install -y python3.9-full +sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 100 +sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 100 +sudo update-alternatives --set python3 /usr/bin/python3.9 +sudo update-alternatives --set python /usr/bin/python3.9 +curl -SL https://bootstrap.pypa.io/get-pip.py | sudo python3 - +sudo pip3 install awscliv2==2.3.1 + +curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ +&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ +&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ +&& sudo apt-get update \ +&& sudo apt-get install gh -y + +sudo mkdir -p /var/jenkins && sudo chown -R ubuntu:ubuntu /var/jenkins + +# Pre-install multi-jdk +sudo apt-get install -y apt-transport-https gnupg curl +sudo mkdir -p /etc/apt/keyrings +curl -o- https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /etc/apt/keyrings/adoptium.asc +echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list + +sudo apt-get update -y +sudo apt-get install -y temurin-8-jdk temurin-11-jdk temurin-17-jdk temurin-21-jdk temurin-23-jdk +# JDK14 required for gradle check to do bwc tests +curl -SL "https://ci.opensearch.org/ci/dbc/tools/jdk/OpenJDK14U-jdk_x64_linux_hotspot_14.0.2_12.tar.gz" -o jdk14.tar.gz +tar -xzf jdk14.tar.gz && rm jdk14.tar.gz +mv "jdk-14.0.2+12" "adoptopenjdk-14-amd64" +sudo chown root:root -R adoptopenjdk-14-amd64 +sudo mv adoptopenjdk-14-amd64 /usr/lib/jvm/ +sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/adoptopenjdk-14-amd64/bin/javac" 1111 +sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/adoptopenjdk-14-amd64/bin/java" 1111 +# JDK19 JDK20 as they are not available on temurin apt repository anymore +curl -SL https://ci.opensearch.org/ci/dbc/tools/jdk/jdk-19.0.2_linux-x64_bin.deb && dpkg -i jdk-19.0.2_linux-x64_bin.deb && rm -v jdk-19.0.2_linux-x64_bin.deb +curl -SL https://ci.opensearch.org/ci/dbc/tools/jdk/jdk-20.0.2_linux-x64_bin.deb && dpkg -i jdk-20.0.2_linux-x64_bin.deb && rm -v jdk-20.0.2_linux-x64_bin.deb +# Reset to JDK21 so Jenkins can bootstrap it +sudo update-alternatives --set "java" "/usr/lib/jvm/temurin-21-jdk-amd64/bin/java" +sudo update-alternatives --set "javac" "/usr/lib/jvm/temurin-21-jdk-amd64/bin/javac" +java -version + +sudo apt-mark hold docker docker.io openssh-server temurin-8-jdk temurin-11-jdk temurin-17-jdk temurin-21-jdk temurin-23-jdk +sudo apt-get clean -y