I use cap invoke a lot to run commands on a bunch of servers. I would like to also use capistrano to push a single file to a bunch of servers.
At first I thought that PUT would do it, but put makes you create the data for the file. I don't want to do this, I just want to copy an existing file from the machine where I'm running the capistrano comand to the other machines.
It would be cool if I could do something like this:
host1$ cap HOSTS=f1.foo.com,f2.foo.com,f3.foo.com COPY /tmp/bar.bin
I would expect this to copy host1:/tmp/bar.bin to f1.foo.com:/tmp/bar.bin and f2.foo.com:/tmp/bar.bin and f3.foo.com:/tmp/bar.bin
This kind of thing seems very useful so I'm sure there must be a way to do this...
upload(from, to, options={}, &block)
The upload action stores the file at the given path on all servers targeted by the current task.
If you ever used the deploy:upload task before, then you might already know how this method works. It takes the path of the resource you want to upload and the target path on the remote servers.
desc "Uploads CHANGELOG.txt to all remote servers."
task :upload_changelog do
upload("#{RAILS_ROOT}/CHANGELOG.txt", "#{current_path}/public/CHANGELOG")
end
source
This uploads all files to the respective servers.
cap deploy:upload FILES=abc,def
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With