Skip to content

Instantly share code, notes, and snippets.

@botchagalupe
Created November 26, 2010 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save botchagalupe/716236 to your computer and use it in GitHub Desktop.
Save botchagalupe/716236 to your computer and use it in GitHub Desktop.
TSE Training Setup (Instructor Notes)

Class Setup on Ubuntu

Setup a Instructor Node on Ubuntu

ami-4a0df923 - Ubuntu 10.04 - 64 Bit - EBS Instance (t1.micro) ami-480df921 - Ubuntu 10.04 - 32 Bit - EBS Instance (m1.small)

ec2-run-instances ami-480df921 --instance-type m1.small --region us-east-1 --key botchagalupe -g default -g wordpress

iinst=`knife ec2 server list | grep running | grep wordpress | awk '{print $2}'`

scp ~/chef-repo/chef.tar ubuntu@$iinst:~

ssh ubuntu@$iinst

_ Create and run Chef Client Boot Script_

if [ ! -f /usr/bin/chef-client ]; then
  apt-get update
  apt-get install -y ruby ruby1.8-dev build-essential wget libruby-extras libruby1.8-extras
  cd /tmp
  wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
  tar zxf rubygems-1.3.7.tgz
  cd rubygems-1.3.7
  ruby setup.rb --no-format-executable
fi

gem install ohai chef --no-rdoc --no-ri --verbose

sudo apt-get -y install libxml2 libxml2-dev libxslt1-dev git-core

sudo gem install net-ssh net-ssh-multi highline --no-rdoc --no-ri --verbose

sudo gem install fog -v 0.2.30 --no-rdoc --no-ri --verbose

mkdir mkdir -p /etc/chef

Create the Chef-Repo

cd ~
git clone http://github.com/opscode/chef-repo.git
cp chef.tar chef-repo 
cd ~/chef-repo
tar -xvf chef.tar 

Validate the install and setup

knife client list

Complete the Client install

Generate your Chef client configuration

cd ~/chef-repo
knife configure client ./client-config
sudo cp ~/chef-repo/client-config/* /etc/chef
sudo chef-client

Setup the new ENV

cat  ~/chef-repo/.chef/legacy-config >>~/.bashrc 

Optionally Install EC2 Tools on image

sudo vi  /etc/apt/sources.list

Add

deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ lucid main multiverse

sudo apt-get update

Install EC2 CLI

sudo apt-get -y install ec2-api-tools 

Verify

Run the code in ~/chef-repo/.chef/legacy-config or place in bash.rc

ec2-describe-images -o self -o amazon

Class Setup on Ubuntu (Student Notes)

Setup a Student Nodes on Ubuntu

ec2-run-instances ami-4a0df923 --instance-type t1.micro --region us-east-1 --key botchagalupe -g default -g tse-demo -n 12

Create a NodeList (From Mac)

instances=""
for i in `knife ec2 server list | grep running | grep tse-demo | awk '{print $2}'`
do
  export instances="$instances $i"
done

Saved Command Version

for i in `knife ec2 server list | grep running | grep tse-demo | awk '{print $2}'`; do export instances="$instances $i"; done

Create a CAPFILE

require 'tempfile'

set(:nodelist) do
  Capistrano::CLI.ui.ask "Node list: "
end unless exists?(:nodelist)

nodelist.split.each do |node|
  role :nodes, node, :ssh_options => {:user => "ubuntu", :keys => "~/chef-repo/.chef/botchagalupe.pem"}
end

task :default do
  pwhash = "$1$xMc08XfL$b4aNqWyrFB3yg3S3oJo2m0"
  sudo "usermod -p '#{pwhash}' ubuntu"
  sudo "sed -i 's/^PasswordAuthentication no$/PasswordAuthentication yes/' /etc/ssh/sshd_config"
  sudo "/etc/init.d/ssh restart"
end

Run the CAPFILE against the nodes

Install Capistrano if not installed

sudo apt-get -y install capistrano

cap default -S nodelist="$instances"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment