Skip to content

Commit eca3d9f

Browse files
author
Gabriel Monroy
committed
separate controller/node ec2 ami prep
1 parent bd89618 commit eca3d9f

3 files changed

Lines changed: 82 additions & 17 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash -ex
2+
3+
#
4+
# Prepare a Deis-optimized Controller AMI from a vanilla Ubuntu 12.04
5+
#
6+
# Instructions:
7+
#
8+
# 1. Launch a vanilla Ubuntu 12.04 instance (64-bit with an EBS root volume)
9+
# 2. SSH in and install the 3.8 kernel with:
10+
# apt-get update && apt-get install -yq linux-image-generic-lts-raring linux-headers-generic-lts-raring && reboot
11+
# 3. After reboot is complete, SSH in and `uname -r` to confirm kernel is 3.8
12+
# 4. Run this script (as root!) to optimize the image for fast boot times
13+
# 5. Create a new AMI from the root volume
14+
# 6. Distribute the AMI to other regions using `ec2-copy-image`
15+
# 7. Update `provision-ec2-controller.sh` script with new AMIs
16+
#
17+
18+
# Remove old kernel(s)
19+
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
20+
21+
# Add the Docker repository key to your local keychain
22+
# using apt-key finger you can check the fingerprint matches 36A1 D786 9245 C895 0F96 6E92 D857 6A8B A88D 21E9
23+
curl https://get.docker.io/gpg | apt-key add -
24+
25+
# Add the Docker repository to your apt sources list.
26+
echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
27+
28+
# upgrade to latest packages
29+
apt-get update
30+
apt-get dist-upgrade -yq
31+
32+
# install required packages
33+
apt-get install lxc-docker-0.7.6 fail2ban curl git inotify-tools make python-setuptools python-pip -yq
34+
35+
# wait for docker to start
36+
while [ ! -e /var/run/docker.sock ] ; do
37+
inotifywait -t 2 -e create $(dirname /var/run/docker.sock)
38+
done
39+
40+
# pull docker images
41+
docker pull deis/etcd
42+
docker pull deis/postgres
43+
docker pull deis/redis
44+
docker pull deis/server
45+
docker pull deis/worker
46+
docker pull deis/registry
47+
docker pull deis/builder
48+
docker pull deis/rsyslog
49+
50+
# install chef 11.x deps
51+
apt-get install -yq ruby1.9.1 ruby1.9.1-dev make
52+
update-alternatives --set ruby /usr/bin/ruby1.9.1
53+
update-alternatives --set gem /usr/bin/gem1.9.1
54+
55+
# clean and remove old packages
56+
apt-get clean
57+
apt-get autoremove -yq
58+
59+
# reset cloud-init
60+
rm -rf /var/lib/cloud
61+
62+
# purge SSH authorized keys
63+
rm -f /home/ubuntu/.ssh/authorized_keys
64+
rm -f /root/.ssh/authorized_keys
65+
66+
# remove /etc/chef so contents can't intefere with
67+
# node being converged (i.e. old keys)
68+
rm -f /etc/chef/*
69+
70+
# purge /var/log
71+
find /var/log -type f | xargs rm
72+
73+
# flush writes to block storage
74+
sync
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash -ex
22

33
#
4-
# Prepare a Deis-optimized AMI from a vanilla Ubuntu 12.04
4+
# Prepare a Deis-optimized Node AMI from a vanilla Ubuntu 12.04
55
#
66
# Instructions:
77
#
@@ -18,15 +18,6 @@
1818
# Remove old kernel(s)
1919
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
2020

21-
apt-get install fail2ban python-software-properties -y
22-
23-
# Add the Nginx repository key to our local keychain
24-
# using apt-key finger you can check the fingerprint matches 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62
25-
curl http://nginx.org/keys/nginx_signing.key | apt-key add -
26-
27-
# Add the Nginx repository to our apt sources list
28-
echo deb http://nginx.org/packages/ubuntu precise nginx > /etc/apt/sources.list.d/nginx-ppa.list
29-
3021
# Add the Docker repository key to your local keychain
3122
# using apt-key finger you can check the fingerprint matches 36A1 D786 9245 C895 0F96 6E92 D857 6A8B A88D 21E9
3223
curl https://get.docker.io/gpg | apt-key add -
@@ -39,15 +30,15 @@ apt-get update
3930
apt-get dist-upgrade -yq
4031

4132
# install required packages
42-
apt-get install lxc-docker-0.7.6 curl git inotify-tools make python-setuptools python-pip -yq
33+
apt-get install lxc-docker-0.7.6 fail2ban curl git inotify-tools make python-setuptools python-pip -yq
4334

4435
# wait for docker to start
4536
while [ ! -e /var/run/docker.sock ] ; do
4637
inotifywait -t 2 -e create $(dirname /var/run/docker.sock)
4738
done
4839

49-
# pull progrium/cedarish docker image
50-
docker pull progrium/cedarish
40+
# pull docker images
41+
docker pull deis/slugrunner
5142

5243
# install chef 11.x deps
5344
apt-get install -yq ruby1.9.1 ruby1.9.1-dev make

contrib/ec2/provision-ec2-controller.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ fi
3434
#################
3535
# chef settings #
3636
#################
37-
node_name=deis-controller
37+
node_name=deis-controller-ec2
3838
run_list="recipe[deis::controller]"
39-
chef_version=11.6.2
39+
chef_version=11.8.2
4040

4141
#######################
4242
# Amazon EC2 settings #
@@ -59,7 +59,7 @@ elif [ "$region" == "us-east-1" ]; then
5959
elif [ "$region" == "us-west-1" ]; then
6060
image=ami-62477527
6161
elif [ "$region" == "us-west-2" ]; then
62-
image=ami-ea6001da
62+
image=ami-ac690a9c
6363
else
6464
echo "Cannot find AMI for region: $region"
6565
exit 1
@@ -89,6 +89,7 @@ if ! ec2-describe-group | grep -q "$sg_name"; then
8989
ec2-authorize deis-controller -P tcp -p 80 -s $sg_src >/dev/null
9090
ec2-authorize deis-controller -P tcp -p 443 -s $sg_src >/dev/null
9191
ec2-authorize deis-controller -P tcp -p 514 -s $sg_src >/dev/null
92+
ec2-authorize deis-controller -P tcp -p 2222 -s $sg_src >/dev/null
9293
set +x
9394
else
9495
echo_color "Security group $sg_name exists"
@@ -107,7 +108,6 @@ else
107108
fi
108109

109110
# create data bags
110-
knife data bag create deis-users 2>/dev/null
111111
knife data bag create deis-formations 2>/dev/null
112112
knife data bag create deis-apps 2>/dev/null
113113

0 commit comments

Comments
 (0)