Skip to content

Instantly share code, notes, and snippets.

@etoews etoews/
Last active Aug 14, 2016

What would you like to do?
export DEBIAN_FRONTEND=noninteractive
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config
service ssh restart
apt-get -y update
apt-get -y install fail2ban
apt-get -y install apt-transport-https ca-certificates
apt-key adv --keyserver hkp:// --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb ubuntu-xenial experimental" > /etc/apt/sources.list.d/docker.list
apt-get -y update
apt-get -y install linux-image-extra-$(uname -r)
apt-get -y install docker-engine=1.12.0~rc4-0~xenial
service docker start
set -euo pipefail
# Usage:
# create
# version
# join {swarm-secret} {swarm-manager-ip}
# info
# delete
# Requirements:
# Environment Variables:
# export RS_USERNAME={my-rackspace-username}
# export RS_API_KEY={my-rackspace-api-key}
# rack: The Rackspace command line interface for managing Rackspace services
# Keypair named swarm
# ssh-keygen -q -b 4096 -t rsa -N "" -f ~/.ssh/id_rsa.swarm
# for region in ORD IAD; do
# export RS_REGION_NAME=${region}
# rack servers keypair upload --name swarm --file ~/.ssh/
# done
main() {
echo "$@"
loop $@
loop() {
for region in ORD IAD; do
export RS_REGION_NAME=${region}
echo -e "Region\t\t${RS_REGION_NAME}"
for i in $(seq -f "%02g" 1 1); do
echo -e "Name\t\t${SERVER_NAME}"
create() {
rack servers instance create \
--name ${SERVER_NAME} \
--image-name "Ubuntu 16.04 LTS (Xenial Xerus) (PVHVM)" \
--flavor-name "512MB Standard Instance" \
--keypair swarm \
delete() {
rack servers instance delete --name ${SERVER_NAME}
version() {
DOCKER_VERSION=$(ssh -i ~/.ssh/id_rsa.swarm root@${SERVER_IP} docker version | grep Version | tail -n 1 | awk '{print $2}')
echo -e "Version\t\t${DOCKER_VERSION}"
hello() {
ssh -i ~/.ssh/id_rsa.swarm root@${SERVER_IP} docker run alpine echo "Hello World"
join() {
ssh -i ~/.ssh/id_rsa.swarm root@${SERVER_IP} docker swarm join --secret ${SWARM_SECRET} ${SWARM_MANAGER_IP}:2377
leave() {
ssh -i ~/.ssh/id_rsa.swarm root@${SERVER_IP} docker swarm leave
info() {
ssh -i ~/.ssh/id_rsa.swarm root@${SERVER_IP} docker info | awk '/Swarm/,/Runtimes/' | sed '$ d'
get_server_ip() {
echo $(rack servers instance get --name ${SERVER_NAME} --fields publicipv4 | awk '{print $2}')
main $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.