Last active
March 28, 2018 21:53
-
-
Save allaire/8419898 to your computer and use it in GitHub Desktop.
Capistrano 3 upload file from erb template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def template(from, to, options = {}) | |
template_path = File.expand_path("../../templates/#{from}", __FILE__) | |
template = ERB.new(File.new(template_path).read).result(binding) | |
upload! StringIO.new(template), to, mode: 0644 # Otherwise it's set to 0640, which is not readable by other users (https://github.com/net-ssh/net-scp/blob/master/lib/net/scp/upload.rb#L63) | |
sudo "chown root:root #{to}" if options[:as_root] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@IwateKyle Nope, you have to edit sudoers file, see https://github.com/capistrano/sshkit/blob/158c2867071e015a117e188d1a0ee7b579c9b24e/lib/sshkit/backends/netssh.rb
@uribefache I was missing a
../
, I just fixed it :D