Skip to content
cedriclombardot edited this page May 4, 2012 · 4 revisions

Recipes for Webistrano are Capistrano recipes and therefore follow the same structure and API discussed in the Capistrano Documentation.

With that said, here's a few short examples of recipes and some extra documentation links to go with:

Using namespaces is a great way to organize your recipes. Every recipe can be its own namespace, or you could put several namespaces in a recipe. Either way, the namespace helps organize related tasks.

namespace :wordpress do
    task :upload do
        #recipe guts here
    end

    task :something do
        #recipe guts here
    end
end

Examples of Action Module

What goes inside a task is the actual "action" or command you want to run on the remote server. Some actions like "upload" will conduct several predefined commands, behind the scenes, to complete the intended action. Others like "run" will simply execute the specified bash/ssh command on the remote server.

upload("files/wallpaper.png", "/var/www/html/wp-content/uploads")
run "#{sudo} apachectl restart"

Put the above all together into a recipe

The recipe below simply uploads a file to the remote server and executes an apache restart command. Not that a restart is needed after an upload, this is simply illustrating how to put a recipe together. You can copy and paste this into a new recipe. Notice the use of #{sudo} Webistrano config variable.

namespace :wordpress do
    task :upload do
        upload("files/wallpaper.png", "/var/www/html/wp-content/uploads")
        run "#{sudo} apachectl restart"
    end
end

After saving the above as a recipe and assigning that recipe to a stage, you will see the following option in the "All tasks:" Deployments select list (for the assigned stage): wordpress:upload