docker-base

by devokot
62 deployments · 21 still active · last rev. 4 months ago

Base configuration for docker hosts

Compatible with: Ubuntu 16.04 LTS
Includes: lib-16
						#! /bin/bash
#
# Base server that sets a root SSH key and disables password auth. Used by me for Ansible-based deploys.
# <UDF name="HOSTNAME"          Label="Hostname" />
# <UDF name="USERNAME"          Label="Username" />
# <UDF name="PASSWORD"          Label="Password" />
# <UDF name="SSH_KEY"           Label="SSH Key" />
# <UDF name="FQDN"              Label="Domain Name">

source <ssinclude StackScriptID=46109>

IPADDR=$(/sbin/ifconfig eth0 | awk '/inet / { print $2 }' | sed 's/addr://')

apt-get update -o Acquire::ForceIPv4=true

goodstuff

# Basic Stuff

ssh_disable_root

ssh_disable_password

user_add_sudo "$USERNAME" "$PASSWORD"

user_add_pubkey "$USERNAME" "$SSH_KEY"

system_set_hostname "$HOSTNAME"

system_add_host_entry "$IPADDR" "$HOSTNAME"

system_add_host_entry "$IPADDR" "$FQDN"

service sshd restart

# Kernel Stuff

## Prevents debconf prompt
export DEBIAN_FRONTEND=noninteractive

apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" linux-image-virtual grub2 -y

update-grub

echo 'admin ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

groupadd docker

usermod -aG docker $USERNAME