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

Update deployment to use the latest Ubuntu LTS Image #23

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion aws/image.pkr.hcl
@@ -1,3 +1,13 @@
packer {
required_plugins {
amazon = {
source = "github.com/hashicorp/amazon"
version = "~> 1"
}
}
}


locals {
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
}
Expand All @@ -10,7 +20,7 @@ data "amazon-ami" "hashistack" {
filters = {
architecture = "x86_64"
"block-device-mapping.volume-type" = "gp2"
name = "ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"
name = "ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
Expand Down
17 changes: 13 additions & 4 deletions azure/image.pkr.hcl
@@ -1,3 +1,12 @@
packer {
required_plugins {
azure = {
source = "github.com/hashicorp/azure"
version = "~> 2"
}
}
}

locals {
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
}
Expand Down Expand Up @@ -39,15 +48,15 @@ source "azure-arm" "hashistack" {
tenant_id = var.tenant_id
os_type = "Linux"
image_publisher = "Canonical"
image_offer = "UbuntuServer"
image_sku = "16.04-LTS"
image_offer = "0001-com-ubuntu-server-jammy"
image_sku = "22_04-lts-gen2"

azure_tags = {
dept = "education"
}

location = var.location
vm_size = "Standard_A2"
vm_size = "Standard_B2s"
}

build {
Expand All @@ -66,4 +75,4 @@ build {
environment_vars = ["INSTALL_NVIDIA_DOCKER=false", "CLOUD_ENV=aws"]
script = "../shared/scripts/setup.sh"
}
}
}
13 changes: 11 additions & 2 deletions gcp/image.pkr.hcl
@@ -1,3 +1,12 @@
packer {
required_plugins {
googlecompute = {
version = ">= 1.1.4"
source = "github.com/hashicorp/googlecompute"
}
}
}

locals {
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
}
Expand All @@ -13,7 +22,7 @@ variable "zone" {
source "googlecompute" "hashistack" {
image_name = "hashistack-${local.timestamp}"
project_id = var.project
source_image = "ubuntu-minimal-1804-bionic-v20221026"
source_image = "ubuntu-minimal-2204-jammy-v20231213b"
ssh_username = "packer"
zone = var.zone
}
Expand All @@ -34,4 +43,4 @@ build {
environment_vars = ["INSTALL_NVIDIA_DOCKER=false", "CLOUD_ENV=gce"]
script = "../shared/scripts/setup.sh"
}
}
}
5 changes: 5 additions & 0 deletions shared/config/consul-systemd-resolved.conf
@@ -0,0 +1,5 @@
[Resolve]
DNS=127.0.0.1:8600
DNSSEC=false
Domains=~consul
DNSStubListenerExtra=DOCKER_BRIDGE_IP_ADDRESS
2 changes: 1 addition & 1 deletion shared/config/consul_aws.service
Expand Up @@ -6,7 +6,7 @@ After=network-online.target
[Service]
Restart=on-failure
Environment=CONSUL_ALLOW_PRIVILEGED_PORTS=true
ExecStart=/usr/local/bin/consul agent -config-dir="/etc/consul.d" -dns-port="53" -recursor="172.31.0.2"
ExecStart=/usr/local/bin/consul agent -config-dir="/etc/consul.d" -recursor="172.31.0.2"
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGTERM
User=root
Expand Down
2 changes: 1 addition & 1 deletion shared/config/consul_azure.service
Expand Up @@ -6,7 +6,7 @@ After=network-online.target
[Service]
Restart=on-failure
Environment=CONSUL_ALLOW_PRIVILEGED_PORTS=true
ExecStart=/usr/local/bin/consul agent -config-dir="/etc/consul.d" -dns-port="53" -recursor="172.31.0.2"
ExecStart=/usr/local/bin/consul agent -config-dir="/etc/consul.d" -recursor="172.31.0.2"
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGTERM
User=root
Expand Down
2 changes: 1 addition & 1 deletion shared/config/consul_gce.service
Expand Up @@ -6,7 +6,7 @@ After=network-online.target
[Service]
Restart=on-failure
Environment=CONSUL_ALLOW_PRIVILEGED_PORTS=true
ExecStart=/usr/local/bin/consul agent -config-dir="/etc/consul.d" -dns-port="8600" -recursor="172.31.0.2"
ExecStart=/usr/local/bin/consul agent -config-dir="/etc/consul.d" -recursor="172.31.0.2"
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGTERM
User=root
Expand Down
12 changes: 7 additions & 5 deletions shared/scripts/client.sh
Expand Up @@ -12,7 +12,7 @@ HOME_DIR=ubuntu
# Wait for network
sleep 15

DOCKER_BRIDGE_IP_ADDRESS=(`ifconfig docker0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'`)
DOCKER_BRIDGE_IP_ADDRESS=(`ip -brief addr show docker0 | awk '{print $3}' | awk -F/ '{print $1}'`)
CLOUD=$1
RETRY_JOIN=$2
NOMAD_BINARY=$3
Expand Down Expand Up @@ -72,10 +72,12 @@ sudo cp $CONFIGDIR/consul-template.service /etc/systemd/system/consul-template.s
# Add hostname to /etc/hosts
echo "127.0.0.1 $(hostname)" | sudo tee --append /etc/hosts

# Add Docker bridge network IP to /etc/resolv.conf (at the top)
echo "nameserver $DOCKER_BRIDGE_IP_ADDRESS" | sudo tee /etc/resolv.conf.new
cat /etc/resolv.conf | sudo tee --append /etc/resolv.conf.new
sudo mv /etc/resolv.conf.new /etc/resolv.conf
# Add systemd-resolved configuration for Consul DNS
# ref: https://developer.hashicorp.com/consul/tutorials/networking/dns-forwarding#systemd-resolved-setup
sed -i "s/DOCKER_BRIDGE_IP_ADDRESS/$DOCKER_BRIDGE_IP_ADDRESS/g" $CONFIGDIR/consul-systemd-resolved.conf
sudo mkdir -p /etc/systemd/resolved.conf.d/
sudo cp $CONFIGDIR/consul-systemd-resolved.conf /etc/systemd/resolved.conf.d/consul.conf
sudo systemctl restart systemd-resolved

# Set env vars for tool CLIs
echo "export VAULT_ADDR=http://$IP_ADDRESS:8200" | sudo tee --append /home/$HOME_DIR/.bashrc
Expand Down
14 changes: 8 additions & 6 deletions shared/scripts/server.sh
Expand Up @@ -13,7 +13,7 @@ HOME_DIR=ubuntu
# Wait for network
sleep 15

DOCKER_BRIDGE_IP_ADDRESS=(`ifconfig docker0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'`)
DOCKER_BRIDGE_IP_ADDRESS=(`ip -brief addr show docker0 | awk '{print $3}' | awk -F/ '{print $1}'`)
CLOUD=$1
SERVER_COUNT=$2
RETRY_JOIN=$3
Expand Down Expand Up @@ -86,15 +86,17 @@ sudo cp $CONFIGDIR/consul-template.service /etc/systemd/system/consul-template.s

echo "127.0.0.1 $(hostname)" | sudo tee --append /etc/hosts

# Add Docker bridge network IP to /etc/resolv.conf (at the top)

echo "nameserver $DOCKER_BRIDGE_IP_ADDRESS" | sudo tee /etc/resolv.conf.new
cat /etc/resolv.conf | sudo tee --append /etc/resolv.conf.new
sudo mv /etc/resolv.conf.new /etc/resolv.conf
# Add systemd-resolved configuration for Consul DNS
# ref: https://developer.hashicorp.com/consul/tutorials/networking/dns-forwarding#systemd-resolved-setup
sed -i "s/DOCKER_BRIDGE_IP_ADDRESS/$DOCKER_BRIDGE_IP_ADDRESS/g" $CONFIGDIR/consul-systemd-resolved.conf
sudo mkdir -p /etc/systemd/resolved.conf.d/
sudo cp $CONFIGDIR/consul-systemd-resolved.conf /etc/systemd/resolved.conf.d/consul.conf
sudo systemctl restart systemd-resolved

# Set env vars for tool CLIs
echo "export CONSUL_RPC_ADDR=$IP_ADDRESS:8400" | sudo tee --append /home/$HOME_DIR/.bashrc
echo "export CONSUL_HTTP_ADDR=$IP_ADDRESS:8500" | sudo tee --append /home/$HOME_DIR/.bashrc
echo "export VAULT_ADDR=http://$IP_ADDRESS:8200" | sudo tee --append /home/$HOME_DIR/.bashrc
echo "export NOMAD_ADDR=http://$IP_ADDRESS:4646" | sudo tee --append /home/$HOME_DIR/.bashrc
echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre" | sudo tee --append /home/$HOME_DIR/.bashrc
echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre" | sudo tee --append /home/$HOME_DIR/.bashrc
4 changes: 2 additions & 2 deletions shared/scripts/setup.sh
Expand Up @@ -36,7 +36,7 @@ case $CLOUD_ENV in
;;

gce)
sudo apt-get update && sudo apt-get install -y software-properties-common
sudo apt-get clean && sudo apt-get update && sudo apt-get install -y software-properties-common
;;

azure)
Expand All @@ -48,7 +48,7 @@ case $CLOUD_ENV in
;;
esac

sudo apt-get update
sudo add-apt-repository universe && sudo apt-get update
sudo apt-get install -y unzip tree redis-tools jq curl tmux
sudo apt-get clean

Expand Down