Last active
April 6, 2023 19:07
-
-
Save drewyangdev/2e3fb75724d6927a1eed67968a1b4b46 to your computer and use it in GitHub Desktop.
cloud-init template and re-run script for debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo su | |
## 1. only debug runcmd | |
# edit /var/lib/cloud/instance/scripts/runcmd | |
cloud-init single --name scripts_user --frequency=always | |
## 2. re-generate runcmd from userdata | |
cloud-init single --name runcmd --frequency=always |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
# logs in /var/log/cloud-init-output.log | |
groups: | |
- ubuntu: [root,sys] | |
- docker | |
users: | |
- default | |
- name: ubuntu | |
gecos: ubuntu | |
shell: /bin/bash | |
primary_group: ubuntu | |
sudo: ALL=(ALL) NOPASSWD:ALL | |
groups: adm, sudo, ubuntu, docker | |
lock_passwd: false | |
ssh_authorized_keys: | |
- ${ssh_authorized_key} | |
## Update apt database and upgrade packages on first boot | |
package_update: true | |
package_upgrade: true | |
## Install additional packages on first boot | |
packages: | |
- git | |
- make | |
- build-essential | |
- net-tools | |
- binutils | |
- nfs-common | |
- vim | |
- nano | |
- tmux | |
write_files: | |
- path: /home/ubuntu/post-setup-README.md | |
content: | | |
# EC2 instance post setup | |
## Check installed packages | |
apt list --installed | |
## Mount GPT Partition Utils | |
cd /mnt/mount_gpt_partition | |
## Mount EFS Volume Utils | |
cd /mnt/mount_efs_volume | |
## Install Nvidia Driver | |
cd /opt/linux_nvidia_driver | |
## Install Docker | |
cd /opt/linux_install_docker | |
owner: ubuntu:ubuntu | |
permissions: "0644" | |
defer: true | |
runcmd: | |
- | | |
sudo apt-get update | |
## Get Helper Scripts | |
echo "INFO :: Get helper scripts" | |
## Mount GPT Partition script - TODO: automate device name input | |
sudo git clone https://gist.github.com/99b991c80a57931e18c85126ef186704.git /mnt/mount_gpt_partition | |
## Mount EFS Volume script | |
sudo git clone https://gist.github.com/8e75be22fa75747c80626ddbbb3699bf.git /mnt/mount_efs_volume | |
## Nvidia Driver Installation script - TODO: automate version input, maybe conda | |
sudo git clone https://gist.github.com/5e2213392b6304d18ac72f0c62675eef.git /opt/linux_nvidia_driver | |
## Docker installation - TODO: dependency of Mount GPT Partition script | |
sudo git clone https://gist.github.com/c6a2951519a190858c4c4ab993afc6a4.git /opt/linux_install_docker | |
## CloudWatch Agent setup | |
sudo git clone https://gist.github.com/694df2205b3d1f5d165564d04701b888.git /opt/cloudwatch_agent_setup | |
echo "INFO :: Setup CloudWatch Agent" | |
sudo bash /opt/cloudwatch_agent_setup/setup_cloudwatch_agent.sh datajoint datajoint | |
## Install Miniconda | |
echo "INFO :: Install Miniconda" | |
wget -P /tmp https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh | |
sudo bash /tmp/Miniconda3-latest-Linux-x86_64.sh -bfu -p /opt/miniconda3 | |
export PATH=$PATH:/opt/miniconda3/bin | |
conda --help | |
echo "export PATH=$PATH:/opt/miniconda3/bin" >> /home/ubuntu/.bashrc | |
## Install Docker | |
echo "INFO :: Install Docker" | |
sudo bash /opt/linux_install_docker/install_docker.sh | |
## Install Nvidia Driver | CUDA toolkit | Nvidia container runtime | |
echo "INFO :: Install GPU related" | |
sudo bash /opt/linux_nvidia_driver/install_nvidia_driver.sh "450.191.01" "https://developer.download.nvidia.com/compute/cuda/11.0.3/local_installers/cuda_11.0.3_450.51.06_linux.run" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment