Skip to content

Amazon Linux 2023 support #151

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

Merged
merged 18 commits into from
May 16, 2024
2 changes: 1 addition & 1 deletion fixtures/test_proxy_init/templates/install_packages.func
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ function install_packages {
rm -f ./awscliv2.zip
rm -rf ./aws
}
%{ endif ~}
%{ endif ~}
2 changes: 1 addition & 1 deletion modules/tfe_init_replicated/functions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ locals {
distribution = var.distribution
enable_monitoring = var.enable_monitoring != null ? var.enable_monitoring : false
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ function get_base64_secrets {

%{ if cloud == "aws" ~}
function get_base64_secrets {
# Description: Pull the Base 64 encoded secrets from AWS Secrets Manager
local secret_id=$1
# OS: Agnostic
# Description: Pull the Base 64 encoded secrets from AWS Secrets Manager

/usr/local/bin/aws secretsmanager get-secret-value --secret-id $secret_id | jq --raw-output '.SecretBinary,.SecretString | select(. != null)'
}
%{ endif ~}
Expand All @@ -27,4 +26,4 @@ get_base64_secrets () {

http_proxy="" https_proxy="" gcloud secrets versions access latest --secret="$secret_id"
}
%{ endif ~}
%{ endif ~}
41 changes: 27 additions & 14 deletions modules/tfe_init_replicated/templates/install_packages.func
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,33 @@ function install_packages {
# OS: Agnostic
# Description: Install AWS packages

%{ if distribution == "rhel" ~}
echo "[$(date +"%FT%T")] [Terraform Enterprise] Install unzip and SSMAgent with yum" | tee -a $log_pathname
yum install -y \
firewalld \
unzip \
https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
systemctl enable amazon-ssm-agent
systemctl start amazon-ssm-agent
systemctl enable firewalld
systemctl start firewalld
%{ if distribution == "rhel" || distribution == "amazon-linux-2023" ~}
echo "[$(date +"%FT%T")] [Terraform Enterprise] Install unzip and firewalld with yum" | tee -a $log_pathname
yum install -y firewalld unzip

%{ if distribution == "rhel" ~}
# Amazon Linux 2023 already has amazon-ssm-agent so install on rhel only
echo "[$(date +"%FT%T")] [Terraform Enterprise] Install ssm-agent with yum" | tee -a $log_pathname
yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
%{ endif ~}

%{ if distribution == "amazon-linux-2023" ~}
echo "[$(date +"%FT%T")] [Terraform Enterprise] Remove existing docker and install v24 with yum" | tee -a $log_pathname
yum remove docker -y
yum install docker-24.0.5-1.amzn2023.0.3 -y

systemctl start docker
systemctl enable docker
%{ endif ~}

systemctl enable amazon-ssm-agent
systemctl start amazon-ssm-agent
systemctl enable firewalld
systemctl start firewalld
%{ else ~}
echo "[$(date +"%FT%T")] [Terraform Enterprise] Install unzip with apt-get" | tee -a $log_pathname
apt-get update -y
apt-get install -y unzip
echo "[$(date +"%FT%T")] [Terraform Enterprise] Install unzip with apt-get" | tee -a $log_pathname
apt-get update -y
apt-get install -y unzip
%{ endif ~}

echo "[$(date +"%FT%T")] [Terraform Enterprise] Install AWS CLI" | tee -a $log_pathname
Expand All @@ -39,4 +52,4 @@ function install_packages {
install_packages () {
:
}
%{ endif ~}
%{ endif ~}
7 changes: 5 additions & 2 deletions modules/tfe_init_replicated/templates/tfe_replicated.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ echo "[$(date +"%FT%T")] [Terraform Enterprise] Skipping TlsBootstrapKey configu
#------------------------------------------------------------------------------
ca_certificate_directory="/dev/null"

%{ if distribution == "rhel" ~}
%{ if distribution == "rhel" || distribution == "amazon-linux-2023" ~}
ca_certificate_directory=/usr/share/pki/ca-trust-source/anchors
%{ else ~}
ca_certificate_directory=/usr/local/share/ca-certificates/extra
Expand All @@ -123,7 +123,7 @@ echo "[$(date +"%FT%T")] [Terraform Enterprise] Skipping CA certificate configur

if [ -f "$ca_cert_filepath" ]
then
%{ if distribution == "rhel" ~}
%{ if distribution == "rhel" || distribution == "amazon-linux-2023" ~}
update-ca-trust

%{ else ~}
Expand Down Expand Up @@ -279,6 +279,9 @@ $install_pathname \
%{ if airgap_pathname != null ~}
airgap \
%{ endif ~}
%{ if distribution == "amazon-linux-2023" ~}
no-docker \
%{ endif ~}
| tee -a $log_pathname

# -----------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions modules/tfe_init_replicated/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ variable "distribution" {
type = string
description = "(Required) What is the OS distribution of the instance on which Terraoform Enterprise will be deployed?"
validation {
condition = contains(["rhel", "ubuntu"], var.distribution)
error_message = "Supported values for distribution are 'rhel', or 'ubuntu'."
condition = contains(["rhel", "ubuntu", "amazon-linux-2023"], var.distribution)
error_message = "Supported values for distribution are 'rhel', 'ubuntu' or amazon-linux-2023."
}
}

Expand Down Expand Up @@ -95,4 +95,4 @@ variable "disk_path" {
variable "replicated_configuration" {
default = null
description = "The settings that will be used to configure Replicated."
}
}