Skip to content

Commit

Permalink
Merge pull request #99 from rackspace-infrastructure-automation/debia…
Browse files Browse the repository at this point in the history
…n10_11

working debian 10/11
  • Loading branch information
aterhune1984 committed Sep 20, 2022
2 parents 8a11382 + 4e966c4 commit 3bea7eb
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
15 changes: 15 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ locals {
amazon = "sysstat ltrace strace iptraf tcpdump"
rhel = "sysstat ltrace strace lsof iotop iptraf-ng tcpdump"
ubuntu = "sysstat iotop iptraf-ng"
debian = "sysstat iotop iptraf-ng"
}
}

Expand All @@ -213,6 +214,8 @@ locals {
centos7 = local.defaults["diagnostic_packages"]["rhel"]
ubuntu18 = local.defaults["diagnostic_packages"]["ubuntu"]
ubuntu20 = local.defaults["diagnostic_packages"]["ubuntu"]
debian10 = local.defaults["diagnostic_packages"]["debian"]
debian11 = local.defaults["diagnostic_packages"]["debian"]
}

user_data_map = {
Expand All @@ -222,6 +225,8 @@ locals {
rhel8 = "rhel_centos_8_userdata.sh"
ubuntu18 = "ubuntu_userdata.sh"
ubuntu20 = "ubuntu_userdata.sh"
debian10 = "debian_userdata.sh"
debian11 = "debian_userdata.sh"
windows2012r2 = "windows_userdata.ps1"
windows2016 = "windows_userdata.ps1"
windows2019 = "windows_userdata.ps1"
Expand All @@ -235,6 +240,8 @@ locals {
rhel8 = "/dev/sdf"
ubuntu18 = "/dev/sdf"
ubuntu20 = "/dev/sdf"
debian10 = "/dev/sdf"
debian11 = "/dev/sdf"
windows2012r2 = "xvdf"
windows2016 = "xvdf"
windows2019 = "xvdf"
Expand Down Expand Up @@ -265,6 +272,8 @@ locals {
centos7 = "nfs-utils"
ubuntu18 = "nfs-kernel-server rpcbind nfs-common nfs4-acl-tools"
ubuntu20 = "nfs-kernel-server rpcbind nfs-common nfs4-acl-tools"
debian10 = "nfs-kernel-server rpcbind nfs-common nfs4-acl-tools"
debian11 = "nfs-kernel-server rpcbind nfs-common nfs4-acl-tools"
}

ssm_nfs_include = {
Expand Down Expand Up @@ -292,6 +301,8 @@ EOF
rhel8 = "309956199498"
ubuntu18 = "099720109477"
ubuntu20 = "099720109477"
debian10 = "136693071363"
debian11 = "136693071363"
windows2012r2 = "801119661308"
windows2016 = "801119661308"
windows2019 = "801119661308"
Expand All @@ -305,6 +316,8 @@ EOF
rhel8 = "RHEL-8.*_HVM-*x86_64*"
ubuntu18 = "ubuntu/images/hvm-ssd/*ubuntu-bionic-18.04-amd64-server*"
ubuntu20 = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"
debian10 = "debian-10-amd64-*"
debian11 = "debian-11-amd64-*"
windows2012r2 = "Windows_Server-2012-R2_RTM-English-64Bit-Base*"
windows2016 = "Windows_Server-2016-English-Full-Base*"
windows2019 = "Windows_Server-2019-English-Full-Base*"
Expand All @@ -319,6 +332,8 @@ EOF
centos7 = []
ubuntu18 = []
ubuntu20 = []
debian10 = []
debian11 = []
windows2012r2 = []
windows2016 = []
windows2019 = []
Expand Down
72 changes: 72 additions & 0 deletions text/debian_userdata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash -xe

function lock_wait {
endtime=$(( $(date +%s) + 300 ))
set +e
while [ $(date +%s) -lt $endtime ]; do
"$@" && break
sleep 15
done
set -e
}

function install_ssm_deb {
if [[ -r "/tmp/ssm_agent_install" ]]; then : ;
else
mkdir -p /tmp/ssm_agent_install
fi
curl https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb -o /tmp/ssm_agent_install/amazon-ssm-agent.deb
lock_wait dpkg -i /tmp/ssm_agent_install/amazon-ssm-agent.deb

if ps -ef | grep -q [a]mazon-ssm-agent ;then
ssm_running="yes"
else
ssm_running="no"
fi

if command -v systemctl ; then
systemctl enable amazon-ssm-agent
if [[ $ssm_running == "no" ]]; then
systemctl start amazon-ssm-agent
fi
else
if [[ $ssm_running == "no" ]]; then
start amazon-ssm-agent
fi
fi

return 0
}

function install_aws_cli_v2 {
mkdir -p /opt/aws/aws
curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o /opt/aws/awscliv2.zip && \
unzip -o /opt/aws/awscliv2.zip -d /opt/aws && \
/opt/aws/aws/install -u
}

export LC_ALL=C.UTF-8
export DEBIAN_FRONTEND=noninteractive

${initial_commands}

exec 1> >(logger -s -t $(basename $0)) 2>&1

lock_wait apt-get update
lock_wait apt-get -y install python-setuptools python3-pip unzip

# Install AWSCLIv2
install_aws_cli_v2

if ps -ef | grep -q [a]mazon-ssm-agent ;then
ssm_running="yes"
else
ssm_running="no"
fi

if [[ $ssm_running == "yes" ]]; then
echo "amazon-ssm-agent already running"
else
# use deb installer
install_ssm_deb
fi

0 comments on commit 3bea7eb

Please sign in to comment.