Use envdir with Capistrano v3
I was trying to use envdir in a Capistrano deploy so I needed to prefix all rake commands with envdir secret
. After an hour of looking at capistrano codes, I saw that behind its magic was sshkit.
What I did was set an after rvm:hook
to prefix the rake as follows:
after 'rvm:hook', 'deploy:prefix_rake'
desc 'Overwrites the default rake command and adds a prefix'
task :prefix_rake do
SSHKit.config.command_map[:rake] = "envdir secret #{ SSHKit.config.command_map[:rake] }"
end
What command_map
does is set the command to run when you do execute :command
. It should be a symbol to get it to work.
Now it works nicely with capistrano-rvm and sets the env vars before any :rake
is executed.
Written by Daniel Alejandro Gaytán Valencia
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#