How can I customize Capistranos SSH command?

170 views Asked by At

In order to deploy into FreeBSD jails, I need my commands to look like this:

ssh [email protected] "jexec 'web_jail' $THE_COMMAND_HERE"
ssh [email protected] "jexec 'db_jail' $ANOTHER_COMMAND_HERE"
...

Note that, though technically possible, I want to avoid activating SSH in the jails directly!

So how can I have Capistrano operate like this?

(Note that I am mostly asking in reference to amending the default cap tasks.)

1

There are 1 answers

1
pedz On

Got chainsaw?

One part that needs clarification is who determines if it is web_jail or db_jail? Is that the role with _jail appended to it?

The place I would hack into is Capistrano::Command.replace_placeholders. You could use an alias_method_chain to hook in. The original is in lib/capistrano/command.rb.

You might be able to do some fancy footwork with the "shell" variable but that would seem pretty hard to do.

Since you have two people watching, this may be a good addition to submit to the Capistrano folks.