Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Capistrano recipes for setting up and deploying to Slicehost
Ruby
branch: master

This branch is 130 commits ahead of cpjolicoeur:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/capistrano/ext
.gitignore
MIT-LICENSE
README.textile
Rakefile
VERSION.yml
bcalloway-slicehost.gemspec

README.textile

Slicehost Recipes

Note: This is a fork of the original slicehost Capistrano recipies by Joshua Peek

Slicehost Capistrano recipes for configuring and managing your slice. Require Capistrano >2.5.0.

Requirements

  • Ubuntu 9.10 or newer
  • Root access
  • Capistrano

Sample Capitrano Deploy Recipe

The following is a sample portion of a Capistrano deploy recipe. All the following options need to be set, although you might have some additions depending on your specific setup.


  set :project, 'myproject' # The name of the project in your GitHub repo 

  set :github_user, "username" # Your GitHub username
  set :domain_name, "mydomain.com" # should be something like mydomain.com
  set :user, 'username' # server username
  set :domain, 'XXX.XXX.XX.XX' # server IP address
  set :domain_prefix, "mydomain" # the production domain name prefix (no www. or .com)
  set :domain_suffix, "com" # Is this a .com, .net, or .org? (just use the 2 letters, no dot)
  set :passenger_version, "2.2.14"

  default_run_options[:pty] = true
  ssh_options[:forward_agent] = true
  ssh_options[:port] = 22 # or change this to an alternate port if you want

  set :repository,  "git@github.com:#{github_user}/#{project}.git" #GitHub clone URL
  set :scm, "git"
  set :scm_passphrase, "" # This is the passphrase (if any) for the ssh key on the server deployed to
  set :branch, "master" # or whatever branch you deploy from
  set :scm_verbose, true
  set :subdomain, "#{project}.#{domain_name}"
  set :application, project
  set :applicationdir, "/home/#{project}" # or whatever directory you want to deploy to

  # Don't change this stuff, but you may want to set shared files at the end of the file ##################
  # deploy config
  set :deploy_to, applicationdir
  set :deploy_via, :remote_cache

  # roles (servers)
  role :app, domain
  role :web, domain
  role :files, domain
  role :gateway, domain
  role :gateway_as_root, domain
  role :db,  domain, :primary => true
  
  #################################
  # All your other deploy settings below here.

Setup

In config/deploy.rb:


  require 'capistrano/ext/slicehost'

In your project root, type the following to see a full list of commands:


  cap -T

Usage

First, setup a normal user. Be sure your capistrano deploy recipe is set to use the root user.


  cap useradd:setup

Now, change your capistrano deploy recipe to use the user you just created, and continue.


  cap slice:configure
</code><pre>
  
This task performs the following:
* Sets-up and secures ssh
* Creates a .bash_profile with helpful shortcuts and colors and creates a nano editor profile
* Sets-up and secures the system with iptables
* Installs and updates aptitude, and provisions the server with essential services
* Sets-up and installs vim
* Sets-up and installs imagemagick

Next, we install a full Ruby stack:<br />
* Apache
* Ruby1.8
* RubyGems
* Passenger
* Git
<pre><code>
  cap slice:provision
</code><pre>

_Note: if you choose to go back and install a Ruby verison other than 1.8.x, you will need to reinstall Passenger_

Now install Rails (it will prompt for what gem you want to install, in this case, type "rails")
<pre><code>
  cap gems:install
</code><pre>
  
You will need to ssh into the server in order to setup mysql and postfix:  
<pre><code>
  sudo aptitude install -y mysql-server mysql-client libmysqlclient15-dev libmysql-ruby1.8
  sudo aptitude install postfix telnet heirloom-mailx

For more information on installing Postfix, see this: http://articles.slicehost.com/2008/7/29/postfix-installation

That should be it for a basic, Rails server.

Slice setup recipes

Commonly used setup recipes. Check the source for more.

Setup ssh, iptables and aptitude


	cap slice:configure

Install Apache


	cap apache:install

Install ruby 1.8


	cap ruby:setup_18

Install ruby enterprise


	cap ruby:install_enterprise

Install ruby gems


	cap gems:install_rubygems

Install passenger


	cap ruby:install_passenger

Upload vhost template


	cap apache:upload_vhost

Install git


	cap git:install

Maintenance recipes

Commonly used maintenance recipes. Check the source for more.

Show disk space


	cap disk:free

Show free memory


	cap disk:memory

Update aptitude


	cap aptitude:update

Upgrade aptitude


	cap aptitude:upgrade

Install package (it will ask you which)


	cap aptitude:install

Reload SSH


	cap ssh:reload

Install a gem (it will ask you which)


	cap gems:intall

List gems


	cap gems:list

Restart apache


	cap apache:restart

Reload apache


	cap apache:reload

Force reload apache


	cap apache:force_reload

All Recipes


cap apache:available_modules      # List available Apache modules
cap apache:available_sites        # List available Apache sites
cap apache:disable_module         # Disable Apache module
cap apache:disable_site           # Disable Apache site
cap apache:enable_module          # Enable Apache module
cap apache:enable_site            # Enable Apache site
cap apache:enabled_modules        # List enabled Apache modules
cap apache:enabled_sites          # List enabled Apache sites
cap apache:force_reload           # Force reload Apache webserver
cap apache:install                # Install Apache
cap apache:reload                 # Reload Apache webserver
cap apache:restart                # Restarts Apache webserver
cap apache:start                  # Starts Apache webserver
cap apache:stop                   # Stops Apache webserver
cap apache:upload_vhost           # Upload Apache virtual host
cap aptitude:full_upgrade         # Upgrades your installed software packages.
cap aptitude:install              # Installs a software package via aptitude.
cap aptitude:safe_upgrade         # Upgrades your installed software packages.
cap aptitude:setup                # Updates software packages and creates a solid base for the server
cap aptitude:uninstall            # Uninstalls a software package via aptitude.
cap aptitude:update               # Updates your software package list.
cap aptitude:upgrade              # Alias for 'aptitude:safe_upgrade'
cap disk:free                     # Show the amount of free disk space.
cap disk:memory                   # Show free memory
cap gems:install                  # Install a gem on the remote server
cap gems:install_rubygems         # Install the gem package system
cap gems:list                     # List gems on remote server
cap gems:uninstall                # Uninstall a gem on the remote server
cap gems:update                   # Update gems on remote server
cap gems:update_system            # Update gem system on remote server
cap git:install                   # Install git
cap iptables:configure            # Harden iptables configuration.
cap istat:setup                   # Setup istat daemon for monitoring with iStat for iPhone.
cap mysql:export                  # Export MySQL database
cap mysql:import                  # Import MySQL database
cap mysql:install                 # Install MySQL
cap mysql:restart                 # Restarts MySQL database server
cap mysql:start                   # Starts MySQL database server
cap mysql:stop                    # Stops MySQL database server
cap nginx:available_sites         # List available Nginx sites
cap nginx:disable_site            # Disable Nginx site
cap nginx:enable_site             # Enable Nginx site
cap nginx:enabled_sites           # List enabled Nginx sites
cap nginx:force_reload            # Force reload Nginx webserver
cap nginx:install                 # Install Nginx
cap nginx:reload                  # Reload Nginx webserver
cap nginx:restart                 # Restarts Nginx webserver
cap nginx:start                   # Starts Nginx webserver
cap nginx:stop                    # Stops Nginx webserver
cap nginx:upload_vhost            # Upload Nginx virtual host
cap postgresql:export             # Export PostgreSQL database
cap postgresql:import             # Import PostgreSQL database
cap postgresql:install            # Install PostgreSQL
cap postgresql:restart            # Restarts PostgreSQL database server
cap postgresql:start              # Starts PostgreSQL database server
cap postgresql:stop               # Stops PostgreSQL database server
cap prod                          # Set the target stage to `prod'.
cap profile:configure             # Setup .bashrc the way we like it
cap ruby:install_enterprise       # Install Ruby Enterpise Edition
cap ruby:install_passenger_apache # Install Phusion Passenger
cap ruby:setup_18                 # Install Ruby 1.8
cap ruby:setup_19                 # Install Ruby 1.9
cap shell                         # Begin an interactive Capistrano session.
cap slice:configure               # set up ssh, iptables, aptitude and vim
cap ssh:configure_sshd            # Configure SSH daemon with more secure setings
cap ssh:reload                    # Reload SSH service.
cap ssh:setup                     # Setup SSH on the gateway host.
cap ssh:upload_keys               # Uploads your local public SSH keys 
cap staging                       # Set the target stage to `staging'.
cap useradd:check_sudoers         # Check that %sudo entry exists in the /etc/sudoers file
cap useradd:setup                 # Interactive adduser
cap vim:install                   # install vim from aptitude
cap vim:load_vimrc                # load up a simple .vimrc
cap vim:setup                     # setup vim on slicehost

Contributors

  • Oleg Zhurbiy
  • Thomas Balthazar
  • Fran Diéguez
  • Stephen Lumenta
  • Jared Giles
  • John Nunemaker
  • Eloy Duran
  • Mischa Fierer
  • Kurt Schrader

Copyright © 2009 Joshua Peek, released under the MIT license

Something went wrong with that request. Please try again.