Skip to content

Instantly share code, notes, and snippets.

@ViktorOgnev
Created July 10, 2014 12:39
Show Gist options
  • Save ViktorOgnev/1fc1a2f928ea4c386591 to your computer and use it in GitHub Desktop.
Save ViktorOgnev/1fc1a2f928ea4c386591 to your computer and use it in GitHub Desktop.
#!/bin/bash
# clone ci repo
# install essential deps
cd ~
rm
apt-get update
apt-get install -y git curl make ruby1.9.1-dev
curl -L https://www.opscode.com/chef/install.sh | bash
gem install --no-ri --no-rdoc librarian-chef
echo 'cloning ci repo'
rm -rf /tmp/ci
mkdir -p /tmp/ci
git clone [email protected]:Scalr/ci.git /tmp/ci
echo 'ci repo contains:'
ls /tmp/ci
# Create cookbook infrastructure
mkdir -p /tmp/chef-solo
mkdir -p /tmp/chef-solo/cookbooks
export LIBRARIAN_CHEF_PATH=/tmp/chef-solo/cookbooks
source /etc/profile.d/scalr_globals.sh
# Deploy master
if [[ $SCALR_FARM_ROLE_ALIAS == 'strider-ci-master' ]]; then
echo 'got ci master, deploying strider'
rm -rf /projects/fatmouse
git clone [email protected]:Scalr/fatmouse.git /projects/fatmouse
rm -rf /projects/scalarizr
git clone [email protected]:Scalr/int-scalarizr.git /projects/scalarizr
git clone [email protected]:Scalr/data_bags.git ~/.chef/data_bags
rm -r /tmp/chef-solo/data_bags
cp -r ~/.chef/data_bags/ /tmp/chef-solo/data_bags
echo 'Required repositories cloned'
cd /tmp/ci
cp -r /tmp/ci/chef/cookbooks/ci/files/default /tmp/chef-solo/cache
librarian-chef install
echo 'Librarian chef installed'
cat <<EOC > /tmp/chef-solo/solo.rb
solo_dir "/tmp/chef-solo"
file_cache_path "#{solo_dir}/cache"
file_backup_path "#{solo_dir}/backup"
cookbook_path "#{solo_dir}/cookbooks"
encrypted_data_bag_secret "/root/.chef/databags_secret_key"
encrypted_data_bag_secret_key_path "~/.chef/databags_secret_key"
data_bags_path "~/.chef/data_bags"
EOC
cat <<EOC > /tmp/chef-solo/attr.json
{"run_list": [
"recipe[commons::github_auth]",
"recipe[ci::master]",
"recipe[ci::stridercd]",
"recipe[ci::repository]"
],
"base_url": "http://107.178.220.114:3000"
}
EOC
chef-solo -c /tmp/chef-solo/solo.rb -j /tmp/chef-solo/attr.json
sudo sed -i.old '1s;^;107.178.212.181 ubuntu-10.04\n;' /etc/hosts
sudo sed -i.old '1s;^;107.178.212.181 ubuntu-10.04-32\n;' /etc/hosts
sudo sed -i.old '1s;^;107.178.212.181 centos-5\n;' /etc/hosts
sudo sed -i.old '1s;^;107.178.212.181 centos-5-32\n;' /etc/hosts
# launch lxc slaves
elif [[ $SCALR_FARM_ROLE_ALIAS == 'strider-ci-slave' ]]; then
echo 'got ci slave, deploying lxc boxes'
cd /tmp/ci
sudo apt-get purge vagrant --yes
sudo apt-get purge lxc --yes
# install lxc
sudo sed -i.old '1s;^;deb http://http.debian.net/debian jessie main\n;' /etc/apt/sources.list.d/jessie.list
sudo sed -i.old '1s;^;deb-src http://http.debian.net/debian jessie main\n;' /etc/apt/sources.list.d/jessie.list
cat <<EOC > /etc/apt/preferences.d/lxc_jessie_pin.pref
Package: *
Pin: release n=jessie
Pin-Priority: 100
Package: lxc
Pin: release n=jessie
Pin-Priority: 600
Package: libc6
Pin: release n=jessie
Pin-Priority: 600
EOC
apt-get update
apt-get install -y lxc redir bridge-utils libc6
sudo sed -i.old '1s;^;none /sys/fs/cgroup cgroup defaults 0 0\n;' /etc/fstab
/etc/fstab
# install vagrant
wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.4.3_x86_64.deb
dpkg -i vagrant_1.4.3_x86_64.deb
/usr/bin/vagrant plugin install vagrant-lxc
/usr/bin/vagrant plugin install vagrant-librarian-chef
/usr/bin/vagrant plugin install vagrant-omnibus
cd /tmp/ci
export LIBRARIAN_CHEF_COOKBOOK_PATH=/tmp/ci/chef/cookbooks
export IS_PRODUCTION_STRIDER_CI_SLAVE=True # provision lxc's, skip master – see Vagrantfile
/usr/bin/vagrant up ubuntu-10.04
/usr/bin/vagrant up ubuntu-10.04-32
/usr/bin/vagrant up centos-5
/usr/bin/vagrant up centos-5-32
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment