SlideShare a Scribd company logo
1 of 18
Making Your Capistrano
     Recipe Book

        Tim Riley
        @timriley
development:
                                                                                                                     oauth_consumer_key: secret_oauth_thing
                                                                                                                     oauth_consumer_secret: secret_oauth_thing
                                                        namespace :gems do
                                                                                                                     oauth_callback: "http://decafsucks.com/oauth_callback"
                                                          task :install, :roles => :app do
# App                                                                                                                <<: *base
                                                            sudo "sh -c 'cd #{release_path} && sudo RAILS_ENV=production rake gems:install'"
set :application, "decafsucks"
                                                          end
                                                                                                                   test: &test
                                                        end
# Server                                                                                                             oauth_consumer_key: secret_oauth_thing
set :user, 'deployer'                                                                                                oauth_consumer_secret: secret_oauth_thing
                                                        namespace :db do
set :deploy_to, "/home/deployer/deployments/#{application}"                                                          oauth_callback: "http://decafsucks.com/oauth_callback"
                                                          task :generate_yaml, :roles => :app do
set :use_sudo, false                                                                                                 <<: *base
                                                            db_config = <<-EOF
set :port, '2222'
                                                        base: &base
                                                                                                                   production:
                                                          adapter: mysql
role :app, '192.168.0.1'                                                                                             oauth_consumer_key: secret_oauth_thing
                                                          encoding: utf8
role :web, '192.168.0.1'                                                                                             oauth_consumer_secret: secret_oauth_thing
                                                          username: mysql_user
role :db,   '192.168.0.1', :primary => true                                                                          oauth_callback: "http://decafsucks.com/oauth_callback"
                                                          password: #{db_password}
                                                                                                                     <<: *base
                                                          socket: /var/run/mysqld/mysqld.sock
# Other                                                                                                            EOF
set :db_password, Proc.new { Capistrano::CLI.password_prompt('DB password: ')}                                         run "mkdir -p #{shared_path}/config"
                                                        development:
                                                                                                                       put twitter_config, "#{shared_path}/config/twitter_auth.yml"
                                                          database: decafsucks_development
# SCM                                                                                                                end
                                                          <<: *base
set :scm, :git
set :repository, 'git@somehwere.com/myapp.git'                                                                       desc 'Make symlink for database yaml'
                                                        test: &test
set :branch, 'master'                                                                                                task :symlink, :roles => :app do
                                                          database: decafsucks_test
set :deploy_via, :remote_cache                                                                                         run "ln -nfs #{shared_path}/config/twitter_auth.yml #{release_path}/co
                                                          <<: *base
                                                                                                                     end
default_run_options[:pty] = true                                                                                   end
                                                        rumble:
set :ssh_options, { :forward_agent => true }
                                                          database: decafsucks_production
                                                                                                                   namespace :sphinx do
                                                          <<: *base
# Passenger                                                                                                          desc 'Create a directory to store the sphinx indexes'
namespace :deploy do                                                                                                 task :create_db_dir, :roles => :app do
                                                        production:
  desc "Restarting mod_rails with restart.txt"                                                                         run "mkdir -p #{shared_path}/sphinx"
                                                          database: decafsucks_production
  task :restart, :roles => :app, :except => { :no_release => true } do                                               end
                                                          <<: *base
    run "touch #{current_path}/tmp/restart.txt"
                                                        EOF
  end                                                                                                                desc 'Generate a config yaml in shared path'
                                                            run "mkdir -p #{shared_path}/config"
                                                                                                                     task :generate_yaml, :roles => :app do
                                                            put db_config, "#{shared_path}/config/database.yml"
  [:start, :stop].each do |t|                                                                                          sphinx_yaml = <<-EOF
                                                          end
    desc "#{t} task is a no-op with mod_rails"                                                                     development: &base
    task t, :roles => :app do ; end                                                                                  morphology: stem_en
                                                          desc 'Make symlink for database yaml'
  end                                                                                                                config_file: #{shared_path}/config/sphinx.conf
                                                          task :symlink, :roles => :app do
end                                                                                                                test:
                                                            run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
                                                                                                                     <<: *base
                                                          end
before 'deploy:setup', 'db:generate_yaml'                                                                          production:
                                                        end
before 'deploy:setup', 'twitter:generate_yaml'                                                                       <<: *base
before 'deploy:setup', 'sphinx:create_db_dir'                                                                      EOF
                                                        namespace :twitter do
before 'deploy:setup', 'sphinx:generate_yaml'                                                                          run "mkdir -p #{shared_path}/config"
                                                          task :generate_yaml, :roles => :app do
                                                                                                                       put sphinx_yaml, "#{shared_path}/config/sphinx.yml"
                                                            twitter_config = <<-EOF
after 'deploy:update_code', 'db:symlink'                                                                             end
                                                        base: &base
after 'deploy:update_code', 'twitter:symlink'                                                                        desc 'Symlink the sphinx yml and config files, and the db directory for
                                                          strategy: oauth
after 'deploy:update_code', 'sphinx:symlink'                                                                         task :symlink, :roles => :app do
                                                          base_url: "https://twitter.com"
                                                                                                                       run "ln -nfs #{shared_path}/sphinx             #{release_path}/db/sphi
                                                          authorize_path: "/oauth/authenticate"
# after 'deploy:update_code', 'gems:install'                                                                           run "ln -nfs #{shared_path}/config/sphinx.yml #{release_path}/config/
                                                          api_timeout: 10
                                                                                                                       run "ln -nfs #{shared_path}/config/sphinx.conf #{release_path}/config/
                                                          remember_for: 14 # days
                                                                                                                     end
                                                                                                                   end
set   :application, "decafsucks"
set   :user, 'deployer'
set   :deploy_to, "/home/deployer/deployments/#{application}"
set   :use_sudo, false

role :app,    '192.168.0.1'
role :web,    '192.168.0.1'
role :db,     '192.168.0.1', :primary => true

set   :scm, :git
set   :repository, 'git@git.mycorp.net:decafsucks.git’
set   :branch, 'master'
set   :deploy_via, :remote_cache

default_run_options[:pty] = true
set :ssh_options, { :forward_agent => true }
namespace :deploy do
  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end

  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with mod_rails"
    task t, :roles => :app do ; end
  end
end
before   'deploy:setup',       'sphinx:create_db_dir'
before   'deploy:setup',       'sphinx:generate_yaml'
after    'deploy:update_code', 'sphinx:symlink'

namespace :sphinx do
  desc 'Create a directory to store the sphinx indexes'
  task :create_db_dir, :roles => :app do
    run "mkdir -p #{shared_path}/sphinx"
  end

  desc 'Generate a config yaml in shared path'
  task :generate_yaml, :roles => :app do
    sphinx_yaml = <<-EOF
development: &base
  morphology: stem_en
  config_file: #{shared_path}/config/sphinx.conf
test:
  <<: *base
production:
  <<: *base
EOF
    run "mkdir -p #{shared_path}/config"
    put sphinx_yaml, "#{shared_path}/config/sphinx.yml"
  end

  desc 'Symlink the sphinx yml and config files, and the db directory for storage of indexes'
  task :symlink, :roles => :app do
    run "ln -nfs #{shared_path}/sphinx             #{release_path}/db/sphinx"
    run "ln -nfs #{shared_path}/config/sphinx.yml #{release_path}/config/sphinx.yml"
    run "ln -nfs #{shared_path}/config/sphinx.conf #{release_path}/config/sphinx.conf"
  end
end
configuration = Capistrano::Configuration.respond_to?(:instance) ?
  Capistrano::Configuration.instance(:must_exist) :
  Capistrano.configuration(:must_exist)

configuration.load do
  # stuff here...
end
unless Capistrano::Configuration.respond_to?(:instance)
  abort "capistrano/ext/multistage requires Capistrano 2"
end

Capistrano::Configuration.instance.load do
  # stuff here...
end
base.rb
configuration.load do

# User details
_cset :user,            'deployer'
_cset(:group)           { user }

# Application details
_cset(:app_name)        { abort "Specify the short name of your app, set :app_name, 'foo'" }
set(:application)       { "#{app_name}.mycorp.com" }
_cset(:runner)          { user }
_cset :use_sudo,        false

# SCM settings
_cset(:appdir)          { "/home/#{user}/deployments/#{application}" }
_cset :scm,             'git'
set(:repository)        { "git@git.mycorp.com:#{app_name}.git"}
_cset :deploy_via,      'remote_cache'
set(:deploy_to)         { appdir }

# Git settings for capistrano
default_run_options[:pty]     = true
ssh_options[:forward_agent]   = true

end
common.rb



def _cset(name, *args, &block)
  unless exists?(name)
    set(name, *args, &block)
  end
end
base.rb
configuration.load do

# User details
_cset :user,            'deployer'
_cset(:group)           { user }

# Application details
_cset(:app_name)        { abort "Specify the short name of your app, set :app_name, 'foo'" }
set(:application)       { "#{app_name}.mycorp.com" }
_cset(:runner)          { user }
_cset :use_sudo,        false

# SCM settings
_cset(:appdir)          { "/home/#{user}/deployments/#{application}" }
_cset :scm,             'git'
set(:repository)        { "git@git.mycorp.com:#{app_name}.git"}
_cset :deploy_via,      'remote_cache'
set(:deploy_to)         { appdir }

# Git settings for capistrano
default_run_options[:pty]     = true
ssh_options[:forward_agent]   = true

end
require 'capistrano/mycorp/common'
configuration.load do
_cset(:app_name) { abort "Specify the short name of your app, set :app_name, 'foo'" }

before   'deploy:setup',       'sphinx:create_db_dir'
before   'deploy:setup',       'sphinx:generate_yaml'
after    'deploy:update_code', 'sphinx:symlink'

namespace :sphinx do
  desc 'Create a directory to store the sphinx indexes'
  task :create_db_dir, :roles => :app do
    run "mkdir -p #{shared_path}/sphinx"


                                                               thinking_
  end

  desc 'Generate a config yaml in shared path'
  task :generate_yaml, :roles => :app do
    sphinx_yaml = <<-EOF
development: &main_settings
  config_file: #{shared_path}/config/sphinx.conf
                                                               sphinx.rb
  pid_file: #{shared_path}/pids/sphinx.pid
production:
  <<: *main_settings
EOF
    put sphinx_yaml, "#{shared_path}/config/sphinx.yml"
  end

  desc 'Symlink the sphinx yml and config files, and the db directory for storage of indexes'
  task :symlink, :roles => :app do
    run "ln -nfs #{shared_path}/sphinx             #{release_path}/db/sphinx"
    run "ln -nfs #{shared_path}/config/sphinx.yml #{release_path}/config/sphinx.yml"
    run "ln -nfs #{shared_path}/config/sphinx.conf #{release_path}/config/sphinx.conf"
  end
end
end
Rakefile

begin
  require 'jeweler'
  Jeweler::Tasks.new do |gemspec|
    gemspec.name = "capistrano-mycorp"
    gemspec.summary = "MyCorp recipes for Capistrano"
    gemspec.description = "MyCorp recipes for Capistrano"
    gemspec.email = "tim@openmonkey.com"
    gemspec.homepage = "http://github.com/timriley/capistrano-mycorp"
    gemspec.authors = ["Tim Riley"]
  end
rescue LoadError
  puts "Jeweler not available. Install it with: gem install jeweler"
end
echo "0.0.1" > VERSION
rake gemspec
rake build

jeweler --help
set   :application, "decafsucks"
set   :user, 'deployer'
set   :deploy_to, "/home/deployer/deployments/#{application}"            namespace :sphinx do
set   :use_sudo, false                                                     desc 'Create a directory to store the sphinx indexes'
                                                                           task :create_db_dir, :roles => :app do
role :app,    '192.168.0.1'                                                  run "mkdir -p #{shared_path}/sphinx"
role :web,    '192.168.0.1'                                                end
role :db,     '192.168.0.1', :primary => true
                                                                           desc 'Generate a config yaml in shared path'
set   :scm, :git                                                           task :generate_yaml, :roles => :app do
set   :repository, 'git@git.mycorp.net:decafsucks.git'                       sphinx_yaml = <<-EOF
set   :branch, 'master'                                                  development: &base
set   :deploy_via, :remote_cache                                           morphology: stem_en
                                                                           config_file: #{shared_path}/config/sphinx.conf
default_run_options[:pty] = true                                         test:
set :ssh_options, { :forward_agent => true }                               <<: *base
                                                                         production:
namespace :deploy do                                                       <<: *base
  desc "Restarting mod_rails with restart.txt"                           EOF
  task :restart, :roles => :app, :except => { :no_release => true } do       run "mkdir -p #{shared_path}/config"
    run "touch #{current_path}/tmp/restart.txt"                              put sphinx_yaml, "#{shared_path}/config/sphinx.yml"
  end                                                                      end

  [:start, :stop].each do |t|                                              desc 'Symlink the sphinx yml and config files, and the db directory for storage of indexes'
    desc "#{t} task is a no-op with mod_rails"                             task :symlink, :roles => :app do
    task t, :roles => :app do ; end                                          run "ln -nfs #{shared_path}/sphinx             #{release_path}/db/sphinx"
  end                                                                        run "ln -nfs #{shared_path}/config/sphinx.yml #{release_path}/config/sphinx.yml"
end                                                                          run "ln -nfs #{shared_path}/config/sphinx.conf #{release_path}/config/sphinx.conf"
                                                                           end
before    'deploy:setup',       'sphinx:create_db_dir'                   end
before    'deploy:setup',       'sphinx:generate_yaml'
after     'deploy:update_code', 'sphinx:symlink'
set :app_name, 'decafsucks'

role :app,   '192.168.0.1'
role :web,   '192.168.0.1'
role :db,    '192.168.0.1', :primary => true

require 'capistrano/mycorp/base'
require 'capistrano/mycorp/thinking_sphinx'
★ Multistage defaults
★ Mounting shares
★ web:disable
★ Gem installation
★ Gem bundling
★ Populating config.yml
★ Populating database.yml
★ Thinking Sphinx
★ ...
Thank You!


        @timriley

    openmonkey.com

timriley/capistrano-mycorp

 technicalpickles/jeweler

More Related Content

What's hot

Vagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptopVagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptopLorin Hochstein
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansibleKhizer Naeem
 
Ansible for beginners
Ansible for beginnersAnsible for beginners
Ansible for beginnersKuo-Le Mei
 
DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)Soshi Nemoto
 
Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Soshi Nemoto
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Michele Orselli
 
CoreOS, or How I Learned to Stop Worrying and Love Systemd
CoreOS, or How I Learned to Stop Worrying and Love SystemdCoreOS, or How I Learned to Stop Worrying and Love Systemd
CoreOS, or How I Learned to Stop Worrying and Love SystemdRichard Lister
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with AnsibleRayed Alrashed
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)Soshi Nemoto
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012Carlos Sanchez
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleRoman Rodomansky
 
Using cobbler in a not so small environment 1.77
Using cobbler in a not so small environment 1.77Using cobbler in a not so small environment 1.77
Using cobbler in a not so small environment 1.77chhorn
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with DockerGeeta Vinnakota
 
Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionJoshua Thijssen
 
DevOps(2) : Vagrant - (MOSG)
DevOps(2) : Vagrant  -  (MOSG)DevOps(2) : Vagrant  -  (MOSG)
DevOps(2) : Vagrant - (MOSG)Soshi Nemoto
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Composeraccoony
 

What's hot (20)

Vagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptopVagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptop
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
Ansible for beginners
Ansible for beginnersAnsible for beginners
Ansible for beginners
 
DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)DevOps(3) : Ansible - (MOSG)
DevOps(3) : Ansible - (MOSG)
 
Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
CoreOS, or How I Learned to Stop Worrying and Love Systemd
CoreOS, or How I Learned to Stop Worrying and Love SystemdCoreOS, or How I Learned to Stop Worrying and Love Systemd
CoreOS, or How I Learned to Stop Worrying and Love Systemd
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
 
Docker.io
Docker.ioDocker.io
Docker.io
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
 
Puppet fundamentals
Puppet fundamentalsPuppet fundamentals
Puppet fundamentals
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with Ansible
 
Using cobbler in a not so small environment 1.77
Using cobbler in a not so small environment 1.77Using cobbler in a not so small environment 1.77
Using cobbler in a not so small environment 1.77
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
 
Cobbler, Func and Puppet: Tools for Large Scale Environments
Cobbler, Func and Puppet: Tools for Large Scale EnvironmentsCobbler, Func and Puppet: Tools for Large Scale Environments
Cobbler, Func and Puppet: Tools for Large Scale Environments
 
Docker toolbox
Docker toolboxDocker toolbox
Docker toolbox
 
Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 Edition
 
DevOps(2) : Vagrant - (MOSG)
DevOps(2) : Vagrant  -  (MOSG)DevOps(2) : Vagrant  -  (MOSG)
DevOps(2) : Vagrant - (MOSG)
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 

Viewers also liked

Viewers also liked (11)

The "Big Bang" of Consumer and Business Marketing - Scott Berg
The "Big Bang" of Consumer and Business Marketing - Scott BergThe "Big Bang" of Consumer and Business Marketing - Scott Berg
The "Big Bang" of Consumer and Business Marketing - Scott Berg
 
B2B e-marketing: The Big Crew Change
B2B e-marketing: The Big Crew ChangeB2B e-marketing: The Big Crew Change
B2B e-marketing: The Big Crew Change
 
Pp 2 Prehistorie Deel I
Pp 2  Prehistorie Deel IPp 2  Prehistorie Deel I
Pp 2 Prehistorie Deel I
 
Supercharging Your Business Through Local Search
Supercharging Your Business Through Local SearchSupercharging Your Business Through Local Search
Supercharging Your Business Through Local Search
 
Experience the Interface
Experience the InterfaceExperience the Interface
Experience the Interface
 
Blast to the Past
Blast to the PastBlast to the Past
Blast to the Past
 
Rainer LäTtemäGi Ameerika
Rainer LäTtemäGi AmeerikaRainer LäTtemäGi Ameerika
Rainer LäTtemäGi Ameerika
 
Komikia 1 (Pp Tminimizer)
Komikia 1 (Pp Tminimizer)Komikia 1 (Pp Tminimizer)
Komikia 1 (Pp Tminimizer)
 
Idaho Powerpoint
Idaho PowerpointIdaho Powerpoint
Idaho Powerpoint
 
Introduction to organizational behavior
Introduction to organizational behaviorIntroduction to organizational behavior
Introduction to organizational behavior
 
Digital Influence : what's at stake for advertisers?
Digital Influence : what's at stake for advertisers?Digital Influence : what's at stake for advertisers?
Digital Influence : what's at stake for advertisers?
 

Similar to Making Your Capistrano Recipe Book

Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppSmartLogic
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Carlos Sanchez
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Carlos Sanchez
 
Facebook的缓存系统
Facebook的缓存系统Facebook的缓存系统
Facebook的缓存系统yiditushe
 
Service discovery and configuration provisioning
Service discovery and configuration provisioningService discovery and configuration provisioning
Service discovery and configuration provisioningSource Ministry
 
4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebookguoqing75
 
Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013grim_radical
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发shaokun
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoAlmir Mendes
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newYiwei Ma
 
Understanding OpenStack Deployments - PuppetConf 2014
Understanding OpenStack Deployments - PuppetConf 2014Understanding OpenStack Deployments - PuppetConf 2014
Understanding OpenStack Deployments - PuppetConf 2014Puppet
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular applicationmirrec
 
Linuxday.at - Lightning Talk
Linuxday.at - Lightning TalkLinuxday.at - Lightning Talk
Linuxday.at - Lightning TalkJan Gehring
 

Similar to Making Your Capistrano Recipe Book (20)

Chef solo the beginning
Chef solo the beginning Chef solo the beginning
Chef solo the beginning
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
 
EC2
EC2EC2
EC2
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012
 
Facebook的缓存系统
Facebook的缓存系统Facebook的缓存系统
Facebook的缓存系统
 
Service discovery and configuration provisioning
Service discovery and configuration provisioningService discovery and configuration provisioning
Service discovery and configuration provisioning
 
4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook
 
Pecl Picks
Pecl PicksPecl Picks
Pecl Picks
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with Capistrano
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
Understanding OpenStack Deployments - PuppetConf 2014
Understanding OpenStack Deployments - PuppetConf 2014Understanding OpenStack Deployments - PuppetConf 2014
Understanding OpenStack Deployments - PuppetConf 2014
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular application
 
Puppet @ Seat
Puppet @ SeatPuppet @ Seat
Puppet @ Seat
 
Linuxday.at - Lightning Talk
Linuxday.at - Lightning TalkLinuxday.at - Lightning Talk
Linuxday.at - Lightning Talk
 

Recently uploaded

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Recently uploaded (20)

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

Making Your Capistrano Recipe Book

  • 1. Making Your Capistrano Recipe Book Tim Riley @timriley
  • 2. development: oauth_consumer_key: secret_oauth_thing oauth_consumer_secret: secret_oauth_thing namespace :gems do oauth_callback: "http://decafsucks.com/oauth_callback" task :install, :roles => :app do # App <<: *base sudo "sh -c 'cd #{release_path} && sudo RAILS_ENV=production rake gems:install'" set :application, "decafsucks" end test: &test end # Server oauth_consumer_key: secret_oauth_thing set :user, 'deployer' oauth_consumer_secret: secret_oauth_thing namespace :db do set :deploy_to, "/home/deployer/deployments/#{application}" oauth_callback: "http://decafsucks.com/oauth_callback" task :generate_yaml, :roles => :app do set :use_sudo, false <<: *base db_config = <<-EOF set :port, '2222' base: &base production: adapter: mysql role :app, '192.168.0.1' oauth_consumer_key: secret_oauth_thing encoding: utf8 role :web, '192.168.0.1' oauth_consumer_secret: secret_oauth_thing username: mysql_user role :db, '192.168.0.1', :primary => true oauth_callback: "http://decafsucks.com/oauth_callback" password: #{db_password} <<: *base socket: /var/run/mysqld/mysqld.sock # Other EOF set :db_password, Proc.new { Capistrano::CLI.password_prompt('DB password: ')} run "mkdir -p #{shared_path}/config" development: put twitter_config, "#{shared_path}/config/twitter_auth.yml" database: decafsucks_development # SCM end <<: *base set :scm, :git set :repository, 'git@somehwere.com/myapp.git' desc 'Make symlink for database yaml' test: &test set :branch, 'master' task :symlink, :roles => :app do database: decafsucks_test set :deploy_via, :remote_cache run "ln -nfs #{shared_path}/config/twitter_auth.yml #{release_path}/co <<: *base end default_run_options[:pty] = true end rumble: set :ssh_options, { :forward_agent => true } database: decafsucks_production namespace :sphinx do <<: *base # Passenger desc 'Create a directory to store the sphinx indexes' namespace :deploy do task :create_db_dir, :roles => :app do production: desc "Restarting mod_rails with restart.txt" run "mkdir -p #{shared_path}/sphinx" database: decafsucks_production task :restart, :roles => :app, :except => { :no_release => true } do end <<: *base run "touch #{current_path}/tmp/restart.txt" EOF end desc 'Generate a config yaml in shared path' run "mkdir -p #{shared_path}/config" task :generate_yaml, :roles => :app do put db_config, "#{shared_path}/config/database.yml" [:start, :stop].each do |t| sphinx_yaml = <<-EOF end desc "#{t} task is a no-op with mod_rails" development: &base task t, :roles => :app do ; end morphology: stem_en desc 'Make symlink for database yaml' end config_file: #{shared_path}/config/sphinx.conf task :symlink, :roles => :app do end test: run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" <<: *base end before 'deploy:setup', 'db:generate_yaml' production: end before 'deploy:setup', 'twitter:generate_yaml' <<: *base before 'deploy:setup', 'sphinx:create_db_dir' EOF namespace :twitter do before 'deploy:setup', 'sphinx:generate_yaml' run "mkdir -p #{shared_path}/config" task :generate_yaml, :roles => :app do put sphinx_yaml, "#{shared_path}/config/sphinx.yml" twitter_config = <<-EOF after 'deploy:update_code', 'db:symlink' end base: &base after 'deploy:update_code', 'twitter:symlink' desc 'Symlink the sphinx yml and config files, and the db directory for strategy: oauth after 'deploy:update_code', 'sphinx:symlink' task :symlink, :roles => :app do base_url: "https://twitter.com" run "ln -nfs #{shared_path}/sphinx #{release_path}/db/sphi authorize_path: "/oauth/authenticate" # after 'deploy:update_code', 'gems:install' run "ln -nfs #{shared_path}/config/sphinx.yml #{release_path}/config/ api_timeout: 10 run "ln -nfs #{shared_path}/config/sphinx.conf #{release_path}/config/ remember_for: 14 # days end end
  • 3. set :application, "decafsucks" set :user, 'deployer' set :deploy_to, "/home/deployer/deployments/#{application}" set :use_sudo, false role :app, '192.168.0.1' role :web, '192.168.0.1' role :db, '192.168.0.1', :primary => true set :scm, :git set :repository, 'git@git.mycorp.net:decafsucks.git’ set :branch, 'master' set :deploy_via, :remote_cache default_run_options[:pty] = true set :ssh_options, { :forward_agent => true }
  • 4. namespace :deploy do desc "Restarting mod_rails with restart.txt" task :restart, :roles => :app, :except => { :no_release => true } do run "touch #{current_path}/tmp/restart.txt" end [:start, :stop].each do |t| desc "#{t} task is a no-op with mod_rails" task t, :roles => :app do ; end end end
  • 5. before 'deploy:setup', 'sphinx:create_db_dir' before 'deploy:setup', 'sphinx:generate_yaml' after 'deploy:update_code', 'sphinx:symlink' namespace :sphinx do desc 'Create a directory to store the sphinx indexes' task :create_db_dir, :roles => :app do run "mkdir -p #{shared_path}/sphinx" end desc 'Generate a config yaml in shared path' task :generate_yaml, :roles => :app do sphinx_yaml = <<-EOF development: &base morphology: stem_en config_file: #{shared_path}/config/sphinx.conf test: <<: *base production: <<: *base EOF run "mkdir -p #{shared_path}/config" put sphinx_yaml, "#{shared_path}/config/sphinx.yml" end desc 'Symlink the sphinx yml and config files, and the db directory for storage of indexes' task :symlink, :roles => :app do run "ln -nfs #{shared_path}/sphinx #{release_path}/db/sphinx" run "ln -nfs #{shared_path}/config/sphinx.yml #{release_path}/config/sphinx.yml" run "ln -nfs #{shared_path}/config/sphinx.conf #{release_path}/config/sphinx.conf" end end
  • 6.
  • 7. configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist) configuration.load do # stuff here... end
  • 8. unless Capistrano::Configuration.respond_to?(:instance) abort "capistrano/ext/multistage requires Capistrano 2" end Capistrano::Configuration.instance.load do # stuff here... end
  • 9. base.rb configuration.load do # User details _cset :user, 'deployer' _cset(:group) { user } # Application details _cset(:app_name) { abort "Specify the short name of your app, set :app_name, 'foo'" } set(:application) { "#{app_name}.mycorp.com" } _cset(:runner) { user } _cset :use_sudo, false # SCM settings _cset(:appdir) { "/home/#{user}/deployments/#{application}" } _cset :scm, 'git' set(:repository) { "git@git.mycorp.com:#{app_name}.git"} _cset :deploy_via, 'remote_cache' set(:deploy_to) { appdir } # Git settings for capistrano default_run_options[:pty] = true ssh_options[:forward_agent] = true end
  • 10. common.rb def _cset(name, *args, &block) unless exists?(name) set(name, *args, &block) end end
  • 11. base.rb configuration.load do # User details _cset :user, 'deployer' _cset(:group) { user } # Application details _cset(:app_name) { abort "Specify the short name of your app, set :app_name, 'foo'" } set(:application) { "#{app_name}.mycorp.com" } _cset(:runner) { user } _cset :use_sudo, false # SCM settings _cset(:appdir) { "/home/#{user}/deployments/#{application}" } _cset :scm, 'git' set(:repository) { "git@git.mycorp.com:#{app_name}.git"} _cset :deploy_via, 'remote_cache' set(:deploy_to) { appdir } # Git settings for capistrano default_run_options[:pty] = true ssh_options[:forward_agent] = true end
  • 12. require 'capistrano/mycorp/common' configuration.load do _cset(:app_name) { abort "Specify the short name of your app, set :app_name, 'foo'" } before 'deploy:setup', 'sphinx:create_db_dir' before 'deploy:setup', 'sphinx:generate_yaml' after 'deploy:update_code', 'sphinx:symlink' namespace :sphinx do desc 'Create a directory to store the sphinx indexes' task :create_db_dir, :roles => :app do run "mkdir -p #{shared_path}/sphinx" thinking_ end desc 'Generate a config yaml in shared path' task :generate_yaml, :roles => :app do sphinx_yaml = <<-EOF development: &main_settings config_file: #{shared_path}/config/sphinx.conf sphinx.rb pid_file: #{shared_path}/pids/sphinx.pid production: <<: *main_settings EOF put sphinx_yaml, "#{shared_path}/config/sphinx.yml" end desc 'Symlink the sphinx yml and config files, and the db directory for storage of indexes' task :symlink, :roles => :app do run "ln -nfs #{shared_path}/sphinx #{release_path}/db/sphinx" run "ln -nfs #{shared_path}/config/sphinx.yml #{release_path}/config/sphinx.yml" run "ln -nfs #{shared_path}/config/sphinx.conf #{release_path}/config/sphinx.conf" end end end
  • 13. Rakefile begin require 'jeweler' Jeweler::Tasks.new do |gemspec| gemspec.name = "capistrano-mycorp" gemspec.summary = "MyCorp recipes for Capistrano" gemspec.description = "MyCorp recipes for Capistrano" gemspec.email = "tim@openmonkey.com" gemspec.homepage = "http://github.com/timriley/capistrano-mycorp" gemspec.authors = ["Tim Riley"] end rescue LoadError puts "Jeweler not available. Install it with: gem install jeweler" end
  • 14. echo "0.0.1" > VERSION rake gemspec rake build jeweler --help
  • 15. set :application, "decafsucks" set :user, 'deployer' set :deploy_to, "/home/deployer/deployments/#{application}" namespace :sphinx do set :use_sudo, false desc 'Create a directory to store the sphinx indexes' task :create_db_dir, :roles => :app do role :app, '192.168.0.1' run "mkdir -p #{shared_path}/sphinx" role :web, '192.168.0.1' end role :db, '192.168.0.1', :primary => true desc 'Generate a config yaml in shared path' set :scm, :git task :generate_yaml, :roles => :app do set :repository, 'git@git.mycorp.net:decafsucks.git' sphinx_yaml = <<-EOF set :branch, 'master' development: &base set :deploy_via, :remote_cache morphology: stem_en config_file: #{shared_path}/config/sphinx.conf default_run_options[:pty] = true test: set :ssh_options, { :forward_agent => true } <<: *base production: namespace :deploy do <<: *base desc "Restarting mod_rails with restart.txt" EOF task :restart, :roles => :app, :except => { :no_release => true } do run "mkdir -p #{shared_path}/config" run "touch #{current_path}/tmp/restart.txt" put sphinx_yaml, "#{shared_path}/config/sphinx.yml" end end [:start, :stop].each do |t| desc 'Symlink the sphinx yml and config files, and the db directory for storage of indexes' desc "#{t} task is a no-op with mod_rails" task :symlink, :roles => :app do task t, :roles => :app do ; end run "ln -nfs #{shared_path}/sphinx #{release_path}/db/sphinx" end run "ln -nfs #{shared_path}/config/sphinx.yml #{release_path}/config/sphinx.yml" end run "ln -nfs #{shared_path}/config/sphinx.conf #{release_path}/config/sphinx.conf" end before 'deploy:setup', 'sphinx:create_db_dir' end before 'deploy:setup', 'sphinx:generate_yaml' after 'deploy:update_code', 'sphinx:symlink'
  • 16. set :app_name, 'decafsucks' role :app, '192.168.0.1' role :web, '192.168.0.1' role :db, '192.168.0.1', :primary => true require 'capistrano/mycorp/base' require 'capistrano/mycorp/thinking_sphinx'
  • 17. ★ Multistage defaults ★ Mounting shares ★ web:disable ★ Gem installation ★ Gem bundling ★ Populating config.yml ★ Populating database.yml ★ Thinking Sphinx ★ ...
  • 18. Thank You! @timriley openmonkey.com timriley/capistrano-mycorp technicalpickles/jeweler