This repo contains rake tasks to automate some of our DevOps needs. It makes use of [Fog] fog github and Chef chef to create and configureservers in the cloud.
Openstack compatability is broken at this time.
- installs chef clients on the web servers
- installs and configures rbenv, nginx, git, etc
- delpoys a sinatra web app
- launches and configures load balancer
- configures dns for the app
creates ec2 xmpp servers
- installs chef clients on the xmpp servers
- installs and configures git, java, tigase
cd ~
git clone [email protected]:splap/fogdemo.git
cd fogdemo
bundle install
Create a free hosted chef account at [OpsCode] chef signup and save your private key as fogdemo.pem and set permissions
chmod og-r ~/.ssh/fogdemo/fogdemo.pem
Install knife and create a Chef Client for our new hosted chef account.
cd ~/fogdemo/chef
sudo gem install chef --no-ri --no-rdoc
knife client create fogclient -a -f "~/ssh/fogdemo/validator.pem"
# see the new client
knife client list
Fetch cookbook declarations from OpsCode
cd ~/fogdemo/chef
librarian-chef install --clean --verbose
Upload roles and cookbooks to hosted chef server
rake push_chef_updates
Fog creates a server, and bootstraps chef. chef installs rbenv, git, nginx, logrotate, etc. It then pulls a sinatra app, installs required gems, and starts up puma.
rake create_web
Connect to or create a load balancer and tell it which web instance to use
rake lb
Configure DNS. Points an alias A record at the load balancer
rake dns
Update all webservers. This will apply chef configuration changes and update the sinatra app. This would not work in a zero downtime deploy strategy without more effort.
rake update_web
Get an overview of the app's cloud deployment (default rake task)
rake
Stop and destroy a web server
rake destroy_server['server_id']
Stop and abandon all existing servers
rake destroy_all
Upload xmpp role on the hosted chef server
knife role from file roles/xmppserver.rb
Create a new xmpp server - installs chef client and runs xmpp role, installing java, tigase, derby db, etc.
rake create_xmpp
Update all xmpp servers
rake update_xmpp