Your SlideShare is downloading. ×
Intermediate  Capistrano
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Intermediate Capistrano

2,296

Published on

A talk I gave at North West Ruby User's Group (http://nwrug.org/) August 20th 2009

A talk I gave at North West Ruby User's Group (http://nwrug.org/) August 20th 2009

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,296
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
37
Comments
0
Likes
7
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Transcript

    • 1. Capistrano at your command Tips and tricks, from wimp to winner Lee Hambley - August 20th 2009 1
    • 2. What’s on the menu? ✤ Capistrano’s Structure ✤ Net::SSH ✤ The Scope of Execution ✤ Task chaining; your own multi-stage ✤ Streams ✤ Prompts 2
    • 3. Simply put, Capistrano is a tool for automating tasks on one or more remote servers. It executes commands in parallel on all targeted machines, and provides a mechanism for rolling back Capistrano changes across multiple machines. It is ideal for anyone doing any kind of system administration, either professionally or incidentally. What’s in the Box? Net::SSH Net::SFTP Net::SCP Net::SSH::Gateway $ gem dependency capistrano Gem capistrano-2.5.8 Capistrano’s Structure net-ssh (>= 2.0.10, runtime) net-sftp (>= 2.0.0, runtime) net-scp (>= 1.0.0, runtime) net-ssh-gateway (>= 1.0.0, runtime) 3
    • 4. Simply put, Capistrano is a tool for automating tasks on one or more remote servers. It executes commands in parallel on all targeted machines, and provides a mechanism for rolling back Capistrano changes across multiple machines. It is ideal for anyone doing any kind of system administration, either professionally or incidentally. What’s in the Box? ✤ Consistent support for different source control software. Net::SSH Net::SFTP Net::SCP Net::SSH::Gateway $ gem dependency capistrano Gem capistrano-2.5.8 Capistrano’s Structure net-ssh (>= 2.0.10, runtime) net-sftp (>= 2.0.0, runtime) net-scp (>= 1.0.0, runtime) net-ssh-gateway (>= 1.0.0, runtime) 3
    • 5. Simply put, Capistrano is a tool for automating tasks on one or more remote servers. It executes commands in parallel on all targeted machines, and provides a mechanism for rolling back Capistrano changes across multiple machines. It is ideal for anyone doing any kind of system administration, either professionally or incidentally. What’s in the Box? ✤ Consistent support for different source control software. Net::SSH Net::SFTP Net::SCP ✤ Rake-esque task definitions, including before/after callbacks for method chaining. Net::SSH::Gateway $ gem dependency capistrano Gem capistrano-2.5.8 Capistrano’s Structure net-ssh (>= 2.0.10, runtime) net-sftp (>= 2.0.0, runtime) net-scp (>= 1.0.0, runtime) net-ssh-gateway (>= 1.0.0, runtime) 3
    • 6. Simply put, Capistrano is a tool for automating tasks on one or more remote servers. It executes commands in parallel on all targeted machines, and provides a mechanism for rolling back Capistrano changes across multiple machines. It is ideal for anyone doing any kind of system administration, either professionally or incidentally. What’s in the Box? ✤ Consistent support for different source control software. Net::SSH Net::SFTP Net::SCP ✤ Rake-esque task definitions, including before/after callbacks for method chaining. Net::SSH::Gateway ✤ Ability to detect and rollback broken jobs using transactions $ gem dependency capistrano Gem capistrano-2.5.8 Capistrano’s Structure net-ssh (>= 2.0.10, runtime) net-sftp (>= 2.0.0, runtime) net-scp (>= 1.0.0, runtime) net-ssh-gateway (>= 1.0.0, runtime) 3
    • 7. Simply put, Capistrano is a tool for automating tasks on one or more remote servers. It executes commands in parallel on all targeted machines, and provides a mechanism for rolling back Capistrano changes across multiple machines. It is ideal for anyone doing any kind of system administration, either professionally or incidentally. What’s in the Box? ✤ Consistent support for different source control software. Net::SSH Net::SFTP Net::SCP ✤ Rake-esque task definitions, including before/after callbacks for method chaining. Net::SSH::Gateway ✤ Ability to detect and rollback broken jobs using transactions ✤ Roles, :app, :web, :db & :define-your-own $ gem dependency capistrano Gem capistrano-2.5.8 Capistrano’s Structure net-ssh (>= 2.0.10, runtime) net-sftp (>= 2.0.0, runtime) net-scp (>= 1.0.0, runtime) net-ssh-gateway (>= 1.0.0, runtime) 3
    • 8. Net::SSH ✤ Magical pure-Ruby implementation of the SSH protocol. ✤ Honours your ~/ssh/config settings. ✤ Supports (creating and using) Tunnels, Gateways, Agent Forwarding and more... ✤ Super clean syntax...
    • 9. Net::SSH ✤ Magical pure-Ruby implementation of the SSH protocol. ✤ Honours your ~/ssh/config settings. ✤ Supports (creating and using) Tunnels, Gateways, Agent Forwarding and more... ✤ Super clean syntax...
    • 10. Net::SSH ✤ Magical pure-Ruby implementation of the SSH protocol. ✤ Honours your ~/ssh/config settings. ✤ Supports (creating and using) Tunnels, Gateways, Agent Forwarding and more... ✤ Super clean syntax...
    • 11. The Scope of Execution ✤ What runs where? ✤ What permissions will I need? ✤ Obscure errors about permissions? ✤ .. lots of different things happening
    • 12. The Scope of Execution $ → cap deploy Calling another Capistrano task. * executing `deploy' * executing `deploy:update' Transactions, you can define what to do for your own transactions if a task within it fails. ** transaction: start { * executing `deploy:update_code' A shell command run on your workstation. executing locally: "git ls-remote git@github.com:leehambley/ capistrano-website.git HEAD" A shell command run remotely. * executing "git clone -q git@github.com:leehambley/capistrano- website.git /u/apps/capistrano-website/releases/20090820114515 && ...... " { * executing `deploy:finalize_update' A shell command run remotely, connecting to your repository server. † * executing "chmod -R g+w /u/apps/capistrano-website/releases/ 20090820114515" { * executing `deploy:symlink' * executing "rm -f /u/apps/capistrano-website/current && ln -s /u/apps/ capistrano-website/releases/20090820114515 /u/apps/capistrano-website/ current" ** transaction: commit † Requires passwordless access to your repository server from your servers; this can be either keys (GitHub deploy keys feature) or SSH agent forwarding to provide your own key by proxy
    • 13. Task Chaining ➊ ➋ ➌ $ rake db:migrate spec features
    • 14. Task Chaining ➊ ➋ ➌ $ rake db:migrate spec features ➊ ➋ $ cap check-ruby-version deploy
    • 15. Task Chaining ➊ ➋ ➌ $ rake db:migrate spec features ----------------- ➊ ➋ $ cap check-ruby-version deploy
    • 16. Task Chaining ➊ ➋ ➌ $ rake db:migrate spec features ----------------- ➊ ➋ $ cap check-ruby-version deploy capture Executes a command on a single host and returns ("captures") the output as a string. stream Very similar to run, but optimised for displaying live streams of text (like tailed log files) from multiple hosts. run Execute commands on one or more servers
    • 17. Task Chaining ➊ ➋ ➌ $ rake db:migrate spec features ----------------- ➊ ➋ $ cap check-ruby-version deploy ➊ ➋ ➌ $ cap staging check-ruby-version deploy capture Executes a command on a single host and returns ("captures") the output as a string. stream Very similar to run, but optimised for displaying live streams of text (like tailed log files) from multiple hosts. run Execute commands on one or more servers
    • 18. Task Chaining ➊ ➋ ➌ $ rake db:migrate spec features ----------------- ➊ ➋ $ cap check-ruby-version deploy ➊ ➋ ➌ $ cap staging check-ruby-version deploy capture Executes a command on a single host and returns ("captures") the output as a string. stream Very similar to run, but optimised for displaying live streams of text (like tailed log files) from multiple hosts. run Execute commands on one or more servers
    • 19. Streams? In Unix and Unix-like operating systems, as well as certain programming language interfaces, the standard streams are pre-connected input and output channels between a computer program and its environment (typically a text terminal) when it begins execution. The three I/O connections are called standard input, standard output and standard error.
    • 20. Streams? In Unix and Unix-like operating systems, as well as certain programming language interfaces, the standard streams are pre-connected input and output channels between a computer program and its environment (typically a text terminal) when it begins execution. The three I/O connections are called standard input, standard output and standard error.
    • 21. Streams? In Unix and Unix-like operating systems, as well as certain programming language interfaces, the standard streams are pre-connected input and output channels between a computer program and its environment (typically a text terminal) when it begins execution. The three I/O connections are called standard input, standard output and standard error.
    • 22. Prompts Implementation
    • 23. Prompts Implementation
    • 24. Prompts Implementation
    • 25. Resources ✤ Capistrano Wiki: - http://www.capify.org/ ✤ Bash Hackers Wiki: - http://bash-hackers.org/wiki/ ✤ Questions: - lee.hambley@gmail.com ✤ Support: - irc://freenode.org/capistrano ✤ Mailing List: - http://groups.google.com/group/capistrano 10
    • 26. Questions?

    ×