Fork me on GitHub

Screwcap

Screwcap is a Net::SSH wrapper that makes it easier to perform actions on remote servers. Whether you are deploying a rails applicaiton or just clearing out a temporary directory, screwcap makes these tasks easy.

Rationale

Installation

Installation is as easy as running gem install screwcap.

Setting up screwcap to use rails is trivial. In your Rails.root, simply run screwcap --setup-rails See this section for more info.

Example Recipe

To execute the above recipe, run the following:

screwcap recipe.rb restart_server

Recipe Book

Screwcap has a growing list of supported recipes, that includes different rails deployment strategies, and other recipes for various tasks!

Check out the recipe database

Documentation

Servers

Servers contain the address(es) you would like to run your tasks on.

Options Examples:

Tasks and Command Sets

Tasks are a simple collection of commands to run on a server or servers. Tasks can also run other tasks.

Options Commands Examples:

Use

The use keyword will automatically import another recipe file into your main recipe file.

Currently use only looks in the same directory as your recipe file.

Examples:

You have one file, called commands.rb

Then you have your main recipe file.

All the items from commands.rb will be fully ingrained and ready to use in your recipe file.

Using command sets and the use keyword is how screwcap is able to be decoupled from tasks, like deploying a rails application.

Variables

You can declare variables with the set command anywhere in the deployment recipe. Variables can be overridden in tasks and command sets. Tasks and command sets inherit the scope of the calling task or command set.

Examples:

Sequences

Sequences are a list of tasks to run.

Options:

You can run a sequence in the same way you run a task.

Callbacks

Screwcap supports both :before and :after callbacks for tasks, in 2 different ways.

The first way is to add a :before => :do_this To your task spec.

The second way is to declare a task named before_task where task is the name of the task.

Using Screwcap with Rails

Screwcap is a great choice to deploy rails applications, because the actual deployment implementation is decoupled from the screwcap base, thus the recipe file can be updated continually.

Before you begin, be sure to add gem 'screwcap' to your Gemfile's :development section.

Setting up screwcap to use rails is trivial. In your Rails.root, simply run screwcap --setup-rails

This sets up a sample recipe file located in config/screwcap/recipe.rb. In the same directory you also get the newest rails tasks file.

Edit that file, then run rake -T remote to see your recipes listed and ready to run!

Using screwcap for other things

Screwcap comes with a binary called screwcap. You can run one or more tasks using the binary.

Recipe Database

I started a new repository called screwcap_recipes that contains all the latest and greatest recipes that fellow screwcappers have to offer. Feel free to write your own and contribute!

Author, Credits, and License

(MIT License)

Copyright © 2010 Grant Ammons (grant@pipelinedeals.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.