Sha256: d452916b81f0ad947f0dda2da3e13b326749bc0ac31de4e68d322a0daf7cce05
Contents?: true
Size: 1.48 KB
Versions: 9
Compression:
Stored size: 1.48 KB
Contents
require 'open-uri' require 'ey-deploy/logged_output' module EY class Server < Struct.new(:hostname, :role, :name) include LoggedOutput def initialize(*fields) super self.role = self.role.to_sym end def self.config=(config) @@config = config end def config @@config end attr_writer :default_task def self.from_roles(*roles) roles = roles.flatten.compact return all if !roles || roles.include?(:all) || roles.empty? all.select do |s| roles.include?(s.role) || roles.include?(s.name) end end def self.from_hash(h) new(h[:hostname], h[:role], h[:name]) end def self.all @all end def self.all=(server_hashes) @all = server_hashes.map { |s| from_hash(s) } end def self.current all.find {|s| s.local? } end def local? [:app_master, :solo].include?(role) end def push_code return if local? run "mkdir -p #{config.repository_cache}" logged_system(%|rsync --delete -aq -e "#{ssh_command}" #{config.repository_cache}/ #{config.user}@#{hostname}:#{config.repository_cache}|) end def run(command) if local? logged_system(command) else logged_system(ssh_command + " " + Escape.shell_command(["#{config.user}@#{hostname}", command])) end end def ssh_command "ssh -i #{ENV['HOME']}/.ssh/internal -o StrictHostKeyChecking=no -o PasswordAuthentication=no" end end end
Version data entries
9 entries across 9 versions & 1 rubygems