Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ubuntu2004 with ubuntu2404 on packer #530

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/compute/agent-node-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ export class AgentNodeConfig {
},
{
key: 'JAVA19_HOME',
value: '/usr/lib/jvm/temurin-19-jdk-amd64',
value: '/usr/lib/jvm/jdk-19',
},
{
key: 'JAVA20_HOME',
value: '/usr/lib/jvm/temurin-20-jdk-amd64',
value: '/usr/lib/jvm/jdk-20',
},
{
key: 'JAVA21_HOME',
Expand Down
97 changes: 97 additions & 0 deletions packer/jenkins-agent-ubuntu2404-x64.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"root-device-type":"ebs"
},
"owners": [
"099720109477"
"amazon"
],
"most_recent":true
},
Expand Down Expand Up @@ -76,7 +76,7 @@
{
"type":"shell",
"scripts": [
"scripts/ubuntu2004/ubuntu2004-agent-setups.sh"
"scripts/ubuntu/ubuntu2004-agent-setups.sh"
]
},
{
Expand Down
71 changes: 71 additions & 0 deletions packer/scripts/ubuntu/ubuntu2404-agent-setups.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/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 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.12 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1
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 -v 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" 1411
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/adoptopenjdk-14-amd64/bin/java" 1411
# JDK19 JDK20 as they are not available on temurin apt repository anymore
sudo apt-get install -y libc6-i386 libc6-x32
curl -SLO https://ci.opensearch.org/ci/dbc/tools/jdk/jdk-19.0.2_linux-x64_bin.deb && sudo dpkg -i jdk-19.0.2_linux-x64_bin.deb && rm -v jdk-19.0.2_linux-x64_bin.deb
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk-19/bin/javac" 1911
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-19/bin/java" 1911
curl -SLO https://ci.opensearch.org/ci/dbc/tools/jdk/jdk-20.0.2_linux-x64_bin.deb && sudo dpkg -i jdk-20.0.2_linux-x64_bin.deb && rm -v jdk-20.0.2_linux-x64_bin.deb
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk-20/bin/javac" 2011
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-20/bin/java" 2011
# 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.io openssh-server temurin-8-jdk temurin-11-jdk temurin-17-jdk temurin-21-jdk temurin-23-jdk
sudo apt-get clean -y && sudo apt-get autoremove -y
8 changes: 7 additions & 1 deletion resources/baseJenkins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,13 @@ tool:
- installSource:
installers:
- adoptOpenJdkInstaller:
id: "jdk-21.0.1+12"
id: "jdk-21.0.6+7"
- name: "openjdk-23"
properties:
- installSource:
installers:
- adoptOpenJdkInstaller:
id: "jdk-23.0.2+7"
mavenGlobalConfig:
globalSettingsProvider: "standard"
settingsProvider: "standard"
Expand Down