Class: SshKeyMan::Uploader
- Inherits:
-
Object
- Object
- SshKeyMan::Uploader
- Defined in:
- lib/uploader.rb
Class Method Summary collapse
-
.upload!(host, port, user, source, dest) ⇒ Object
upload a file to a remote server.
-
.upload_all_public_keys(group) ⇒ Object
upload authorized_keys for a specific group.
-
.upload_to_all_servers(source, dest, group) ⇒ Object
upload file to a group of servers.
Class Method Details
.upload!(host, port, user, source, dest) ⇒ Object
upload a file to a remote server
27 28 29 30 31 32 |
# File 'lib/uploader.rb', line 27 def self.upload! host, port, user, source, dest puts "coping file from #{source} to #{user}@#{host}:#{dest}" `scp -P #{port} #{source} #{user}@#{host}:#{dest}` raise "upload failed" if $?.exitstatus != 0 end |
.upload_all_public_keys(group) ⇒ Object
upload authorized_keys for a specific group
9 10 11 12 |
# File 'lib/uploader.rb', line 9 def self.upload_all_public_keys group = File.join(".", "authorized_keys") upload_to_all_servers , "~/.ssh/", group end |
.upload_to_all_servers(source, dest, group) ⇒ Object
upload file to a group of servers
16 17 18 19 20 21 22 23 |
# File 'lib/uploader.rb', line 16 def self.upload_to_all_servers source, dest, group server_list_path = File.join(".", "server_list.yml") servers = YAML::load_file(server_list_path)['servers'][group] raise "No Server Group: #{group}" if servers.size == 0 servers.each do |server_info| upload! server_info["host"], server_info["port"]||"22", server_info["user"], source, dest end end |