Setting Up a New (Ubuntu) Server
What could you possibly do with a new Ubuntu 22 Server?
Get Docker
Here is an easy way to get docker up and running. You can even put this in a script.
#!/bin/bash
# https://docs.docker.com/engine/install/ubuntu/#install-using-the-convenience-script
ROOTLESS_USER=$USER
if [ $# != 0 ]
then
ROOTLESS_USER=$1
fi
echo "Running with $ROOTLESS_USER as user"
echo '---Creating ~/docker and /docker---'
mkdir /home/$ROOTLESS_USER/docker
sudo ln -s /home/$ROOTLESS_USER/docker /docker
echo '---Removing old docker---'
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
echo '---Installing docker---'
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
rm get-docker.sh
echo '---Setting up non-root user for docker---'
sudo groupadd docker;
sudo usermod -aG docker $ROOTLESS_USER;
newgrp docker;
To Run It
chmod +x ./docker-install
./docker-install
These steps are pretty much the same as following docker's official guide which can be found here. Get Docker
Run Ansible Playbook
playbook.yaml
---
- hosts: new
become: yes
tasks:
- import_tasks: ../tasks/mount_nfs.yml
- import_tasks: ../tasks/setup_ssh.yml
- import_tasks: ../tasks/essential.yml
- import_tasks: ../tasks/set_dns.yml
tasks/essential.yaml
---
- name: Set Timezone to America/Chicago
timezone:
name: America/Chicago
- name: Update Packages
apt:
update_cache: yes
upgrade: yes
- name: Install Essential Packages
package:
name: "{{ packages }}"
state: latest
- name: Configure ZSH
include_role:
name: gantsign.oh-my-zsh
vars:
users:
- username: '{{username}}'
oh_my_zsh:
theme: strug
plugins:
- git
- sudo
- zsh-autosuggestions
- dirhistory
- docker
- docker-compose
- name: Install zsh-autosuggestions
command:
cmd: git clone https://github.com/zsh-users/zsh-autosuggestions /home/{{username}}/.oh-my-zsh/custom/plugins/zsh-autosuggestions
creates: /home/{{username}}/.oh-my-zsh/custom/plugins/zsh-autosuggestions
- name: Find All Custom Local Bin Scripts
find:
paths: /mnt/tkNAS/sean/localbin
register: find
- name: Create Symlinks to /usr/local/bin
become: True
file:
src: "{{ item.path }}"
path: "/usr/local/bin/{{ item.path | basename }}"
state: link
with_items: "{{ find.files }}"