Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Userdata for octohost on Digital Ocean with ZFS - be careful - it might eat your data.
export PUBLIC_IPV4=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)
export CONSUL_KEY=$(consul keygen)
service consul stop
rm -rf /var/cache/octohost/*
sudo cat > /etc/consul.d/default.json << EOL
{
"data_dir": "/var/cache/octohost",
"server": true,
"bootstrap": true,
"client_addr": "0.0.0.0",
"advertise_addr": "$PUBLIC_IPV4",
"datacenter": "dc1",
"node_name": "octohost",
"enable_syslog": true,
"encrypt": "$CONSUL_KEY"
}
EOL
service consul start
service docker stop
mkdir -p /var/zfs/
truncate -s 20GB /var/zfs/docker.img # Use whatever size you'd like.
zpool create -f zroot /var/zfs/docker.img
zfs create -o mountpoint=/var/lib/docker-zfs zroot/docker
sudo cat > /etc/default/docker << EOL
# Docker Upstart and SysVinit configuration file
# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"
# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock --dns 8.8.8.8 --dns 8.8.4.4 --graph=/var/lib/docker-zfs --storage-driver=zfs"
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"
# This is also a handy place to tweak where Docker's temporary files go.
#export TMPDIR="/mnt/bigdrive/docker-tmp"
EOL
service docker start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment