SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
Capistrano 2
  Rocks my world
       Graeme Mathieson, Rubaidh Ltd
           <mathie@rubaidh.com>
http://woss.name/ & http://www.rubaidh.com/
What’s the plan?
•   So, what is it?

•   Installing 2.0

•   What’s new in Cap 2?

•   Stuff I’ve done with cap 2
What is it?
•   A Rails deployment tool

•   A Java deployment tool

•   A troubleshooting tool

•   An ad-hoc systems management tool
Without a Capfile

$ cap2 invoke COMMAND=uname HOSTS=macallan,cardhu
   * executing `invoke'
   * executing quot;unamequot;
     servers: [quot;macallanquot;, quot;cardhuquot;]
     [macallan] executing command
     [cardhu] executing command
  ** [out :: cardhu] SunOS
  ** [out :: macallan] Linux
     command finished
$
Using cap shell
$ cap2 shell HOSTS=balvenie,cardhu
  * executing `shell'
cap> uptime
[establishing connection(s) to balvenie, cardhu]
 ** [out :: balvenie] 19:33:52 up 211 days, 7:25, 1 user, load
average: 0.06, 0.07, 0.07
 ** [out :: cardhu] 7:33pm up 10 day(s), 6:47, 2 users, load
average: 0.18, 0.16, 0.15
cap> uname -r
 ** [out :: balvenie] 2.4.21-47.0.1.EL
 ** [out :: cardhu] 5.10
cap>
Installing 2.0
$   gem   install -y net-ssh net-ftp highline
[   ...   ]
$   gem   install -s http://gems.rubyonrails.com/ capistrano
[   ...   ]




                             Done!
Co-existing with 1.x

# In ~/.bashrc
alias cap1=quot;`which cap` _1.4.1_quot;
alias cap2=quot;`which cap`quot;
alias cap=quot;echo 'Please explicitly choose cap1 or cap2.'quot;
New in 2.0?
•   More rake-like

    -   Use `cap2 -T` to list tasks

    -   Namespaces

•   Deployment strategies

•   Dependencies

•   Generic hooks
New task names
•   deploy    well, umm, deploy

•   deploy_with_migrations     deploy:migrations

•   diff_from_last_deploy    deploy:pending:diff

•   setup    deploy:setup

•   Same idea, just with namespaces
New Deployment Tasks
•   Subversion log of undeployed changes
    •   deploy:pending

•   Command, gem, file, directory dependencies
    • deploy:check
What I’ve been up to
Recipes in plugins

# New Capfile
Dir['vendor/plugins/*/recipes'].each do |plugin|
  load_paths << plugin
end
load 'deploy' if respond_to?(:namespace)
load 'config/deploy'
Daemon Strategies
•   Default uses spin/spawner/reaper

•   Solaris Service Management Framework

•   runit

•   daemontools

•   Autogenerate script/spin
Staging
•   Separate clusters for staging & deployment

•   Use svnmerge to manage branches

•   Trunk is deployed to staging server

•   Production branch gets deployed live
General Strategy


•   Create a rake task to do what you want.

•   Create a Capistrano task that runs the rake
    task.

•   Hook it into the deployment.
DB Backup - Rake
desc quot;Dumps the database into db/env-data.sql.quot;
task :dump => :environment do
  abc = ActiveRecord::Base.configurations[RAILS_ENV]
  cmd = ['mysqldump']
  cmd << quot;--host='#{abc['host']}'quot; unless abc['host'].blank?
  cmd << quot;--user='#{abc['username']}'quot;
  cmd << quot;--password='#{abc['password']}'quot;
  cmd << abc['database']
  cmd << quot; | gzip > #{RAILS_ROOT}/db/#{RAILS_ENV}-data.sql.gzquot;
  sh cmd.flatten.join ' '
end
DB Backup - Capfile

desc “Back up the production database”
task :backup, :roles => :db, :only => { :primary => true } do
  rake = fetch(:rake, 'rake')
  rails_env = fetch(:rails_env, 'production')

  run quot;cd #{current_path}; #{rake} RAILS_ENV=#{rails_env} db:dumpquot;
  get quot;#{current_path}/db/#{rails_env}-data.sql.gzquot;, quot;db/#
{rails_env}-data.sql.gzquot;
end
Hook into deployment


before quot;deploy:migratequot;,   quot;db:backupquot;
All in a plugin


$ script/plugin install -x 
http://svn.rubaidh.com/plugins/trunk/rubaidh_platform
“I checked out your slides, and they look great!
Best of luck on your presentation.”

                                   - Jamis Buck
What else do you want
      to know?

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
Background processing with Resque
Background processing with ResqueBackground processing with Resque
Background processing with Resque
 
Background Jobs with Resque
Background Jobs with ResqueBackground Jobs with Resque
Background Jobs with Resque
 
Capistrano 3 Deployment
Capistrano 3 DeploymentCapistrano 3 Deployment
Capistrano 3 Deployment
 
DATABASE AUTOMATION with Thousands of database, monitoring and backup
DATABASE AUTOMATION with Thousands of database, monitoring and backupDATABASE AUTOMATION with Thousands of database, monitoring and backup
DATABASE AUTOMATION with Thousands of database, monitoring and backup
 
Backing up thousands of containers
Backing up thousands of containersBacking up thousands of containers
Backing up thousands of containers
 
Config managament for development environments ii
Config managament for development environments iiConfig managament for development environments ii
Config managament for development environments ii
 
Puppet
PuppetPuppet
Puppet
 
Scaling HBase (nosql store) to handle massive loads at Pinterest by Jeremy Carol
Scaling HBase (nosql store) to handle massive loads at Pinterest by Jeremy CarolScaling HBase (nosql store) to handle massive loads at Pinterest by Jeremy Carol
Scaling HBase (nosql store) to handle massive loads at Pinterest by Jeremy Carol
 
PowerShell: Automation for everyone
PowerShell: Automation for everyonePowerShell: Automation for everyone
PowerShell: Automation for everyone
 
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
 
Designing net-aws-glacier
Designing net-aws-glacierDesigning net-aws-glacier
Designing net-aws-glacier
 
Php resque
Php resquePhp resque
Php resque
 
Altitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshopAltitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshop
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
 
Securing Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultSecuring Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp Vault
 
Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!
 
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, EverAltitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
 
Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.
 

Destaque (8)

QUE ES EL Spam OSCAR E OSPINA
QUE ES EL Spam OSCAR E OSPINAQUE ES EL Spam OSCAR E OSPINA
QUE ES EL Spam OSCAR E OSPINA
 
Riads Essaouira Maroc Hotel Maison 002
Riads Essaouira Maroc Hotel Maison 002Riads Essaouira Maroc Hotel Maison 002
Riads Essaouira Maroc Hotel Maison 002
 
Sample
SampleSample
Sample
 
Riads Essaouira Maroc Hotel Maison 01
Riads Essaouira Maroc Hotel Maison 01Riads Essaouira Maroc Hotel Maison 01
Riads Essaouira Maroc Hotel Maison 01
 
Kaleido02
Kaleido02Kaleido02
Kaleido02
 
Vickyandsunny V2
Vickyandsunny V2Vickyandsunny V2
Vickyandsunny V2
 
Medula Espinal
Medula EspinalMedula Espinal
Medula Espinal
 
TPTP
TPTPTPTP
TPTP
 

Semelhante a Capistrano 2 Rocks My World

Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
tomcopeland
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Jesse Vincent
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
Yiwei Ma
 
Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with Capistrano
Almir Mendes
 

Semelhante a Capistrano 2 Rocks My World (20)

Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Capistrano2
Capistrano2Capistrano2
Capistrano2
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret Sauce
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
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
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
 
Useful Kafka tools
Useful Kafka toolsUseful Kafka tools
Useful Kafka tools
 
Capistrano
CapistranoCapistrano
Capistrano
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
Puppet Camp 2012
Puppet Camp 2012Puppet Camp 2012
Puppet Camp 2012
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
Memcached Study
Memcached StudyMemcached Study
Memcached Study
 
How I hack on puppet modules
How I hack on puppet modulesHow I hack on puppet modules
How I hack on puppet modules
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with Capistrano
 
EC2
EC2EC2
EC2
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual Infrastructure
 
infra-as-code
infra-as-codeinfra-as-code
infra-as-code
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Capistrano 2 Rocks My World

  • 1. Capistrano 2 Rocks my world Graeme Mathieson, Rubaidh Ltd <mathie@rubaidh.com> http://woss.name/ & http://www.rubaidh.com/
  • 2. What’s the plan? • So, what is it? • Installing 2.0 • What’s new in Cap 2? • Stuff I’ve done with cap 2
  • 3. What is it? • A Rails deployment tool • A Java deployment tool • A troubleshooting tool • An ad-hoc systems management tool
  • 4. Without a Capfile $ cap2 invoke COMMAND=uname HOSTS=macallan,cardhu * executing `invoke' * executing quot;unamequot; servers: [quot;macallanquot;, quot;cardhuquot;] [macallan] executing command [cardhu] executing command ** [out :: cardhu] SunOS ** [out :: macallan] Linux command finished $
  • 5. Using cap shell $ cap2 shell HOSTS=balvenie,cardhu * executing `shell' cap> uptime [establishing connection(s) to balvenie, cardhu] ** [out :: balvenie] 19:33:52 up 211 days, 7:25, 1 user, load average: 0.06, 0.07, 0.07 ** [out :: cardhu] 7:33pm up 10 day(s), 6:47, 2 users, load average: 0.18, 0.16, 0.15 cap> uname -r ** [out :: balvenie] 2.4.21-47.0.1.EL ** [out :: cardhu] 5.10 cap>
  • 6. Installing 2.0 $ gem install -y net-ssh net-ftp highline [ ... ] $ gem install -s http://gems.rubyonrails.com/ capistrano [ ... ] Done!
  • 7. Co-existing with 1.x # In ~/.bashrc alias cap1=quot;`which cap` _1.4.1_quot; alias cap2=quot;`which cap`quot; alias cap=quot;echo 'Please explicitly choose cap1 or cap2.'quot;
  • 8. New in 2.0? • More rake-like - Use `cap2 -T` to list tasks - Namespaces • Deployment strategies • Dependencies • Generic hooks
  • 9. New task names • deploy well, umm, deploy • deploy_with_migrations deploy:migrations • diff_from_last_deploy deploy:pending:diff • setup deploy:setup • Same idea, just with namespaces
  • 10. New Deployment Tasks • Subversion log of undeployed changes • deploy:pending • Command, gem, file, directory dependencies • deploy:check
  • 12. Recipes in plugins # New Capfile Dir['vendor/plugins/*/recipes'].each do |plugin| load_paths << plugin end load 'deploy' if respond_to?(:namespace) load 'config/deploy'
  • 13. Daemon Strategies • Default uses spin/spawner/reaper • Solaris Service Management Framework • runit • daemontools • Autogenerate script/spin
  • 14. Staging • Separate clusters for staging & deployment • Use svnmerge to manage branches • Trunk is deployed to staging server • Production branch gets deployed live
  • 15. General Strategy • Create a rake task to do what you want. • Create a Capistrano task that runs the rake task. • Hook it into the deployment.
  • 16. DB Backup - Rake desc quot;Dumps the database into db/env-data.sql.quot; task :dump => :environment do abc = ActiveRecord::Base.configurations[RAILS_ENV] cmd = ['mysqldump'] cmd << quot;--host='#{abc['host']}'quot; unless abc['host'].blank? cmd << quot;--user='#{abc['username']}'quot; cmd << quot;--password='#{abc['password']}'quot; cmd << abc['database'] cmd << quot; | gzip > #{RAILS_ROOT}/db/#{RAILS_ENV}-data.sql.gzquot; sh cmd.flatten.join ' ' end
  • 17. DB Backup - Capfile desc “Back up the production database” task :backup, :roles => :db, :only => { :primary => true } do rake = fetch(:rake, 'rake') rails_env = fetch(:rails_env, 'production') run quot;cd #{current_path}; #{rake} RAILS_ENV=#{rails_env} db:dumpquot; get quot;#{current_path}/db/#{rails_env}-data.sql.gzquot;, quot;db/# {rails_env}-data.sql.gzquot; end
  • 18. Hook into deployment before quot;deploy:migratequot;, quot;db:backupquot;
  • 19. All in a plugin $ script/plugin install -x http://svn.rubaidh.com/plugins/trunk/rubaidh_platform
  • 20. “I checked out your slides, and they look great! Best of luck on your presentation.” - Jamis Buck
  • 21. What else do you want to know?